
我已切換到 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"}
有人知道為什麼會發生這種情況?