RH294 Ch 10: Git, VS Code and ansible-navigator
Ansible code is code: it belongs in version control, and the exam expects you to work that way.
Git essentials.
bash git clone http://utility/git/webasha-infra.git ~/webasha-infra git config --global user.name "Student" git config --global user.email [email protected] git status what changed git add release.yml stage git commit -m "Add release playbook" git push send commits to origin git pull bring others' commits in git log --oneline
A commit without a configured identity fails, so set it first. To publish an existing directory: git init -b main, git remote add origin URL, git push -u origin main. A .gitignore keeps noise such as navigator artifacts or vault password files out of the repository.
VS Code. Open the cloned folder (File → Open Folder). The Ansible extension recognises playbooks, gives completion for module options and shows ansible-lint warnings inline. The Source Control view stages, commits and syncs (push and pull) with buttons, and the integrated terminal runs in the project directory.
ansible-navigator runs playbooks inside an execution environment (EE): a container image with ansible-core, Python libraries and collections, so every machine runs the same content. Configure it per project in ansible-navigator.yml:
yaml ansible-navigator: execution-environment: image: utility.lab.example.com/ee-supported-rhel10:latest pull: policy: never mode: stdout
Then ansible-navigator run release.yml. Without mode: stdout you get the interactive text UI (:0 drills into a play, Esc goes back). Other subcommands: inventory, doc, collections, images, config. Each run saves a <playbook-artifact-<time.json that ansible-navigator replay can open later.
The EE only sees the project directory, so ansible.cfg, inventory, roles and collections must live inside it; your SSH keys are mounted in automatically.
Common exam mistakes - Running navigator from the wrong directory, so it ignores the project's ansible.cfg and ansible-navigator.yml. - pull: policy: always on an offline network — the run fails trying to reach a registry. - Committing but forgetting to push; the grader looks at the server. - Pushing to the wrong branch name (main vs master).