Custom Execution Environment
AWX is currently running mostly in Kubernetes or single node Minikube Kubernetes cluster. It come with default Runtime/Execution Environment which is fine, until you start doing some kung-fu with json for example. The default is missing some Ansible Collections like
community.general and some python modules.
You can't just install Ansible Collections with Ansible task at the start for example, because it will not load (Mostly issue with
delegate to localhost).
So how it works ?
Evey time you run job/template, AWX is creating docker image to which it will inject your playbooks/tasks. This is the image we need to modify. We will extend the official Execution Environment with bunch of collections and python modules to have error fee runs or filter missing, like:
ERROR! template error while templating string: no filter named 'json_query'
Here is the guide on my GitLab: HERE
You can read almost all the information there, but I will copy it here as well.
First get some Linux computer with docker and Internet access, we need to build custom image and push it to registry. However you can freely use my already build Execution Environment if you like, then you can skip the build part.
Build docker image
Clone my repo
git clone https://gitlab.privatecloud.sk/vladoportos/create-custom-ee-for-awx.git cd create-custom-ee-for-awx
- requirements.txt for python requirements
- requirements.yml for Ansible collections
Dockerfile we are extending
quay.io/ansible/awx-ee:0.2.0 check here if its the latest (don't use
Before the build
There is one thing to mention, your AWX needs to get to this Execution Environment somehow, it pulls by default the
quay.io/ansible/awx-ee:0.2.0 so I registered on https://quay.io with free account and will be pushing the build image there. You can find mine HERE
So the following build example will work with my quay.io account.
docker image build --tag quay.io/vladoportos/custom-awx-ee:latest . docker login quay.io docker push quay.io/vladoportos/custom-awx-ee
Replace the quay.io links with yours.
Set the new Runtime Environment in AWX
Administration -> Execution Environments -> Add
You can then choose this as Execution Environment in your templates.
Check for issues in minikube.
Switch to minikube user (this is user I use for minikube server)
su - minikube minikube kubectl get events
You should have something like this when you lunch job:
11s Normal Scheduled pod/awx-job-170-mhz4t Successfully assigned default/awx-job-170-mhz4t to minikube 11s Normal Pulling pod/awx-job-170-mhz4t Pulling image "quay.io/vladoportos/custom-awx-ee:latest" 5s Normal Pulled pod/awx-job-170-mhz4t Successfully pulled image "quay.io/vladoportos/custom-awx-ee:latest" in 5.316071635s 5s Normal Created pod/awx-job-170-mhz4t Created container worker 5s Normal Started pod/awx-job-170-mhz4t Started container worker
This is sign that it worked most likely. You might get errors like:
3m18s Warning InspectFailed pod/awx-job-168-x5dlq Failed to apply default image tag "docker pull quay.io/vladoportos/custom-awx-ee:latest": couldn't parse image reference "docker pull quay.io/vladoportos/custom-awx-ee:latest": invalid reference format 3m33s Warning Failed pod/awx-job-168-x5dlq Error: InvalidImageName
This happened when I put wrong name into AWX setting.
Logout from quay.io
docker logout quay.io
And thats it, this guide is based on AWX issues/312
That’s it for now, was it helpful to you? Now get some coffee and maybe get me one too 🙂