Configure automation content navigator to use a specific image by default and then use it to examine the current Ansible configuration.
Outcomes
Configure automation content navigator by using an ansible-navigator.yml file.
Configure Ansible by using an ansible.cfg file.
Use the ansible-navigator command to review your current Ansible configuration.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command creates an Ansible project in the /home/student/config-review directory.
[student@workstation ~]$ lab start config-review
Procedure 4.3. Instructions
Change to the /home/student/config-review directory for your Ansible project and configure the automation content navigator settings file to use the hub.lab.example.com/ee-supported-rhel8:latest image by default, and set the pull policy to missing.
Change to the /home/student/config-review directory.
[student@workstation ~]$ cd ~/config-reviewEdit the ~/config-review/ansible-navigator.yml automation content navigator settings file.
Change the value of the image directive to hub.lab.example.com/ee-supported-rhel8:latest, and in the pull section change the value of the policy directive to missing.
Use the following grep command to display lines that do not begin with a number sign.
The output of the grep command displays the expected content after you modify the ansible-navigator.yml file:
[student@workstation config-review]$grep -v '^#' ansible-navigator.yml--- ansible-navigator: execution-environment: enabled: True image:hub.lab.example.com/ee-supported-rhel8:latestpull: policy:missinglogging: level: critical playbook-artifact: enable: True
Because the install-web.yml playbook requires prompting for the privilege escalation password, you must disable creating playbook artifacts.
Configure the automation content navigator settings file to disable creating playbook artifacts.
Edit the ~/config-review/ansible-navigator.yml automation content navigator settings file.
In the playbook-artifact section, change the value of the enable directive to False.
The output of the grep command displays the expected content after you modify the ansible-navigator.yml file:
[student@workstation config-review]$grep -v '^#' ansible-navigator.yml--- ansible-navigator: execution-environment: enabled: True image: hub.lab.example.com/ee-supported-rhel8:latest pull: policy: missing logging: level: critical playbook-artifact: enable:False
Use automation content navigator to determine how to specify the maximum number of forks Ansible uses to execute tasks on target hosts.
Identify the name of the variable and to which section the variable belongs.
Modify the ~/config-review/ansible.cfg Ansible configuration file to set the maximum number of forks to 15.
Use automation content navigator to verify the changes.
Run the ansible-navigator config command with no arguments.
[student@workstation config-review]$ ansible-navigator config
Name Default Source Current
0│Action warnings True default True
1│Agnostic become prompt True default True
2│Allow world readable tmpfiles True default False
3│Ansible connection path True default None
...output omitted...Type :f forks and then press Enter to filter the configuration settings for the forks pattern.
Name Default Source Current
0│Default forks True default 5Press 0 to inspect the Default forks configuration.
Default forks (current/default: 5) 0│--- 1│current_config_file: /home/student/config-review/ansible.cfg 2│current_value: 5 3│default: true 4│default_value: 5 5│description: Maximum number of forks Ansible will use to execute tasks on tar 6│env: 7│- name: ANSIBLE_FORKS 8│ini: 9│- key: forks10│ section: defaults
11│name: Default forks 12│option: DEFAULT_FORKS 13│source: default 14│type: integer 15│via: default
The | |
The |
Exit from ansible-navigator by pressing ESC twice.
Edit the ~/config-review/ansible.cfg Ansible settings file and change the forks setting to 15.
The following grep command does not display lines that begin with a number sign, blank lines, and lines that begin with a semicolon.
The output of the grep command displays the expected content after you modify the ansible.cfg file:
[student@workstation config-review]$grep -Ev '^#|^$|^;' ansible.cfg[defaults]forks=15inventory = inventory [privilege_escalation] ...output omitted...
To verify the setting, run the ansible-navigator config command with no arguments.
[student@workstation config-review]$ ansible-navigator config
Name Default Source Current
0│Action warnings True default True
1│Agnostic become prompt True default True
2│Allow world readable tmpfiles True default False
3│Ansible connection path True default None
...output omitted...Type :f forks and then press Enter to filter the configuration settings for the forks pattern.
Name Default Source Current 0│Default forksFalse /home/student/config-review/ansible.cfg15
Exit from ansible-navigator by pressing ESC.
Use the ansible-navigator command with the -m stdout and --ask-become-pass options to run the install-web.yml playbook.
When prompted, enter student for the privilege escalation password.
Verify that the playbook runs successfully.
Use the ansible-navigator command with the -m stdout and --ask-become-pass options to run the install-web.yml playbook.
[student@workstation config-review]$ansible-navigator run install-web.yml \>-m stdout --ask-become-passBECOME password:studentPLAY [Install web server] ****************************************************** TASK [Gathering Facts] ********************************************************* ok: [servera.lab.example.com] TASK [Install httpd package] *************************************************** changed: [servera.lab.example.com] PLAY RECAP ********************************************************************* servera.lab.example.com : ok=2 changed=1 unreachable=0 failed=0 ...