At the end of the previous lesson, every Aurora Store deployment still started with a person typing a command or clicking a button: launching the AWX template, building the execution environment with ansible-builder, remembering to update aurora_app_version in the inventory after using the survey… And nothing automatically checks that a change to aurora-infra doesn't break a playbook's syntax before it reaches main. In this lesson you'll set up the repository's continuous integration and delivery (CI/CD): a pipeline in Gitea Actions (with syntax compatible with GitHub Actions, plus its GitLab CI equivalent) that, on every change, lints the code, checks the syntax, leaves room for tests, builds and publishes aurora-ee when its dependencies change and, when a version tag is created, launches the website release workflow in AWX. Along the way you'll compare the two big models for deploying from CI (running ansible-playbook on the runner or delegating to AWX) and resolve an open issue from Module 7: making sure the deployed version is always recorded in Git.

Contents

  1. CI/CD applied to an Ansible repository
  2. The aurora-infra pipeline
  3. Gitea Actions: enabling the service and registering a runner
  4. First stages: linting and syntax checking
  5. The test stage (reserved for Molecule)
  6. Building and publishing the execution environment from CI
  7. Deploying from CI: ansible-playbook on the runner or AWX
  8. CI talks to AWX: user, token and secrets
  9. Deploying the website by version tag
  10. Environments and approvals
  11. The same pipeline in GitHub Actions and GitLab CI
  12. Best practices for secrets in CI

  1. CI/CD applied to an Ansible repository

  • Continuous integration (CI): every change pushed to the repository is verified automatically (style, syntax, tests). The goal is to detect errors minutes after they're made, not when someone runs the playbook against production.
  • Continuous delivery (CD): verified code is left ready to be deployed with a simple, repeatable step, often with a human approval.
  • Continuous deployment (CD): every verified change is deployed on its own, without intervention.

In an infrastructure-as-code repository, the "product" isn't a binary but changes to servers. That makes CI even more valuable: an indentation error in group_vars can leave the store without a website.

Question Without CI With CI
Does this change break the syntax of any playbook? You find out when you run it You find out when you push it
Does it follow the agreed style? Depends on who reviews it Automatic review, the same for everyone
Which EE does AWX use and who built it? Someone, from their laptop The pipeline, from a specific commit
Which version of the website is deployed? Whichever was chosen in the survey (does it match Git?) The one in the Git tag

  1. The aurora-infra pipeline

flowchart LR
    PUSH[push or pull request] --> LINT[Lint<br/>yamllint + ansible-lint]
    PUSH --> SYN[Syntax<br/>ansible-playbook --syntax-check]
    SYN --> TEST[Tests<br/>Molecule, Lesson 9.5]
    TEST -->|main only| CHECK[AWX: Aurora - Check configuration]
    MAINEE[push to main with changes in ee/ or collections/] --> EE[Build and publish aurora-ee]
    TAG[web-X.Y.Z tag] --> VER[Does the tag match the inventory?]
    VER --> WF[AWX: Aurora - Release web version<br/>with approval]

Three workflow files, each with its own trigger:

File Triggered by Stages
.gitea/workflows/ci.yml Any push and every pull request Lint → syntax → tests → (on main) check in AWX
.gitea/workflows/ee.yml A push to main that changes ee/ or collections/requirements.yml Build, check and publish aurora-ee
.gitea/workflows/web-deploy.yml web-* tags Verify the version and launch the AWX workflow

And one principle guides the whole design: CI doesn't deploy by itself; it asks AWX to do it. AWX already has the credentials, the inventory, the permissions, the approval and the history (Module 7). CI only needs a token to launch templates. You'll see the reasoning in section 7.

  1. Gitea Actions: enabling the service and registering a runner

3.1. Concepts

Gitea Actions is the CI system built into Gitea, compatible with GitHub Actions syntax: workflows are YAML files in .gitea/workflows/ (it also reads .github/workflows/), with on: (triggers), jobs: and steps:. Jobs are run by a runner, act_runner, a separate program that registers with Gitea and picks up jobs according to its labels (runs-on:).

Each runner label says where jobs run:

Mode Example label Steps run…
docker ubuntu-latest:docker://docker.gitea.com/runner-images:ubuntu-latest In a new container per job (isolated, throwaway)
host aurora-runner:host Directly on the runner machine, as its user

For the lab, Aurora chooses a runner in host mode on awx1, with an unprivileged user: it's the simplest option (it doesn't need a container daemon for the jobs) and it allows building the EE with Podman. Each job creates its own Python virtual environment, so the steps are the same as on a throwaway GitHub runner.

