0

I've switched to AWX for my playbooks management and I can't seem to figure out this issue with assert. Here is a role that I've prepared:

- name: Run testing environment
  docker_compose:
    project_name: "testing"
    definition:
      version: '3.7'
      services:
        nginx:
          image: nginx:alpine
  register: output

- name: save output
  debug:
    var: output

- name: assert that container is running
  assert:
    that:
      - "nginx.testing_nginx_1.state.running"

When I run it with the ansible-playbook command, everything works well and the assert tasks returns the following:

TASK [test_role : assert that container is running] ************************************************************************************
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

But when I run the same exact playbook using AWX, I get:

TASK [test_role : assert that container is running] ****************************
fatal: [testhost]: FAILED! => {"msg": "The conditional check 'nginx.testing_nginx_1.state.running' failed. The error was: error while evaluating conditional (nginx.testing_nginx_1.state.running): 'nginx' is undefined"}

Does anyone have an idea why this is happening?

dywan666
  • 160
  • 8
  • There is something missing. You have not shown a playbook or a task or anything else that defines `nginx`. – Michael Hampton Aug 10 '21 at 16:59
  • I’ve shown everything. I took this from the module documentation: https://docs.ansible.com/ansible/latest/collections/community/docker/docker_compose_module.html#ansible-collections-community-docker-docker-compose-module - please take a loot at the last example. – dywan666 Aug 10 '21 at 19:55
  • Wow, this is not very well documented. It seems like those facts get populated for all the containers you've declared in docker-compose.yml whenever you call that module. Or at least that is what they are implying. I suspect you should look at the `output` from the previous task.. – Michael Hampton Aug 10 '21 at 20:03
  • You are right. I can see that ansible_facts get populated with the `nginx` variable in my case. So why is this not working in AWX? – dywan666 Aug 11 '21 at 05:49
  • Which version of ansible is your awx installation running ? I'd bet it is different and older than the one you are running manually. Try to install the same version in a virtualenv locally and run the playbook with it. Do you get the same error ? – Zeitounator Aug 14 '21 at 20:44
  • I've decided to just use the info from the output, modified my playbooks slightly and everything is working correctly from both AWX and ansible running locally. – dywan666 Aug 20 '21 at 09:06

0 Answers0