custom modules and local images

What should i do to add bigsuds and pysphere modules to my awx installation? And i am still not able to upgrade the current image without loosing the settings.
Will be happy if someone show me a path.

How is your database set up?

If you want custom modules you’ll need to add them to the image build and build your own custom images.

You are right. I solved the issue by building locally.

Oguz,

I am trying to get some custom modules into AWX as well, but I am at a loss as to where to start building a custom image. I see no dockerfile listed at https://hub.docker.com/r/ansible/awx_task/ so I don’t know which volumes are already built. I am assuming I can just do use ansible/awx_task and set up some volumes in a new dockerfile, but I don’t know which volumes are already set up in the current public images. Could you share your process for building a local image?

Tom

You can find the Dockerfiles as part of the installer here: https://github.com/ansible/awx/tree/devel/installer/image_build/templates

Thanks, Matthew.

I found the files you referenced in awx/installer/image_build/templates.

I stopped my current running containers, deleted all of the images, and blew away the directory I had cloned AWX to. I did a fresh clone, then made modifications. I changed the postgres_data_dir variable in inventory to point to a permanent location, I set use_docker_compose=true.

I modified Dockerfile.task.j2 to look like the following (notes on the lines I added):

FROM {{ awx_web_image }}:{{ awx_version }}
USER 0
RUN mkdir -p /usr/share/ansible/modules ← added by Tom
RUN echo “library = /usr/share/ansible/modules” >> /etc/ansible/ansible.cfg ← added by Tom
RUN sudo yum -y remove nginx
USER 1000
EXPOSE 8052
VOLUME /etc/ansible/roles /usr/share/ansible/modules ← added by Tom
CMD /usr/bin/launch_awx_task.sh

I then ran the installer, but the image does not appear to have been built according to my modifications:

docker inspect awx_task_1 produces this (I am using docker-compose):

“Image”: “ansible/awx_task:latest”,
“Volumes”: null,
“WorkingDir”: “/var/lib/awx”,
“Entrypoint”: [
“/tini”,
“–”
],

I assume that the installer will build the new image according to this template. Is that correct? Is there something I have to tell the installer to do to honor my changes?

Tom

Okay, I am making progress, but now I’ve run in to another roadblock.My read of INSTALL.md is that I should remove these lines in order to build a custom image based on my modifications to awx/installer/image_build/templates/Dockerfile.task.j2:

dockerhub_base=
dockerhub_version=

but when i run the playbook to build awx, I get this output. It takes about a minute for it to fail on the last task:

TASK [image_build : Clean distribution] **************************************************************************************************************************
changed: [localhost → localhost]

TASK [image_build : Build sdist builder image] *******************************************************************************************************************
changed: [localhost → localhost]

TASK [image_build : Build AWX distribution using container] ******************************************************************************************************
fatal: [localhost → localhost]: FAILED! => {“changed”: false, “msg”: “Error creating container: 500 Server Error: Internal Server Error ("Error parsing reference: "awx_sdist_builder:" is not a valid repository/tag")”}

it looks like that line is in awx/installer/image_build/tasks/main.yml:

  • name: Build AWX distribution using container
    docker_container:
    env:
    http_proxy: “{{ http_proxy | default(‘’) }}”
    https_proxy: “{{ https_proxy | default(‘’) }}”
    no_proxy: “{{ no_proxy | default(‘’) }}”
    image: “awx_sdist_builder:{{ awx_version }}”
    name: awx_sdist_builder

But that line looks correct to me. The : should be fine since it is surrounded by double quotes.

Any ideas?

I believe the problem is based on the awx_version variable being empty. In the main.yml playbook, the first task is

  • name: Get Version from checkout if not provided
    shell: “git describe --long --first-parent | sed ‘s/\-g.*//’ | sed ‘s/\-/\./’”
    delegate_to: localhost
    register: awx_version_command
    when: awx_version is not defined

however, on my system (centos7, with git installed via yum), I don’t have the --first-parent option:

[root@awx.local]# git describe --long --first-parent
error: unknown option `first-parent’
usage: git describe [options] *
or: git describe [options] --dirty

–contains find the tag that comes after the commit
–debug debug search strategy on stderr
–all use any ref
–tags use any tag, even unannotated
–long always use long format
–abbrev[=] use digits to display SHA-1s
–exact-match only output exact matches
–candidates consider most recent tags (default: 10)
–match only consider tags matching
–always show abbreviated commit object as fallback
–dirty[=] append on dirty working tree (default: “-dirty”)

but I can see the version:

[root@awx.local]# git describe --long
1.0.4-101-gdba78e6

so I could hardcode the version number in the playbook I suppose. But what is really being looked for in the version number? In dockerhub I see lots of different tags for the awx_task image. Which one would be best to use?

I’ll keep posting my progress here. I’m hoping that someone more familiar with AWX than I can help me.

I removed “–first-parent” from the git command which produces the following output:

1.0.4.101

so I removed that from the task in the playbook, but now it appears there is a different problem:

TASK [image_build : Clean distribution] **************************************************************************************************************************
changed: [localhost → localhost]

TASK [image_build : Build sdist builder image] *******************************************************************************************************************
changed: [localhost → localhost]

TASK [image_build : Build AWX distribution using container] ******************************************************************************************************
changed: [localhost → localhost]

TASK [image_build : Build AWX distribution locally] **************************************************************************************************************
skipping: [localhost]

TASK [image_build : Set docker build base path] ******************************************************************************************************************
ok: [localhost]

TASK [image_build : Set awx_web image name] **********************************************************************************************************************
ok: [localhost]

TASK [image_build : Set awx_task image name] *********************************************************************************************************************
ok: [localhost]

TASK [image_build : Ensure directory exists] *********************************************************************************************************************
changed: [localhost → localhost]

TASK [image_build : Stage sdist] *********************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: /opt/awx/installer/…/dist/awx-1.0.4.101.tar.gz
fatal: [localhost → localhost]: FAILED! => {“changed”: false, “msg”: “Could not find or access ‘…/dist/awx-1.0.4.101.tar.gz’\nSearched in:\n\t/opt/awx/installer/image_build/files/…/dist/awx-1.0.4.101.tar.gz\n\t/opt/awx/installer/image_build/…/dist/awx-1.0.4.101.tar.gz\n\t/opt/awx/installer/image_build/tasks/files/…/dist/awx-1.0.4.101.tar.gz\n\t/opt/awx/installer/image_build/tasks/…/dist/awx-1.0.4.101.tar.gz\n\t/opt/awx/installer/files/…/dist/awx-1.0.4.101.tar.gz\n\t/opt/awx/installer/…/dist/awx-1.0.4.101.tar.gz”}

Any thoughts on this?