01. January 2020 - verfasst von Oliver Gaida - Kategorien: ["ansible"]
Logische Operationen in Ansible
Negation
- shell: echo "This certainly isn't epic!"
when: not epic
Variable gesetzt?
- shell: echo "I've got '' and am not afraid to use it!"
when: foo is defined
- fail: msg="Bailing out. this play requires 'bar'"
when: bar is undefined
Wert überprüfen
Adhoc-Kommando:
ansible localhost -m debug -a 'msg="{% if 1 == 1 %}{{ \"ja\" }}{% else %}{{ \"nein\" }}{% endif %}"'
localhost | SUCCESS => {
"msg": "ja"
}
Substring ist enthalten
- shell: echo "motd contains the word hi"
when: motd_contents.stdout.find('hi') != -1