DevOps Classroomnotes 28/Jan/2023

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

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 -i to 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.

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

Exercises

  1. Install mysql and postgres using ansible roles
  2. Install mongo db on ubuntu
  3. Install ha proxy
  4. Install java on windows server
  5. Install nop commerce Refer Here
  6. convert this script Refer Here into ansible playbook

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner