Manage the RWS Ansible Execution Environment

This guide provides step-by-step instructions on how to manage the RWS Ansible Execution Environment, ensuring compatibility with the latest Python and Ansible versions, along with the required Ansible collections.

Projects: c2platform/rws/ansible-execution-environment, c2platform/c2/docker/gitlab-runner


The RWS Ansible Execution Environment is constructed via ansible-builder within the c2platform/rws/ansible-execution-environment project, utilizing a GitLab CI/CD pipeline that operates in Docker containers. This process results in a Docker image that serves as the EE. The custom GitLab Runner image required for this process is derived from the c2platform/c2/docker/gitlab-runner project. For additional details on this approach, please refer to the Docker-in-docker ( dind ) how-to guide.


Prerequisites

  • Ensure your RWS Development Environment is set up on Ubuntu 22, as detailed here.
  • Install Podman  , a container management tool.

Inspecting the Execution Environment

To explore the contents of the EE, start by setting environment variables for convenience:

export IMAGE_NAME="registry.gitlab.com/c2platform/rws/ansible-execution-environment"
export IMAGE_VERSION="0.1.7"
export IMAGE="$IMAGE_NAME:$IMAGE_VERSION"

Then, execute the following commands to list all included Ansible collections and Python/PIP packages:

podman run $IMAGE ansible-galaxy collection list
podman run $IMAGE pip3 list installed

The output will display the available collections and installed packages.

Show me

θ85° [:ansible-gis]└2 master(+39/-10)* ± podman run $IMAGE ansible-galaxy collection list

# /usr/share/ansible/collections/ansible_collections
Collection            Version
--------------------- -------
ansible.posix         1.5.4
ansible.windows       1.14.0
awx.awx               22.4.0
c2platform.core       1.0.8
c2platform.gis        1.0.4
c2platform.mgmt       1.0.2
c2platform.wincore    1.0.5
checkmk.general       3.0.0
chocolatey.chocolatey 1.5.1
community.crypto      2.17.1
community.general     8.3.0
community.postgresql  2.4.3
community.windows     2.0.0
θ65° [:ansible-execution-environment]└2 master(+18/-2)* ± podman run $IMAGE pip3 list installed | grep ansible
ansible-compat            4.1.11
ansible-core              2.15.0
ansible-lint              6.17.2
ansible-runner            2.3.4

[notice] A new release of pip available: 22.3.1 -> 24.0
[notice] To update, run: pip install --upgrade pip

Updating the Execution Environment

To update the EE, you can either clone the c2platform/rws/ansible-execution-environment project or edit it directly using the GitLab Web IDE. Consider modifying the following files:

  • Update the Ansible version, Python, and PIP packages in execution-environment.yml.
  • Refresh Ansible collections in requirements.yml.
  • Amend OS system dependencies in indep.txt.

Submitting and pushing your modifications will trigger the GitLab CI/CD pipeline to release a new latest version of the EE.

Local Build, Inspection, and Testing

For local development, you can use ansible-builder, ansible-navigator, and podman to construct and validate the EE. This is a recommended practice before committing changes:

rws  # Activate the RWS virtual environment
cd ../ansible-execution-environment/
ansible-builder build --tag $IMAGE

Show me

θ62° [:ansible-execution-environment]└2 master(+18/-2)* ± ansible-builder build --tag $IMAGE
Running command:
  podman build -f context/Containerfile -t registry.gitlab.com/c2platform/rws/ansible-execution-environment:0.1.7 context
Complete! The build context can be found at: /home/ostraaten/git/gitlab/c2/ansible-execution-environment/context

Inspect and test the EE similarly to the initial inspection step.

podman run $IMAGE ansible-galaxy collection list
podman run $IMAGE pip3 list installed

To test the EE, use:

ansible-navigator run test_localhost.yml --eei $IMAGE --mode stdout

This command will execute a test playbook and display the output.

Show me

θ65° [:ansible-execution-environment]└2 master ± ansible-navigator run test_localhost.yml --eei $IMAGE --mode stdout
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'

PLAY [Gather and print local Ansible / Python facts] ***************************

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [Print Ansible version] ***************************************************
ok: [localhost] => {
    "ansible_version": {
        "full": "2.15.0",
        "major": 2,
        "minor": 15,
        "revision": 0,
        "string": "2.15.0"
    }
}

TASK [Print Ansible Python] ****************************************************
ok: [localhost] => {
    "ansible_playbook_python": "/usr/bin/python3"
}

TASK [Print Ansible Python version] ********************************************
ok: [localhost] => {
    "ansible_python_version": "3.11.7"
}

PLAY RECAP *********************************************************************
localhost                  : ok=4    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Releasing a New Version

To release an updated version of the EE:

  1. Amend the CHANGELOG.md to reflect the latest changes.
  2. Commit and push these changes. This action will prompt the CI/CD pipeline to publish a new latest version of the image.
  3. After the pipeline concludes, manually initiate the Create release step via the GitLab web interface.

Additional Resources



Last modified November 14, 2024: guideline tags en fme flow tags RWS-353 (ed0ed3f)