断言在 Ansible 中有效,但在 AWX 中无效

断言在 Ansible 中有效,但在 AWX 中无效

我已经切换到 AWX 来管理我的剧本,但我似乎无法用断言解决这个问题。这是我准备的角色:

- 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"

当我使用 ansible-playbook 命令运行它时,一切运行良好,并且断言任务返回以下内容:

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

但是当我使用 AWX 运行完全相同的剧本时,我得到:

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"}

有人知道为什么会发生这种情况吗?

相关内容