# custom modules and local images

**URL:** <https://forum.ansible.com/t/custom-modules-and-local-images/26380>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [December 26, 2017, 10:59am UTC](https://forum.ansible.com/t/custom-modules-and-local-images/26380 "2017-12-26T10:59:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oguz\_Yarimtepe](https://avatars.discourse-cdn.com/v4/letter/o/d07c76/32.png) [@Oguz\_Yarimtepe](https://forum.ansible.com/u/Oguz_Yarimtepe)\
**Post date:** [December 26, 2017, 10:59am UTC](https://forum.ansible.com/t/custom-modules-and-local-images/26380/1 "2017-12-26T10:59:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [January 8, 2018, 4:17pm UTC](https://forum.ansible.com/t/custom-modules-and-local-images/26380/2 "2018-01-08T16:17:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Oguz\_Yarimtepe](https://avatars.discourse-cdn.com/v4/letter/o/d07c76/32.png) [@Oguz\_Yarimtepe](https://forum.ansible.com/u/Oguz_Yarimtepe)\
**Post date:** [January 10, 2018, 1:21pm UTC](https://forum.ansible.com/t/custom-modules-and-local-images/26380/3 "2018-01-10T13:21:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tom\_Ammon](https://avatars.discourse-cdn.com/v4/letter/t/77aa72/32.png) [@Tom\_Ammon](https://forum.ansible.com/u/Tom_Ammon)\
**Post date:** [February 23, 2018, 4:55am UTC](https://forum.ansible.com/t/custom-modules-and-local-images/26380/4 "2018-02-23T04:55:09Z")

</div>

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/](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

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [February 26, 2018, 1:43pm UTC](https://forum.ansible.com/t/custom-modules-and-local-images/26380/5 "2018-02-26T13:43:15Z")

</div>

You can find the Dockerfiles as part of the installer here: [https://github.com/ansible/awx/tree/devel/installer/image\_build/templates](https://github.com/ansible/awx/tree/devel/installer/image_build/templates)

---

<div class="post-metadata">

**Author:** ![Tom\_Ammon](https://avatars.discourse-cdn.com/v4/letter/t/77aa72/32.png) [@Tom\_Ammon](https://forum.ansible.com/u/Tom_Ammon)\
**Post date:** [February 27, 2018, 4:05am UTC](https://forum.ansible.com/t/custom-modules-and-local-images/26380/6 "2018-02-27T04:05:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tom\_Ammon](https://avatars.discourse-cdn.com/v4/letter/t/77aa72/32.png) [@Tom\_Ammon](https://forum.ansible.com/u/Tom_Ammon)\
**Post date:** [February 28, 2018, 9:18pm UTC](https://forum.ansible.com/t/custom-modules-and-local-images/26380/7 "2018-02-28T21:18:16Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Tom\_Ammon](https://avatars.discourse-cdn.com/v4/letter/t/77aa72/32.png) [@Tom\_Ammon](https://forum.ansible.com/u/Tom_Ammon)\
**Post date:** [February 28, 2018, 9:36pm UTC](https://forum.ansible.com/t/custom-modules-and-local-images/26380/8 "2018-02-28T21:36:45Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Tom\_Ammon](https://avatars.discourse-cdn.com/v4/letter/t/77aa72/32.png) [@Tom\_Ammon](https://forum.ansible.com/u/Tom_Ammon)\
**Post date:** [February 28, 2018, 9:49pm UTC](https://forum.ansible.com/t/custom-modules-and-local-images/26380/9 "2018-02-28T21:49:04Z")

</div>

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?
