Ansible is a great tool for automating common IT devops tasks for many machines in parallel.
Control Node: This is the machine that actually runs ansible + InventoryInventory: A list of managed nodes that are logically organised. You can create an inventory on the control node.
Playbook A list of plays that define the order in which Ansible performs operations, from top to bottom, to achieve an overall goal.
Play An ordered list of tasks that maps to managed nodes in an inventory.
Task A reference to a single module that defines the operations that Ansible performs.
Module A unit of code or binary that Ansible runs on managed nodes. Ansible modules are grouped in collections with a Fully Qualified Collection Name (FQCN) for each module.
Create a pip environment.
python3 -m venv venv
. venv/bin/activate
Install ansible. This will install ansible binary and ansible-* other binaries.
pip3 install ansible
Create a file named inventory.ini and add your hosts under different groups. Even if you do not define any groups in your inventory file, Ansible creates two default groups: all and ungrouped.
You can specify a ssh user and a private key to file to connect to said host.
[myhosts]
192.168.1.83 ansible_ssh_user=root ansible_ssh_private_key_file=./athena/ssh_config/id_rsa
192.168.1.82 ansible_ssh_user=root ansible_ssh_private_key_file=./athena/ssh_config/id_rsa
Validate the inventory file. You can use -i multiple times to include multiple inventories.
ansible-inventory -i inventory.ini --list
Run the playbook against all hosts in inventory file
ansible-playbook -i inventory.ini playbook.yaml
List all installed ansible-galaxy collections