how to run community modules in awx

171 Views Asked by At

I have the following module in my ansible playbook that I wish to run using awx:

- name: Clean up and Prune everything docker on oasis
      community.docker.docker_prune:
        containers: true
        images: true
        networks: true
        volumes: true
        builder_cache: true

When running this playbook I get the following error:

ERROR! couldn't resolve module/action 'community.docker.docker_prune'. This often indicates a misspelling, missing collection, or incorrect module path.
The error appears to be in '/runner/project/update_machines.yml': line 38, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
    - name: Clean up and Prune everything docker on oasis
      ^ here

How do I fix it? I can run this using command line ansible with no issues on a different VM with ansible installed.

1

There are 1 best solutions below

0
Shery On

Found 2 ways to do it.

  1. Build your own environment executor with required modules included and use that. (you will need ansible_build for it). Look here for more info
  2. If your collections don't require system dependencies that may not be present in AWX EE, you can just put the requirements in collections/requirements.yml in your project folder. So I created a collections folder at the root of ansible project directory and then created a requirements.yml inside this folder. Add your required modules in this file. for example mine looks like this:
---
collections:
  - name: community.general
  - name: community.docker

More info here.