AWX deployment with Ansible


The documented installation method for AWX is quite manual. The Ansible playbook below can be used to easily deploy your preferred release of AWX. It is presumed that you already have a working Kubernetes or minik8s instance.

I prefer to execute the deployment yaml in a separate step to the initial set up. However you can always run the deploy file the playbook generates immediately after Step 5.

Creating a deployment file using Ansible

The playbook below will save the generated deploy file outside the awx-operator repository to the path specified with the variable awx_deploy_file. The variable awx_release should be set to your desired release version.

 2  - name: Create AWX Operator deployment manifest
 3    hosts: my_k8s_manager
 4    vars:
 5      k8s_user: "myuser"
 6      awx_release: "0.14.0"
 7      awx_repo: ""
 8      awx_operator_local_dir: "/home/{{k8s_user}}/awx-operator/"
 9      awx_deploy_file: "/home/{{k8s_user}}/awx/awx_deploy-{{awx_release}}.yml"
10    tasks:
11      - name: "Step 1. Clone AWX release locally"
12        ansible.builtin.git:
13          repo: "{{awx_repo}}"
14          dest: "{{awx_operator_local_dir}}"
15          version: "{{awx_release}}"
16          force: yes
17      - name: "Step 2. Check if this release version has a deployment file"
18        stat:
19          path: "{{awx_deploy_file}}"
20        register: deploy_file
21      - name: "Step 3. run make in repo and nominate the namespace AWX will be deployed to."
22        make:
23          chdir: "{{awx_operator_local_dir}}"
24          target: deploy
25          params:
26            NAMESPACE: awx-example
27        when: not deploy_file.stat.exists
28      - name: "Step 4. Set image release version for controller"
29        shell:
30          chdir: "{{awx_operator_local_dir}}/config/manager/"
31          cmd: "{{awx_operator_local_dir | quote }}/bin/kustomize edit set image{{ awx_release | quote }}"
32        when: not deploy_file.stat.exists
33      - name: "Step 5. Generate the deployment file"
34        shell:
35          chdir: "{{awx_operator_local_dir}}/"
36          cmd: bin/kustomize build config/default >> {{awx_deploy_file | quote}}
37          creates: "{{awx_deploy_file}}"
38        when: not deploy_file.stat.exists

Running the deployment file

With the deployment file created, we can now create the awx-operator. The playbook will create a deploy file for the release version you selected.

1kubectl apply -f /home/myuser/awx/awx_deploy.0.14.0.yml

Get the code

All code shown in this post can be found here