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:
In addition, the API can be asked for options that can be used when interacting with it for various configuration items:
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.
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.
This collection provides modules that correspond to the various components of Controller to configure:
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.
Leveraging this overlay collection provides a few key benefits:
Roles can be specified in a simplified playbook, over writing tasks that call the modules individually.
Not all options need to be specified when managing resources, allowing for a more simplified data structure overall:
The collection will automatically loop over elements in a list, attempting to apply many at once, speeding up configuration.
Navigation
Previous Exercise | Next Exercise |