I have a list of strings that I expect in some command's output. How can I create an ansible script that tests and - in case one or several of the entries is not contained - executes a task?
So my ansible script might look like:
vars:
musthave:
- value1
- value2
tasks:
- name: Check the configured values
command: "cat configfile"
register: current_configuration
changed_when: false
- set a variable if one or more of the musthave's are missing in current_configuration.stdout
...
- name: Execute task to reconfigure system
command: "reconfigure..."
when: true = variable
So is there something like
variable = false
for s in musthave:
if not s in current_configuration.stdout:
variable |= true