Security. In host mode, anyone who can modify a workflow in the repository runs code on awx1 as the runner user. That's acceptable for an internal repository with controlled access; in production, ephemeral runners in containers or VMs are used, and workflows from external forks are never run on runners with access to the internal network.

3.2. Preparing awx1

ssh awx1
# Unprivileged user for the runner, with a persistent session for rootless Podman
sudo useradd --create-home --shell /bin/bash runner
sudo loginctl enable-linger runner
# Tools the jobs need: Python with venv, Git and Node.js (for actions/checkout)
sudo apt-get update && sudo apt-get install -y python3-venv git nodejs
# The lab registry without TLS, for Podman on awx1 too (as on your computer, Lesson 7.6)
sudo tee /etc/containers/registries.conf.d/50-aurora-store.conf >/dev/null <<'EOF'
[[registry]]
location = "registry.aurora-store.example:5000"
insecure = true
EOF

Download act_runner (the version is an example: check the latest one at https://dl.gitea.com/act_runner/) and install it:

curl -fsSLo /tmp/act_runner https://dl.gitea.com/act_runner/0.2.11/act_runner-0.2.11-linux-amd64
sudo install -m 0755 /tmp/act_runner /usr/local/bin/act_runner

3.3. Registering the runner

  1. In Gitea, log in as alex and go to the ops organization → Settings → Actions → Runners → Create new Runner, and copy the registration token. An organization runner serves all its repositories.
  2. In the Settings of the ops/aurora-infra repository, check that the Actions unit is enabled.
  3. Register the runner as the runner user:
sudo -iu runner
act_runner generate-config > config.yaml
act_runner register --no-interactive \
  --instance http://git.aurora-store.example \
  --token 'REGISTRATION_TOKEN' \
  --name awx1-runner \
  --labels aurora-runner:host
exit

Registration creates the .runner file (with the runner's identity) in runner's home directory. Create a systemd service so it starts on its own, /etc/systemd/system/act_runner.service:

[Unit]
Description=Gitea Actions runner (act_runner)
After=network-online.target

[Service]
User=runner
WorkingDirectory=/home/runner
ExecStart=/usr/local/bin/act_runner daemon --config /home/runner/config.yaml
Restart=on-failure

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now act_runner
exit

In Gitea, the awx1-runner runner shows up as Idle with the aurora-runner label. These manual steps on awx1 add to those from Lesson 7.2; automating the services machine with Ansible remains a pending improvement (you'll come back to it in the final project).

  1. First stages: linting and syntax checking

4.1. The CI tools, versioned

So that jobs are reproducible, the Python tools are declared in the repository, in ci/requirements.txt:

# Tools for the aurora-infra continuous integration (Lesson 8.3).
# ansible-core: the same series as the laptop and aurora-ee.
ansible-core>=2.17,<2.18
# Linting (configuration and pinned versions in Lesson 9.4).
yamllint
ansible-lint
# AWX client: the same version as the server (AWX 24.6.1).
awxkit==24.6.1

4.2. The ci.yml workflow

.gitea/workflows/ci.yml:

---
name: aurora-infra CI

on:
  push:
    branches: ["**"]
  pull_request:

jobs:
  lint:
    name: Lint
    runs-on: aurora-runner
    steps:
      - name: Check out the repository
        uses: actions/checkout@v4

      - name: Set up the tools
        run: |
          python3 -m venv .venv
          .venv/bin/pip install --quiet -r ci/requirements.txt

      - name: yamllint
        # Informational until Lesson 9.4, where the rules are agreed.
        continue-on-error: true
        run: .venv/bin/yamllint .

      - name: ansible-lint
        # Informational until Lesson 9.4.
        continue-on-error: true
        run: .venv/bin/ansible-lint

  syntax:
    name: Syntax check
    runs-on: aurora-runner
    steps:
      - name: Check out the repository
        uses: actions/checkout@v4

      - name: Set up the tools and the Ansible dependencies
        run: |
          python3 -m venv .venv
          .venv/bin/pip install --quiet -r ci/requirements.txt
          .venv/bin/ansible-galaxy collection install -r collections/requirements.yml
          .venv/bin/ansible-galaxy role install -r roles/requirements.yml

      - name: Check the playbook syntax
        run: |
          for playbook in site.yml upgrade.yml catalog-image.yml kubernetes.yml; do
            echo "== $playbook"
            .venv/bin/ansible-playbook "$playbook" --syntax-check
          done

  tests:
    name: Tests
    runs-on: aurora-runner
    needs: syntax
    steps:
      - name: Check out the repository
        uses: actions/checkout@v4

      - name: Run the Molecule scenarios of the roles that have them
        run: |
          for role in roles/*/; do
            if [ -d "${role}molecule" ]; then
              echo "== $role"
              (cd "$role" && molecule test)
            fi
          done
          echo "Tests finished"

  lab-check:
    name: AWX check
    runs-on: aurora-runner
    needs: [lint, tests]
    if: github.ref == 'refs/heads/main'
    env:
      TOWER_HOST: ${{ vars.AWX_HOST }}
      TOWER_OAUTH_TOKEN: ${{ secrets.AWX_TOKEN }}
    steps:
      - name: Check out the repository
        uses: actions/checkout@v4

      - name: Set up the AWX client
        run: |
          python3 -m venv .venv
          .venv/bin/pip install --quiet -r ci/requirements.txt

      - name: Launch the check template and wait for the result
        run: .venv/bin/awx job_templates launch "Aurora - Check configuration" --monitor -f human

Explanation, part by part:

  • on: with push to any branch and pull_request: every proposed change is verified before it's merged.
  • runs-on: aurora-runner: the label of the runner on awx1.
  • uses: actions/checkout@v4: the standard action that checks out the repository at the commit that triggered the job. Gitea gets it from its actions mirror; it needs Node.js on the runner (that's why you installed it).
  • Each job creates its own .venv: jobs don't share anything with each other (on a throwaway runner they don't even share a machine), so each one installs what it needs.
  • Lint: yamllint . reviews the YAML of the whole repository and ansible-lint applies the Ansible best-practice rules (FQCN, task names, quoted mode…). For now they're only invoked with continue-on-error: true: their warnings appear in the log, but they don't stop the pipeline. In Lesson 9.4 you'll agree on their configuration, fix the warnings and remove that line.
  • Syntax: ansible-playbook --syntax-check parses the playbooks (and everything they import) without connecting to any host. It needs to find the roles and collections, so they're installed first with ansible-galaxy using the repository's ansible.cfg (galaxy_roles/ and collections/). It doesn't need the Vault password: the syntax check doesn't load host variables.
  • needs: orders the jobs: the tests wait for the syntax check, and the AWX check waits for everything else.
  • if: github.ref == 'refs/heads/main': the AWX check is only launched for the main branch. Gitea fills in the github.* context for compatibility (gitea.* also exists).
  • vars.AWX_HOST and secrets.AWX_TOKEN: a repository variable and secret (section 8).

Add .venv/ to .gitignore (in case someone creates it locally), make a commit and push to a branch:

git switch -c ci-initial
git add ci/ .gitea/ .gitignore
git commit -m "CI: lint, syntax and a placeholder for tests"
git push -u origin ci-initial

In Gitea, in the repository's Actions tab, you'll see the run with its jobs. lint finishes with warnings (flagged, but green), and syntax should pass. Trigger a failure to see it working: break the indentation of a task in webservers.yml, push the change and check that syntax fails with the same message you'd see in your terminal. Undo the error (git revert, or fix it and push).

  1. The test stage (reserved for Molecule)

The tests job goes through the roles in roles/ and runs molecule test in those that have a molecule/ directory. Today none of them has one, so the step finishes without doing anything. In Lesson 9.5 you'll write Molecule scenarios (which, as you saw in Lesson 8.1, create throwaway containers, apply the role, check its idempotency and verify it) and add molecule to ci/requirements.txt: from then on, the pipeline will run them without touching this file.

Why isn't the syntax check enough? Because --syntax-check doesn't detect a misspelled variable, a module with a wrong parameter or a task that isn't idempotent. For that you have to run the code against something: a container (Molecule), a test environment (Lesson 9.1) or, at the very least, the lab in check mode (the lab-check job).

  1. Building and publishing the execution environment from CI

6.1. A new version of aurora-ee

Since Lesson 7.6, collections/requirements.yml has gained community.docker (8.1) and kubernetes.core (8.2). aurora-ee:1.0.0 doesn't have them, so AWX couldn't run apiservers.yml. It's time to publish aurora-ee:1.1.0, and this time CI will do it.

.gitea/workflows/ee.yml:

---
name: aurora-ee execution environment

on:
  push:
    branches: [main]
    paths:
      - "ee/**"
      - "collections/requirements.yml"

jobs:
  build:
    name: Build and publish aurora-ee
    runs-on: aurora-runner
    steps:
      - name: Check out the repository
        uses: actions/checkout@v4

      - name: Read the image tag
        id: image
        run: |
          tag=$(grep -A1 '^  tags:' ee/execution-environment.yml | tail -n1 | sed 's/^ *- *//')
          echo "tag=$tag" >> "$GITHUB_OUTPUT"
          echo "Image: $tag"

      - name: Refuse to overwrite a published tag
        run: |
          version="${{ steps.image.outputs.tag }}"
          version="${version##*:}"
          if curl -fsS http://registry.aurora-store.example:5000/v2/aurora/aurora-ee/tags/list \
               | grep -q "\"$version\""; then
            echo "Version $version is already published: change options.tags in ee/execution-environment.yml"
            exit 1
          fi

      - name: Build the image
        run: |
          python3 -m venv .venv
          .venv/bin/pip install --quiet ansible-builder
          .venv/bin/ansible-builder build -f ee/execution-environment.yml -c ee/context --container-runtime podman

      - name: Check the image contents
        run: |
          podman run --rm "${{ steps.image.outputs.tag }}" ansible --version
          podman run --rm "${{ steps.image.outputs.tag }}" ansible-galaxy collection list

      - name: Publish the image
        run: podman push "${{ steps.image.outputs.tag }}"

What's new:

  • paths: narrows the trigger: the workflow only runs if the push to main changes the EE or the collections. Changing a motd doesn't rebuild anything.
  • Outputs between steps (id: + $GITHUB_OUTPUT + steps.image.outputs.tag): the first step reads the tag from options.tags in the definition file, which is still the single source of truth for the version.
  • Immutable tags, now enforced: if the version is already in the registry, the job fails instead of overwriting it (the rule you agreed on in Lesson 7.6).
  • A check before publishing: if the image doesn't have Ansible or is missing collections, it never reaches the registry.

6.2. Publishing aurora-ee:1.1.0

On a branch, change options.tags in ee/execution-environment.yml to registry.aurora-store.example:5000/aurora/aurora-ee:1.1.0 and image: in ansible-navigator.yml to the same tag. Merge the ci-initial branch and this one into main (through pull requests in Gitea, watching ci.yml verify them). The push to main triggers ee.yml, which builds and publishes the image.

Then, in AWX (as alex): create the aurora-ee 1.1.0 EE with the new image and set it as the default EE of the Aurora Store organization, keeping aurora-ee 1.0.0 for a few days so you can roll back (the same procedure as in Exercise 3 of Lesson 7.6). The same push to main has also launched Aurora - Check configuration… with the previous image, because the change in AWX comes afterwards: a good example of why the order of the steps matters.

What about the catalog API image? Its natural place is the CI of its own repository, ops/aurora-catalog: a workflow that, when a 1.1.0 tag is created, builds and publishes catalog:1.1.0. That way, catalog-image.yml (Lesson 8.1) remains a lab tool and the aurora-infra pipeline only changes the deployed version. You'll do it in Exercise 2.

  1. Deploying from CI: ansible-playbook on the runner or AWX

There are two ways for a pipeline to deploy with Ansible.

7.1. Model A: the runner runs ansible-playbook

The runner installs Ansible, receives the SSH key and the Vault password as secrets, and runs the playbook directly. A typical job (illustrative, not adopted by Aurora):

  deploy:
    runs-on: aurora-runner
    steps:
      - uses: actions/checkout@v4
      - name: Set up Ansible and dependencies
        run: |
          python3 -m venv .venv
          .venv/bin/pip install --quiet -r ci/requirements.txt
          .venv/bin/ansible-galaxy collection install -r collections/requirements.yml
          .venv/bin/ansible-galaxy role install -r roles/requirements.yml
      - name: Write the secrets to temporary files
        env:
          SSH_KEY: ${{ secrets.AURORA_SSH_KEY }}
          VAULT_PASS: ${{ secrets.AURORA_VAULT_LAB }}
          KNOWN_HOSTS: ${{ secrets.AURORA_KNOWN_HOSTS }}
        run: |
          umask 077
          mkdir -p "$RUNNER_TEMP/aurora"
          printf '%s\n' "$SSH_KEY" > "$RUNNER_TEMP/aurora/id"
          printf '%s' "$VAULT_PASS" > "$RUNNER_TEMP/aurora/vault.pass"
          printf '%s\n' "$KNOWN_HOSTS" > "$RUNNER_TEMP/aurora/known_hosts"
      - name: Run the playbook
        env:
          ANSIBLE_PRIVATE_KEY_FILE: ${{ runner.temp }}/aurora/id
          ANSIBLE_VAULT_IDENTITY_LIST: lab@${{ runner.temp }}/aurora/vault.pass
          ANSIBLE_SSH_ARGS: -o UserKnownHostsFile=${{ runner.temp }}/aurora/known_hosts
        run: .venv/bin/ansible-playbook webservers.yml --tags deploy
      - name: Delete the secrets
        if: always()
        run: rm -rf "$RUNNER_TEMP/aurora"

Notice the precautions: umask 077 so the files are created with 0600 permissions; the Vault password passed through ANSIBLE_VAULT_IDENTITY_LIST (as in your ~/.bashrc); the SSH fingerprints as a secret instead of disabling the check; and a final step with if: always() that deletes the secrets even if the deployment fails.

7.2. Model B: CI launches AWX templates or workflows

CI only has an AWX token with permission to execute certain templates. AWX does the rest with its own credentials.

Aspect A: ansible-playbook on the runner B: launching AWX from CI
Secrets in CI SSH key, Vault password, fingerprints Just an AWX token
Who can deploy what Whoever can modify the pipeline AWX RBAC (Lesson 7.5)
Approvals Those of the CI system (if it has them) The approval node of the AWX workflow
History and auditing CI logs (they expire) AWX job history, just like jobs launched by hand
Execution environment Whatever the job installs aurora-ee, the usual one
Network The runner must reach all servers over SSH Only AWX reaches the servers
Dependencies No extra platform Needs AWX/AAP
Suitable for Small projects, without a platform Organizations with AWX/AAP

Aurora adopts model B: it has AWX, and duplicating the SSH key and the Vault password in CI would widen the attack surface and bypass the permissions and the approval you configured in Lesson 7.5. CI decides when; AWX decides how and who.

7.3. Three ways to launch AWX

Tool Example When
awx CLI (awxkit) awx job_templates launch "Aurora - Check configuration" --monitor Simple shell steps (the one Aurora uses)
awx.awx collection awx.awx.job_launch and awx.awx.workflow_launch modules in a playbook If CI already runs playbooks or you want logic beforehand
REST API curl -H "Authorization: Bearer $TOKEN" -X POST $AWX/api/v2/job_templates/<id>/launch/ With no tools installed

With the awx.awx collection (its version must match AWX's, here 24.6.1), the launch would be:

- name: Launch the website release workflow
  hosts: localhost
  gather_facts: false
  tasks:
    - name: Launch the workflow with the given version
      awx.awx.workflow_launch:
        name: Aurora - Release web version
        organization: Aurora Store
        extra_vars:
          aurora_app_version: "{{ version }}"
        wait: false
      # controller_host and controller_oauthtoken are read from CONTROLLER_HOST and CONTROLLER_OAUTH_TOKEN

Aurora doesn't add it to its requirements: the CLI is enough and doesn't require yet another collection.

  1. CI talks to AWX: user, token and secrets

Applying the least privilege from Lesson 7.5:

  1. In AWX, as alex, create the gitea-ci user (type Normal, organization Aurora Store, a long generated password stored in the password manager).
  2. Give it only the Execute role on Aurora - Check configuration and on the Aurora - Release web version workflow. Do not give it Approve: approval is still a person's job (marc).
  3. Log in as gitea-ci → User Details → Tokens → Create token, with Write scope (launching is writing) and no application (personal token). Copy the token: AWX won't show it again.
  4. In Gitea, ops/aurora-infra repository → Settings → Actions:
    • Secrets: AWX_TOKEN = the token.
    • Variables: AWX_HOST = http://192.168.56.30:30080.

Gitea secrets are stored encrypted, aren't shown after they're created and are masked in the logs (they appear as ***). Variables are for non-secret data. With this, the lab-check job in ci.yml works: on main, every change ends with a check of the whole lab in check mode, visible in the AWX history as launched by gitea-ci.

  1. Deploying the website by version tag

9.1. The open issue from Module 7

In Module 7 you agreed on a rule: the deployed version must end up in the repository. But the flow was "first deploy with the survey and then someone updates aurora_app_version and makes a commit". If that second step is forgotten, the inventory and reality diverge, and the next run of site.yml would take the website back to the previous version.

With CI you'll reverse the order: Git first, then the deployment.

Module 7 (survey) Module 8 (tag)
Where the version is decided In the AWX survey In a reviewed commit of inventory/group_vars/webservers.yml
What triggers the deployment A person launches the workflow Creating the web-X.Y.Z tag
Record in Git Afterwards, by hand (easy to forget) Beforehand; CI checks that they match
Approval Approval node (marc) The same approval node

9.2. The web-deploy.yml workflow

.gitea/workflows/web-deploy.yml:

---
name: Web deployment

on:
  push:
    tags:
      - "web-*"

jobs:
  publish:
    name: Release the tag's version
    runs-on: aurora-runner
    env:
      TOWER_HOST: ${{ vars.AWX_HOST }}
      TOWER_OAUTH_TOKEN: ${{ secrets.AWX_TOKEN }}
    steps:
      - name: Check out the repository with its history
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Extract the version from the tag
        id: version
        run: |
          version="${GITHUB_REF_NAME#web-}"
          if ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
            echo "Invalid tag: $GITHUB_REF_NAME (format: web-X.Y.Z)"
            exit 1
          fi
          echo "version=$version" >> "$GITHUB_OUTPUT"

      - name: Check that the tag is on main
        run: |
          git fetch origin main
          git merge-base --is-ancestor "$GITHUB_SHA" origin/main \
            || { echo "The tag doesn't point to a commit on main"; exit 1; }

      - name: Check that the inventory declares that version
        run: |
          declared=$(grep -E '^aurora_app_version:' inventory/group_vars/webservers.yml | sed -E 's/.*"(.*)".*/\1/')
          if [ "$declared" != "${{ steps.version.outputs.version }}" ]; then
            echo "The inventory declares $declared and the tag is ${{ steps.version.outputs.version }}"
            exit 1
          fi

      - name: Set up the AWX client
        run: |
          python3 -m venv .venv
          .venv/bin/pip install --quiet -r ci/requirements.txt

      - name: Launch the release workflow in AWX
        run: |
          .venv/bin/awx workflow_job_templates launch "Aurora - Release web version" \
            --extra_vars "{\"aurora_app_version\": \"${{ steps.version.outputs.version }}\"}" \
            -f human
          echo "Workflow launched: pending approval in AWX (${TOWER_HOST})"

Step by step:

  • on.push.tags: ["web-*"]: only tags with that prefix. aurora-infra tags without the prefix remain free for other uses.
  • GITHUB_REF_NAME is the tag name (web-1.4.0); ${GITHUB_REF_NAME#web-} strips the prefix. The regular expression rejects malformed tags.
  • fetch-depth: 0 fetches the full history, needed for git merge-base --is-ancestor, which checks that the tagged commit is already on main (nobody deploys from an unreviewed branch).
  • The key check: the tag's version must be exactly the aurora_app_version in that commit's inventory. If they don't match, nothing is deployed.
  • Launching without --monitor: the AWX workflow has an approval node with a 4-hour timeout; waiting from CI would tie up the runner all that time. CI launches and finishes; the follow-up happens in AWX. (For templates without approval, like the check in ci.yml, --monitor is used, and the CI job fails if the AWX job fails.)
  • The workflow's survey receives its answer through --extra_vars, as if someone had filled it in.

9.3. Releasing version 1.4.0

The website release procedure now looks like this:

git switch -c web-1.4.0
# inventory/group_vars/webservers.yml -> aurora_app_version: "1.4.0"
git commit -am "Website version 1.4.0"
git push -u origin web-1.4.0
# Pull request in Gitea -> green CI -> review -> merge into main
git switch main && git pull
git tag -a web-1.4.0 -m "Web 1.4.0"
git push origin web-1.4.0

When the tag is pushed, web-deploy.yml verifies and launches the workflow: project sync → check (check mode, which now shows the version change as an expected difference) → marc's approval → rolling deployment with serial: 1 and the load balancer. Check the result with curl -s http://192.168.56.10/ | grep Version (it should say 1.4.0), and in AWX you'll see the job launched by gitea-ci and approved by marc.

Two consequences of the new order you should be aware of:

  • Between the merge into main and the approval, main declares a version that isn't deployed yet. If someone launched the full Aurora - Configure infrastructure in that window, it would deploy 1.4.0 without going through the approval. Aurora's rule: tag immediately after merging a version change, and don't launch the full configuration while a release is pending. (The nightly check isn't a problem: it runs in check mode.)
  • The workflow's survey still exists for emergencies, but a deployment launched by hand with a version different from the one on main creates drift again. From now on, the normal path is the tag.

Change the survey's default value to 1.4.0 and commit whatever is left ("CI: web deployment via web-X.Y.Z tag through AWX").

  1. Environments and approvals

Modern CI systems let you define environments (staging, production) with their own secrets, protection rules and approvals:

Platform Environments Manual approval
GitHub Actions environment: on the job, with per-environment secrets Required reviewers on the environment
GitLab CI environment: with deployment history when: manual on the job; approvals for protected environments in the paid tiers
Gitea Actions No protected environments or required reviewers (in the lab version) Not built in: protected branches and external approvals are used
AWX Per-environment inventories and templates Workflow approval node with RBAC (Approve)

Aurora concentrates approval in AWX: it's independent of the CI tool and stays in the same history as the deployment. In Gitea, round out the protection with protected branches: in ops/aurora-infra → Settings → Branches, protect main so it can only be merged through a pull request with green CI and an approved review, and restrict who can create web-* tags (Settings → Tags, protected tags).

Today Aurora only has the lab, and the workflow's check node acts as "staging". In Lesson 9.1, with inventories separated by environment, the pipeline will be able to deploy to staging automatically and leave production behind the approval.

  1. The same pipeline in GitHub Actions and GitLab CI

11.1. GitHub Actions

The syntax is the same; the platform details change:

Item Gitea (lab) GitHub
Location .gitea/workflows/ (or .github/workflows/) .github/workflows/
Machine runs-on: aurora-runner (host on awx1) runs-on: ubuntu-latest (ephemeral) or a self-hosted runner
Python The system one + venv actions/setup-python@v5
Context github.* and gitea.* github.*
Network The runner is on the lab network Hosted runners can't reach a private network: AWX must be reachable or a self-hosted runner is used

A syntax job for GitHub:

  syntax:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: pip install -r ci/requirements.txt
      - run: |
          ansible-galaxy collection install -r collections/requirements.yml
          ansible-galaxy role install -r roles/requirements.yml
      - run: ansible-playbook site.yml --syntax-check

11.2. GitLab CI

In GitLab, the whole pipeline goes into a single .gitlab-ci.yml with stages (stages) and rules (rules) instead of several workflows:

stages: [lint, syntax, tests, ee, deploy]

default:
  image: python:3.12
  before_script:
    - pip install --quiet -r ci/requirements.txt

lint:
  stage: lint
  script:
    - yamllint .
    - ansible-lint
  allow_failure: true            # informational until Lesson 9.4

syntax:
  stage: syntax
  script:
    - ansible-galaxy collection install -r collections/requirements.yml
    - ansible-galaxy role install -r roles/requirements.yml
    - ansible-playbook site.yml --syntax-check

lab-check:
  stage: deploy
  rules:
    - if: $CI_COMMIT_BRANCH == "main"
  variables:
    TOWER_HOST: $AWX_HOST          # project CI/CD variables (AWX_TOKEN masked and protected)
    TOWER_OAUTH_TOKEN: $AWX_TOKEN
  script:
    - awx job_templates launch "Aurora - Check configuration" --monitor -f human

deploy-web:
  stage: deploy
  rules:
    - if: $CI_COMMIT_TAG =~ /^web-\d+\.\d+\.\d+$/
  environment: lab
  variables:
    TOWER_HOST: $AWX_HOST
    TOWER_OAUTH_TOKEN: $AWX_TOKEN
  script:
    - VERSION="${CI_COMMIT_TAG#web-}"
    - grep -q "^aurora_app_version: \"$VERSION\"" inventory/group_vars/webservers.yml
    - awx workflow_job_templates launch "Aurora - Release web version" --extra_vars "{\"aurora_app_version\": \"$VERSION\"}"

Main equivalences: needs/job order → stages; if: → rules:; continue-on-error → allow_failure; repository secrets → masked and protected CI/CD variables (only available on protected branches and tags); the EE build would go in the ee stage with rules: changes: on ee/** and a runner with Podman or Docker.

  1. Best practices for secrets in CI

  • The fewer secrets, the better: model B leaves a single AWX token in CI, with execute permissions on two specific templates.
  • Least privilege and expiry: per-tool service tokens (gitea-ci), never a person's or admin's; rotate them periodically and revoke them if a leak is suspected.
  • Never in the repository or in the workflow: always in the platform's secret store. A secret in a commit stays in the history even if you delete it (Lesson 6.4).
  • Don't print them: CI masking is a safety net, not a guarantee (a base64-encoded or split secret isn't masked). Avoid set -x and -vvv in steps with secrets; in Ansible, no_log: true.
  • Temporary files with umask 077 and deletion with if: always() (or after_script in GitLab).
  • Secrets only on protected branches: a pull request from an arbitrary branch shouldn't be able to read them (by default, Gitea and GitHub don't pass them to pull requests from forks).
  • Verified SSH fingerprints: if CI connects over SSH, pass known_hosts as a secret; don't disable host_key_checking.
  • Professional review: the design of secrets and permissions for a real CI/CD platform should be reviewed by a security specialist (Lesson 9.2).

Common Mistakes and Tips

  • The job stays in "Waiting" forever: no runner has the runs-on label, or the runner is stopped (sudo systemctl status act_runner on awx1).
  • actions/checkout fails with a Node.js error: nodejs is missing on the runner in host mode.
  • ERROR! the role 'nginx' was not found in the syntax check: the roles from roles/requirements.yml weren't installed, or the step ran outside the repository root (and its ansible.cfg wasn't used).
  • awx: 401 Unauthorized: expired, revoked or wrongly copied token; or TOWER_HOST without http://.
  • awx: 403 Forbidden when launching: the gitea-ci user doesn't have Execute on that template.
  • The tag workflow doesn't trigger: you pushed the branch but not the tag (git push origin web-1.4.0), or the tag doesn't start with web-.
  • podman push fails with "http: server gave HTTP response to HTTPS client": the insecure registry configuration is missing on awx1.
  • Tip: test pipeline changes on a branch; the main and tag workflows are the ones that deploy.

Exercises

Exercise 1: mandatory lint for the new files

Until Lesson 9.4 arrives, the team wants yamllint to be mandatory at least for the files in .gitea/workflows/. Modify the lint job to achieve this without removing the informational nature of the rest.

Exercise 2: CI for the catalog API repository

Write .gitea/workflows/image.yml for the ops/aurora-catalog repository so that, when an X.Y.Z tag is pushed, it builds the registry.aurora-store.example:5000/aurora/catalog:X.Y.Z image with Podman (passing the version as a build argument), checks that it responds on /health and publishes it.

Exercise 3: troubleshooting

When the web-1.5.0 tag is pushed, the job fails with "The inventory declares 1.4.0 and the tag is 1.5.0". What has probably happened and how do you fix it without leaving misleading tags in the repository?

Solutions

Exercise 1. Add a step without continue-on-error before the informational ones:

      - name: yamllint of the workflows (mandatory)
        run: .venv/bin/yamllint .gitea/workflows/

If a workflow has a style error, the lint job fails, and with it lab-check, which has it in needs. The rest of the repository is still reviewed in informational mode.

Exercise 2.

---
name: Catalog API image

on:
  push:
    tags:
      - "[0-9]+.[0-9]+.[0-9]+"

jobs:
  image:
    runs-on: aurora-runner
    env:
      IMAGE: registry.aurora-store.example:5000/aurora/catalog:${{ github.ref_name }}
    steps:
      - uses: actions/checkout@v4

      - name: Build
        run: podman build --pull --build-arg AURORA_CATALOG_VERSION=${{ github.ref_name }} -t "$IMAGE" .

      - name: Test
        run: |
          podman run -d --rm --name catalog-test -p 18080:8080 "$IMAGE"
          sleep 3
          curl -fsS http://localhost:18080/health | grep -q '"version": "${{ github.ref_name }}"'

      - name: Stop the test
        if: always()
        run: podman rm -f catalog-test || true

      - name: Publish
        run: podman push "$IMAGE"

The Gitea/GitHub tag pattern is a glob (not a regular expression), which is why it's written as [0-9]+.[0-9]+.[0-9]+. The test starts the freshly built image on a free port and checks that it reports the right version before publishing it. After that, deploying it is a matter of changing aurora_catalog_version (or aurora_catalog_k8s_version) in aurora-infra.

Exercise 3. The tag was created on a main commit where the version change hadn't been merged yet (for example, it was tagged before the pull request was accepted, or on an out-of-date local main). CI has done its job: it hasn't deployed anything. Fix: delete the tag locally and in Gitea (git tag -d web-1.5.0 and git push origin :refs/tags/web-1.5.0), merge the pull request with aurora_app_version: "1.5.0", update main (git pull) and create and push the tag again. Deleting a published tag is only acceptable because it never deployed anything; a tag that did get deployed is never moved.

Conclusion

aurora-infra now has continuous integration and delivery. With Gitea Actions and an act_runner runner in host mode on awx1, every change goes through linting (informational for now, until Lesson 9.4), a syntax check of all the playbooks and a test stage ready for Molecule (Lesson 9.5); on main, it ends with a check of the whole lab in AWX. The execution environment is built and published by the pipeline (aurora-ee:1.1.0, with community.docker and kubernetes.core), which refuses to overwrite tags. You've compared the two models for deploying from CI, and Aurora has chosen to have CI launch AWX with a least-privilege token, instead of handing out SSH keys and Vault passwords. And the open issue from Module 7 is resolved: the website version is decided in a reviewed commit and released with a web-X.Y.Z tag that CI validates before launching the workflow with approval. You also know how everything translates to GitHub Actions and GitLab CI. So far, however, everything has run on the lab machines you created with Vagrant. In the next lesson, Ansible in Cloud Environments, Aurora makes the jump to the cloud: you'll use Ansible to provision the network, security groups and instances of a staging environment on AWS, and configure them in the same playbook.

Ansible Course: From Beginner to Advanced

Module 1: Introduction to Ansible

Module 2: Ansible Fundamentals

Module 3: Playbooks

Module 4: Roles

Module 5: Advanced Playbook Techniques

Module 6: Ansible Galaxy

Module 7: Ansible Tower, AWX and Automation Platform

Module 8: Ansible for DevOps

Module 9: Ansible Best Practices

Module 10: Advanced Ansible Topics

Module 11: Final Project

© Copyright 2026. All rights reserved