← RHCE in Ansible: automation and operations
04 / 23 · 110 MIN

Git, dev containers, and rehearsals

Connect code review to the artifact and environment actually executed.

Concept and mechanism

A repository identifies playbook origin, but Git being present does not guarantee the commit contains the intended fix. Git add stages content at that moment. A later file edit does not automatically enter a plain commit without staging again.

Review differences between working tree, index, and commit before publishing. If push is rejected as non-fast-forward, inspect and integrate remote changes through the team process, resolve conflicts, and validate the result. Forcing replacement of shared history is not the automatic correction for that message.

The pipeline should identify its commit so diagnosis compares the same artifact.

Guided application

VS Code and development containers help repeat tools and dependencies but require consistent runtime configuration. If the extension expects Docker while the environment uses Podman, confirm documented configuration instead of changing a production playbook to solve an editor problem.

Lint and syntax checks detect useful defect classes without demonstrating remote access or functional outcomes. Check mode has limits too: a command task without creates or removes can be skipped, leaving a path unrehearsed. In a fictional RUN handover, ask another colleague to execute the same commit and environment.

Retain results, simulation limits, and functional checks. Remove sensitive debug output before sharing artifacts, even when values came from Vault.

Separate file, index and commit

In the original lab, the initial commit contains batch_window=120. The author changes it to 90, runs git add, then writes 60 without staging again. Three states now exist: HEAD 120, index 90 and working tree 60.

A plain commit records 90. To review what will be recorded, compare the index with HEAD using git diff --cached; to inspect edits still awaiting staging, use git diff. MM in status summarizes both differences.

Before promoting a correction, inspecting the editor is insufficient: confirm the staged snapshot. To remove the change from the next commit while retaining the edit, git restore --staged acts on the index. Adding --worktree would also replace the file and change the intended operation.

Retrieve revisions without confusing refs

The second clone receives 90 because 60 has not been published. After the author publishes 80, fetch updates origin/main but leaves the second clone HEAD and file at 90. This separation allows inspection before integration. origin/main is a local ref to observed state rather than a continuous remote read.

Record fetch time and used identifiers. A branch can advance; the exercise approved-90 tag retains the approved commit while main evolves. To reproduce delivery, confirm the commit identifier associated with its manifest.

If you work in detached HEAD and create a commit you want to retain, create a branch at that revision before changing context.

Resolve a conflict with operational intent

Starting from 90, one clone publishes 80 and the other commits 60. The second push is rejected. Fetch reveals divergence but does not decide the correct window.

The lab merge produces a conflict and three index entries for the path. The author chooses 70 as a fictional agreed value, removes markers and stages before completing. The new commit has two parents, preserving both lines of work.

Approval of 70 is a teaching decision rather than an automatic Git conclusion. In a real project, compare resolution with requirements and repeat tests on combined content. Parent tests do not prove the combination works.

Force-with-lease checks a ref condition; it does not automatically integrate remote work.

Code reversion and service recovery

The lab then publishes an incorrect value of 5. Git revert creates another commit returning to 70; the 5 commit remains reachable in history. Retaining it explains the error and correction without silently replacing the past.

Do not confuse file reversion with operational recovery. If a playbook already applied changes, remote effects need assessment and some may be irreversible. The return plan should describe affected data, authorized compensation and service checks.

Successful push confirms source publication without establishing that a service responds again. This exercise executed no Ansible and changed no servers: observed values belong to files in synthetic local repositories.

Tracked content, ignore and historical exposure

A file named credentials.example.yml contains only DEMO_NOT_A_SECRET. After it is tracked, adding it to .gitignore does not hide its edits. The exercise removes it from the index using rm --cached and commits: the local copy remains, the new snapshot omits the path and earlier history still returns the example.

Ignore now applies to the untracked file. This mechanism neither revokes a credential nor removes earlier copies. Sensitive content would require separate exposure handling through the applicable process.

The removed example does not appear in a fresh clone, but that also does not establish historical cleanup. The lab never uses real secrets.

Reproducible rehearsal and RUN handover

Two Git 2.56.0 runs passed 31 checks each with 77 invocations per run. The runner creates a new destination, a local bare remote and three clones; it accesses no network and does not use the application repository. It retains logs, script hash, values and commit identifiers.

The final clone shows 70 on main and 90 when selecting the approved tag. For RUN handover, provide the revision identifier, local modification state, inventory of used files and environment dependencies. A coherent clone still requires collections, node access and functional criteria.

Git diff --check helps with whitespace and conflict markers but does not validate YAML semantics, remote authorization or Ansible outcomes. Repeat the runner only in a new lab directory.

LAB RESULTS
HEAD=120; index=90; working tree=60
Plain commit ->90; local edit stays 60
Fetch: origin/main=80; HEAD stays 90
Conflict:80 vs 60; fictional resolution=70
Published error=5; revert creates a new 70 commit
Tag approved-90 retains 90

Inspect: git status --porcelain
git diff; git diff --cached
git show HEAD:group_vars.yml
git ls-files --unmerged
IN PRACTICE

The editor shows the fix, but the pipeline commit still contains the version staged before it.

Common pitfalls

Saved file as commit; lint as functional rehearsal; clean check as complete proof.

Related topics: State and repeatability · Inventories, variables, and configuration · Access and execution environment

Take this idea with you

Connect the approved revision with actually executed content while distinguishing Git integration from operational outcomes.

Create account

References

Red Hat®, RHCE and Ansible are trademarks or registered trademarks of Red Hat, Inc. bigsavant.com is an independent preparation platform and is not affiliated with, associated with, sponsored, authorised or endorsed by Red Hat. Content and questions are original, are not official exam questions, and completing our tests does not award or guarantee any certification. Names are used only to identify the subject. All other trademarks belong to their respective owners.