parallelism in ansible
- Ansible forks: This represents the number of hosts in which ansible will parallely execute the playbook
- The default number of forks are 5, This value can be changed while executing ansible command or in the configuration file.
- Refer Here for the setting number of forks
- If you want to run the whole playbook in batches use serial Refer Here
Order of execution
Tags in Ansible
- Refer Here
- Refer Here for the playbook with tags
ansible-playbook -i hosts tags.yaml --tags pre
ansible-playbook -i hosts tags.yaml --tags pre,main
ansible-playbook -i hosts tags.yaml --skip-tags pre
ansible-playbook -i hosts tags.yaml --skip-tags pre,verbose
Dyanmic inventory
- dynamic inventory is where you can still use
-ito pass this script to ansible playbook. - Ansible will execute this script (i.e. this file needs to have executable permissions). Script can be in any language. ansible will call this script and read the json response and dynamically use the ipaddress/hostnames from the script.
- Now to get ansible inventories dynamically we have plugins for every cloud.
- aws ec2 Refer Here
- azure vms Refer Here
Ansible for Windows
- Refer Here
- ansible_connection variable will have a default value of ssh, while connecting to windows machines we have two options
- winrm
- ssh
Winrm setup on Windows Server
- Create a windows server
- Setup winrm Refer Here
- Run Powershell as admin
- Refer Here for the detailed steps
- Refer Here for windows modules
- Installing iis on windows server
- manual steps: Refer Here
- Refer Here for the playbook


Exercises
- Install mysql and postgres using ansible roles
- Install mongo db on ubuntu
- Install ha proxy
- Install java on windows server
- Install nop commerce Refer Here
- convert this script Refer Here into ansible playbook
