Ansible-Controlling playbook execution
- Forks:
- Maximum number of simultaneous connections Ansible made on each Task
- How to set it:
- /etc/ansible/ansible.cfg
[defaults]
forks = 100 ansible-playbook -f 100 my_playbook.yml
- /etc/ansible/ansible.cfg
- Strategy:
- Types
- linear
- free
- debug
- How to set strategy
- In playbook
“`yaml
<li>hosts: all
become: yes
strategy: free
“` - In playbook
- /etc/ansible/ansible.cfg
[defaults]
strategy = free
- Types
Keywords that effect ansible playbook execution
-
serial:
- if you want to manage only few machines at a time.
- You can define how many hosts Ansible should manage at a single time by using the serial keywork
“`yaml
</ul>
<hr />
<ul>
<li>name: test
hosts: all
serial: 2
gather_facts: no
tasks:<ul>
<li>name: first task
debug:
msg: "first task"</li>
<li>name: second task
debug:
msg: "second task"
“`
“`
PLAY [all] ##################################</li>
</ul>
TASK [ first task] ##########################
changed [web1]
changed [web2]
TASK [ second task] ##########################
changed [web1]
changed [web2]
PLAY [all] ##################################
TASK [ first task] ##########################
changed [web3]
changed [web4]
TASK [ second task] ##########################
changed [web3]
changed [web4]
“`
* throttle: sets number of workers for a particular task. This can be set at block or task.
* run_once: Runs only one node in the inventory
* ignore_errors: ignores all the errors occured during playbook execution
* ignore_unreachable: ignores unreachable nodes
* order: Order in which nodes from inventory are picked

Ansible Tower Installation
- Refer Here
- For ansible tower installation and usage please refer classroom video
Ansible Vault
- Ansible Vault helps secure vital secret information.
- Ansible vault can encrypt variables or even entire files and YAML Playbooks
- Create an encrypted file in Ansible
- Create a file with
username: tomcat and password: tomcat
in yaml
- Create a file with
- view the encrypted file
- edit the content
- if you want to change the password for the file
-
Encrypting existing files using vault
-
Decryption of the encrypted file