The awx role

The next and (sort of) final role for our AWX installation can be created by running:

$ ansible-galaxy init roles/awx

The default variables in roles/awx/defaults/main.yml are similar in format to the ones in the docker role:

awx:
repo_url: "https://github.com/ansible/awx.git"
logo_url: "https://github.com/ansible/awx-logos.git"
repo_path: "~/awx/"
packages:
- "git"
pip:
- "ansible"
- "boto"
- "boto3"
- "botocore"
install_command: 'ansible-playbook -i inventory --extra-vars "awx_official=true" install.yml'

Starting from the top, we have two different GitHub repo URLs. The first awx.repo_url is the main AWX repository and the second awx.logo_url is for the official logo pack. Next up, we have the path, awx.repo_path, and we want to check out the code too. In this case, it is ~/awx which, as we are using become, will be /root/awx/.

To check out the code from GitHub, we need to make sure that we have Git installed. awx.packages is the only additional package we need to install using yum. Next up, we need to install Ansible itself and a few of the other Python packages we will need using PIP (awx.pip).

Finally, we have the command (awx.install_command) we need to run in order to install Ansible AWX. As you can see, we are using an Ansible playbook that ships as part of the code we are checking out; the command itself is overriding the option for using official AWX logos by passing awx_official=true as extra variables.

Now that we have discussed the variables we need to define, we can add the tasks to roles/awx/tasks/main.yml, starting with the tasks that install the Yum and Pip packages:

- name: install the awx packages
yum:
name: "{{ item }}"
state: "installed"
update_cache: "yes"
with_items: "{{ awx.packages }}"

- name: install the python packages
pip:
name: "{{ item }}"
with_items: "{{ awx.pip }}"

Next, we have the tasks that check out the two AWX repositories from GitHub:

- name: check out the awx repo
git:
repo: "{{ awx.repo_url }}"
dest: "{{ awx.repo_path }}"
clone: "yes"
update: "yes"

- name: check out the awx logos repo
git:
repo: "{{ awx.logo_url }}"
dest: "{{ awx.repo_path }}"
clone: "yes"
update: "yes"

As you can see, both repositories are being moved to the same location on our Vagrant box. The final task runs the playbook that downloads, configures, and launches the Ansible AWX Docker containers:

- name: install awx
command: "{{ awx.install_command }}"
args:
chdir: "{{ awx.repo_path }}installer"
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.159.195