Okay, Automation Controller is up and running but pretty empty. In this task you add some automation content to it. To make it not too easy and resemble more real life situations, you will use Ansible to configure Automation Controller objects.
Prerequisites
ansible-navigator on a laptop/VM.Tasks
ansible.controller collection to create these objects in your Automation Controller:
BTW you don’t have to install the ansible.controller collection because it’s already baked into the EE we used before to deploy instances.
Okay…
ansible.controller here, upstream is called awx.awx.loop in the creating hosts section to only contain the public FQDN of your managed node instance.
ssh_key_data: points to the SSH key you use to connect to the instancesYou have seen how ansible-navigator knew which Execution Environment image to use, right? But this only works if you have the needed configuration in ansible-navigator.ymlliving in the same directory you run ansible-navigator from. You can specify the EE and other parameters on the commandline but it’s easier to track what you’ve done in the config file. As a start copy the ansible-navigator.yml file over to your new directory and adapt it if needed.
ansible.controller collection modules to be able to talk to your Automation Controller:
ansible-navigator.yml file
ansible-navigator
-m stdout to mimic the output of ansible-playbookGoal
Tips
---
- name: Configure automation controller
hosts: localhost
become: false
gather_facts: false
tasks:
- name: Create an inventory
ansible.controller.inventory:
name: Learnfest Inventory
organization: Default
- name: Add hosts to inventory
ansible.controller.host:
name: "{{ item }}"
inventory: Learnfest Inventory
state: present
loop:
- <instance-5>
- name: Machine Credentials
ansible.controller.credential:
name: Learnfest Credentials
credential_type: Machine
organization: Default
inputs:
username: ec2-user
ssh_key_data: "{{ lookup('file', '~/.ssh/<GUID>key.pem' ) }}"
- name: Learnfest Project
ansible.controller.project:
name: Learnfest Project
organization: Default
state: present
scm_update_on_launch: True
scm_delete_on_update: True
scm_type: git
scm_url: https://github.com/ansible-learnfest/playbooks-example.git
- name: Learnfest Job Template
ansible.controller.job_template:
name: Install Apache
organization: Default
state: present
inventory: Learnfest Inventory
become_enabled: True
playbook: apache_install.yml
project: Learnfest Project
credential: Learnfest Credentials
controller.ansible-navigator collections against the EE in question.ansible.controller in Automation Hub, awx.awx upstream, lot’s of references to Tower in the docs)… don’t be, all will finally be good! (TM)