RH294 Ch 1: Ansible, ansible.cfg and ansible-navigator

Ansible is agentless: the control node connects to each managed node over SSH, copies a small Python module across, runs it and reads back a JSON result. Nothing needs to be installed on the nodes except Python and an account you can log in to. Because modules compare the current state with the state you asked for, a second run changes nothing. That property, idempotence, is what makes automation safe to repeat.

ansible.cfg. Ansible reads the first config file it finds: $ANSIBLECONFIG, then ./ansible.cfg in the current directory, then ~/.ansible.cfg, then /etc/ansible/ansible.cfg. That is why you always work from the project directory.

ini [defaults] inventory = ./inventory remoteuser = devops

[privilegeescalation] become = true becomemethod = sudo becomeuser = root becomeaskpass = false

ansible --version shows which file is in use, and ansible-config dump --only-changed lists only what you changed.

ansible-navigator runs Ansible inside an execution environment (EE): a container image holding ansible-core, Python libraries and collections. Everyone on the team gets the same tool set. Its settings file is ansible-navigator.yml in the project:

yaml --- ansible-navigator: execution-environment: image: utility.lab.example.com/ee-supported-rhel10:latest pull: policy: never mode: stdout

policy: never uses the image already in local podman storage (the exam has no registry access to pull again), and mode: stdout prints plain output like ansible-playbook instead of the interactive text UI.

Ad-hoc commands run a single module without a playbook: ansible all -m ping, ansible dev -m user -a name=automation, ansible all -m copy -a 'content="hi\n" dest=/etc/motd'. They are useful for checks and one-off fixes.

Looking things up. In the exam you have no internet access, so learn to use the built-in documentation: - ansible-navigator doc -l lists every module in the EE; ansible-navigator doc ansible.posix.firewalld shows options and examples (scroll to EXAMPLES). - ansible-navigator collections lists the collections and their versions. - ansible-doc does the same for content installed on the control node itself.

Common mistakes - Running commands from your home directory, so ~/ansible/ansible.cfg is ignored. - Wrong YAML nesting in ansible-navigator.yml: mode belongs directly under ansible-navigator:, not under execution-environment. - Forgetting pull: policy: never, so navigator tries to reach a registry and fails. - Using short module names that are ambiguous; prefer FQCNs such as ansible.builtin.copy.