Ansible playbooks are lists of tasks that are automatically run against hosts. A group of hosts make up his Ansible inventory. Each module in an Ansible playbook performs a specific task. Each module contains metadata that determines when and where tasks are run and by whom.
Ansible is a serverless configuration management tool
Install Commands ----> sudo apt-get install ansible
Then Install sudo apt-get install sshpass -y
for ssh passwords for particular serverless
Ansible Inventory Format is ----> .yaml .ini we can use
Ansible Inventory Default File Is ----> /etc/ansible/hosts
Firstly Uncomment this File
sudo nano /etc/ansible/ansible.cfg
++++++++++++++++++++++++++++++++++++++++++++++++++
# Uncomment this in order to avoid SSH key host checking.
host_key_checking = False
+++++++++++++++++++++++++++++++++++++++++++++++++++
ansible <alias name> -m modulename -i file name
we can Write this type
for ex : ansible-worker ansible_host=3.108.237.22 ansible_ssh_private_key_file=/home/kapil/Downloads/Ansible-Worker.pem ansible_connection=ssh ansible_port=22 ansible_user=ubuntu
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
ansible-worker ----> alias name of Inventory
ansible_host=3.108.237.22 ----> ansible host or IP that or ansible worker host IP which u want to control
ansible_ssh_private_key_file=/home/Kapil/Downloads/Ansible-Worker.pem ----> server keys and file location
ansible_connection=ssh ----> ansible connection ssh or anything
ansible_port=22 ----> ansible-worker port 22 or 92 or another thing
ansible_user=ubuntu ----> ansible-worker user or us server ka kis user se command chalvana chate home
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Wild Cards:
If Hume alag alag Hostname hai or unka ek group banana hai to kasie banayege means alag naam hai
but unko ek group mein setup krke run krna hai to kaise krege
ex: room,week,kapil,rahul,nitin,etc so aako ek hi group mein add krna hai to
[webserver] |
room |
week |--------> group of webserver
kapil |
Rahul |
[database] |-------------> group of database
nitin |
Is an Ansible playbook a script?
Ansible playbooks are organizational units of scripts that define the work of server configuration managed by Ansible automation tools. Ansible is a configuration management tool that uses Ansible playbooks to automate the configuration of multiple servers.