Skip to content

Instantly share code, notes, and snippets.

View moushegh's full-sized avatar
💭
I may be slow to respond.

Moushegh Nazaretyan moushegh

💭
I may be slow to respond.
View GitHub Profile
@moushegh
moushegh / ansible_conditionals_examples.yaml
Created November 15, 2021 12:35 — forked from marcusphi/ansible_conditionals_examples.yaml
Ansible 1.3 Conditional Execution -- Very complete example with comments -- I find the conditional expressions to be ridiculously hard to get right in Ansible. I don't have a good model of what's going on under the surface so I often get it wrong. What makes it even harder is that there has been at least three different variants over the course …
---
# This has been tested with ansible 1.3 with these commands:
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=false"
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=true"
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts"
# NB: The type of the variable is crucial!
- name: Ansible Conditionals Examples
hosts: $hosts
vars_files:

Keybase proof

I hereby claim:

  • I am moushegh on github.
  • I am naut (https://keybase.io/naut) on keybase.
  • I have a public key ASBM4BBq8n8tcWe6yGRMBgq9qPqVGBThbEi9yEGq1UWiDgo

To claim this, I am signing this object: