How to enable changes in AWX Containers?

4.1k views Asked by At

I am trying to install additional python packages in AWX container awx_tasks so that the changes could enable the ansible modules like snow, ec2_elb_facts run (which have pre-requisites as Python modules). I have made the changes in the container using:

# docker exec -it 80ab6bf562a9 bash

where 80ab6bf562a9 is the container id for awx_task container.

and then installed the required packages inside the custom virtual environment (as mentioned in the AWX documentation). Post this, i have made the changes permanent by creating a new image with the container changes using:

# docker commit 80ab6bf562a9 ansible/awx_task:latest

Post this, ran the following command to map the new container with the newly created image with container changes.

# docker run --name awx_task -d 5290f9b3268c

Following are the containers post the above changes. Here, the newly created container which was mapped with the new image with changes in existing container is 968fb2a7da2f.

# docker container ps -a
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS                    PORTS                                                 NAMES
968fb2a7da2f        5290f9b3268c                 "/tini -- /bin/sh -c…"   2 days ago          Exited (143) 2 days ago                                                         awx_task
80ab6bf562a9        535bb2b8e1f3                 "/tini -- /bin/sh -c…"   3 weeks ago         Up 2 days                 8052/tcp                                              awx_task_OLD
aea2551951d5        b7c261b76010                 "/tini -- /bin/sh -c…"   3 weeks ago         Up 2 days                 0.0.0.0:80->8052/tcp                                  awx_web
e789a4a82a9e        memcached:alpine             "docker-entrypoint.s…"   3 weeks ago         Up 2 days                 11211/tcp                                             memcached
a8c74584255c        ansible/awx_rabbitmq:3.7.4   "docker-entrypoint.s…"   3 weeks ago         Up 2 days                 4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp   rabbitmq
25f6f6ca7766        postgres:9.6                 "docker-entrypoint.s…"   3 weeks ago         Up 2 days                 5432/tcp                                              postgres

Following are my images post above changes. Here, the newly created image (with changes) is 5290f9b3268c.

# docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
ansible/awx_task       latest              5290f9b3268c        2 days ago          1.48GB
postgres               9.6                 106bdfb062df        8 weeks ago         235MB
ansible/awx_task       <none>              535bb2b8e1f3        8 weeks ago         1.07GB
ansible/awx_web        <none>              b7c261b76010        8 weeks ago         1.04GB
hello-world            latest              2cb0d9787c4d        2 months ago        1.85kB
memcached              alpine              b40e8fa7e3e5        2 months ago        8.69MB
ansible/awx_rabbitmq   3.7.4               e08fe791079e        6 months ago        85.6MB

The new container is properly mapped with the new image (which has got the changes i wanted). The issue now is that when i stop the old container and start the new container AWX doesn't work. I can just view the UI, if i run any tasks like executing templates, it just freezes. It appears like the new container/images are not talking with the other containers like awx_rabbitmq, postgres etc. I have been reading multiple posts regarding this however, i couldn't find any single post which highlights anything regarding this.

I basically want the changes in the awx_task container to work so that i could achieve the goal of making the custom modules work. Could anyone suggest what can be done so that the new awx_task container could take the role of the older awx_task and AWX could work normally?

2

There are 2 answers

0
Ankit Vashistha On BEST ANSWER

Since i found the way to do this, i will share the steps to make the required changes.

The python package versions can be controlled from the requirements directory, AWX Task and AWX Web Images related changes can be applied in the Dockerfile.j2 in the roles directory. Once the required changes are applied, we can run the setup using ansible-playbook install.yml -i inventory.

0
diavol On

You should use the install.yml to restart the awx_task container, since it ensures the right environment variables are set, the right volumes are mapped, etc. Same command as you've used to install AWX: ansible-playbook install.yml -i inventory. See here for a full list of arguments that are used.