Skip to content

Instantly share code, notes, and snippets.

@base10
Created July 25, 2013 15:39
Show Gist options
  • Save base10/6081009 to your computer and use it in GitHub Desktop.
Save base10/6081009 to your computer and use it in GitHub Desktop.
Related to Michael's suggestions: (https://github.com/ansible/ansible/issues/3658#issuecomment-21535516), I've updated my playbook.yml to match suggestions. Unfortunately, I'm still not seeing the expected results. I expect to see bippy fail. fake-inventory is just localhost
---
- name: webserver plays
hosts: all
user: nathan
sudo: no
gather_facts: false
vars:
foo: "onetwothree"
bar: "fourfivesix"
err_variable_not_present: |
Required variables not present. Make sure you have ~/.wa-dev-ansible-vars defined
Use playbooks/group_vars/default as a starting point
pre_tasks:
- name: "ensure variables"
fail: >
msg="{{ err_variable_not_present }}"
when: item is not defined
with_items:
- "{{ foo }}"
- "{{ bar }}"
- "{{ bippy }}"
$ ansible-playbook -vvv -i fake-inventory playbooks.yml
PLAY [webserver plays] ********************************************************
TASK: [ensure variables] ******************************************************
skipping: [localhost] => (item=onetwothree)
skipping: [localhost] => (item=fourfivesix)
skipping: [localhost] => (item={{bippy}})
PLAY RECAP ********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment