Ansible: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
Line 9: Line 9:


== Playbook ==
== Playbook ==
{|
| valign="top" colspan="2" |
  chorke-academia-project
  chorke-academia-project
  ├─ main_playbook.yml
  ├─ main_playbook.yml
Line 25: Line 27:
               └─ all.yaml
               └─ all.yaml


| valign="top" |
<source lang="yaml">
all:
  children:
    gtw_servers:
      hosts:
        10.20.22.1:
    dmz_servers:
      hosts:
        10.20.22.100:
    dns_servers:
      hosts:
        10.20.22.[100:102]:
      vars:
        ansible_port: 22
        ansible_user: deploy
        ansible_ssh_pass: sadaqah
</source>
|-
| colspan="3" |
----
|-
| valign="top" colspan="3" |
<source lang="bash">
<source lang="bash">
mkdir -p chorke-academia-project/inventories/{staging,test}/academia/{group_vars,host_vars}
mkdir -p chorke-academia-project/inventories/{staging,test}/academia/{group_vars,host_vars}
Line 35: Line 61:
ansible-inventory -i inventories/staging --list
ansible-inventory -i inventories/staging --list
</source>
</source>
|}


== Modules ==
== Modules ==

Revision as of 09:27, 27 November 2022

sudo apt update  && sudo apt list  --upgradeable
sudo apt upgrade && sudo apt install ansible ansible-lint sshpass

sshpass -V
ansible --version
ansible-lint --version

Playbook

chorke-academia-project
├─ main_playbook.yml
└─ inventories/
   ├─ staging/
   │  └─ academia/
   │     ├─ inventory.yml
   │     └─ group_vars/
   │        ├─ academia_group.yaml
   │        └─ all.yaml
   └─ test/
      └─ academia/
         ├─ inventory.yml
         └─ group_vars/
             ├─ academia_group.yaml
             └─ all.yaml
all:
  children:
    gtw_servers:
      hosts:
        10.20.22.1:
    dmz_servers:
      hosts:
        10.20.22.100:
    dns_servers:
      hosts:
        10.20.22.[100:102]:
      vars:
        ansible_port: 22
        ansible_user: deploy
        ansible_ssh_pass: sadaqah

mkdir -p chorke-academia-project/inventories/{staging,test}/academia/{group_vars,host_vars}
touch    chorke-academia-project/inventories/{staging,test}/academia/group_vars/{all,academia_group}.yaml
touch    chorke-academia-project/inventories/{staging,test}/academia/inventory.yml
touch    chorke-academia-project/main_playbook.yml

cd chorke-academia-project
ansible-playbook  -i inventories/staging main_playbook.yml
ansible-inventory -i inventories/staging --list

Modules





Namespaces


Knowledge

python3 -m venv .venv --prompt="academia"
# source .venv/bin/activate
# (academia) $
python3 -m venv .venv --prompt="molecule"
# source .venv/bin/activate
# (molecule) $
python -m venv .venv --prompt="molecule"
# .venv\Scripts\activate
# (molecule) PS>

pip install -r requirements.txt
pip freeze   > requirements.txt

ansible-inventory\
 -i inventories/staging/\
 --list
ansible dns_servers\
 -i inventories/staging/\
 -m ping
ansible-playbook\
 -i inventories/staging/\
 main_playbook.yml

References