Workshop Exercise 3.1 - Ansible Controller as Code

Table of Contents

Objective

Step 1 - Ansible Controller as Code Idea

Within Ansible Controller, various configurations are made to enable the running of automation, things such as projects, credentials, inventories, job templates, and more.

While these configurations can be made using the WebUI, they also can be managed using the API of controller. For example, when browsing the API, the credential endpoint looks like such:

Controller Credentials List

In addition, the API can be asked for options that can be used when interacting with it for various configuration items:

Controller Credentials Options

This allows for the entire configuration of Controller to be defined as code, and programatically applied to Controller - which is a best practice for running Controller at scale, in production.

Step 2 - The ansible.controller Collection

Instead of crafting json payloads and using curl to interact with the controller API, Ansible engine itself can be used to interact with Controller’s API, and allows for resources to be defined in a more straightforward format: as simple variables.

To facilitate this, an ansible collection, ansible.controller, can be leveraged with Ansible engine. Ansible.Controller Collection

This collection provides modules that correspond to the various components of Controller to configure: Ansible.Controller Modules

Step 3 - Using an Overlay Collection

While the ansible.controller collection provides a more simplified mechanism for interacting with Controller, various “overlay” collections exist that further simplify how various Controller configuration elements can be defined, and how the automation playbooks themselves can be more simple.

Once such collection is the infra.controller_configuration collection, which depends on the ansible.controller collection, and provides roles that wrap the individual modules within the ansible.controller collection. Infra.Controller_configuration Collection

Leveraging this overlay collection provides a few key benefits:


Navigation

Previous Exercise Next Exercise

Click here to return to the Workshop Homepage