I try to verify that my docker compose suit is up with task
- name: Verify that web and db services are running
ansible.builtin.assert:
that:
- "output.services.artifactory-exporter-pdp.devopsmonitoring_artifactory-exporter-pdp_1.state.running"
...
this give me a failure message:
2023-07-20T13:57:06.2633470Z fatal: [server]: FAILED! => {"msg": "The conditional check 'output.services.artifactory-exporter-pdp.devopsmonitoring_artifactory-exporter-pdp_1.state.running' failed. The error was: error while evaluating conditional (output.services.artifactory-exporter-pdp.devopsmonitoring_artifactory-exporter-pdp_1.state.running): 'dict object' has no attribute 'artifactory'"}
and in the associated output I clearly see that it's a 1:1 match.
Are there any special characters here that I should escape, or something I'm missing?
Are there any special characters here that I should escape?
Yes, according to Creating valid variable names
Not all strings are valid Ansible variable names. A variable name can only include letters, numbers, and underscores. Python keywords or playbook keywords are not valid variable names.
That's why the string gets cut off and you get an error message
'dict object' has no attribute 'artifactory'
as the systems if looking for
output.services.artifactory
which is obviously not existing.
You may try with array notation
output.services['artifactory-exporter-pdp']['devopsmonitoring_artifactory-exporter-pdp_1'].state.running
Similar Q&A