Modify awx_task container to include new software

Hi, I would like to know if you could pinpoint me the exact way to make a software installed in the awx_task container, so when I run playbooks from AWX using the “delegate_to: localhost” it gets done successfully.

Currently, I think the Dockerfile is at /opt/awx-install/awx/installer/roles/image_build/tasks/main.yml
Do you think that adding in that file new tasks will result in what I am trying to achieve?
Or is there some particular way to handle this better? I have searched through Google and this forum but no clue, there’s an unanswered question here: https://groups.google.com/forum/#!searchin/awx-project/awx_task$20include%7Csort:date/awx-project/mI-X1oCqbiA/02D0LaeWDAAJ

Also there’s a stackoverflow question that doesn’t quite answer what I am searching for: https://stackoverflow.com/questions/52473962/how-to-enable-changes-in-awx-containers

Thank you!

The Dockerfile for the awx-web container is at awx/devel/installer/roles/image_build/templates/Dockerfile.j2 and the Dockerfile for the awx-task container is at awx/devel/installer/roles/image_build/templates/Dockerfile.task.j2. If you take a look at the awx-task Dockerfile, you’ll see that all it’s doing is building off the awx-web Dockerfile and removing nginx and launching a different script. Anything the awx-web Dockerfile installs/executes as part of the image is also part of awx-task.

What I’ve been doing is I’ll modify the awx-web Dockerfile with RUN commands to install extra yum packages, pip modules, or ansible virtual envs using Ansible’s lineinfile/blockinfile. Ends up looking similar to below (installs extra yum packages)

lineinfile:
path: awx/installer/roles/image_build/templates/Dockerfile.j2
insertbefore: “USER 1000”
line: “RUN yum -y install {{ item }}”
state: present
loop: “{{ extra_yum_packages }}”

Thank you very much, Uriel,

But you said that the awx/devel/installer/roles/image_build/templates/Dockerfile.task.j2 is the Dockerfile, but in fact is a Jinja2 file…
I think you mean the file awx/installer/roles/image_build/tasks/main.yml is the one you have modified? Or which file have you modified?
Could you more in detail what have you written (or a very simple example) in both files? I apologize for this question, but I think it could clear out a lot of things to the ones that are facing this kind of problem.

Thank you very much again!

I am in fact modifying the Jinja2 files. A Jinja2 file is nothing more than a text file with special markup – during the installation process, the Jinja2 files are converted to a regular Dockerfile text file and used to build the images. See the following tasks in the main.yml file: https://github.com/ansible/awx/blob/devel/installer/roles/image_build/tasks/main.yml#L107 and https://github.com/ansible/awx/blob/devel/installer/roles/image_build/tasks/main.yml#L113.

And the snippet of Ansible code is exactly what I use to install additional yum packages. It’s editing the Dockerfiles to add lines that install yum packages. When the image finally gets built, those commands are run and the final image has those packages ready to go.

I tried to install jq and wget by adding following lines to https://github.com/ansible/awx/blob/devel/installer/roles/image_build/templates/Dockerfile.j2 after 2nd ‘FROM’ and it’s not working as I don’t see those in awx-web container. Your approach looks similar too, so not sure why adding additional tools wouldn’t work.

Added after ‘ENV PATH=“/usr/pgsql-10/bin:${PATH}”’ line(#244 in above Dockerfile.j2)

RUN dnf install -y jq
RUN dnf install -y wget