Skip to content

Instantly share code, notes, and snippets.

@akatch
Forked from rektide/ansible-dict-iter.yaml
Last active February 2, 2017 21:35
Show Gist options
  • Save akatch/5b5164064999082dbb1a6a36ce5237d0 to your computer and use it in GitHub Desktop.
Save akatch/5b5164064999082dbb1a6a36ce5237d0 to your computer and use it in GitHub Desktop.
Ansible cannot iterate on a dict & check the results (changed_when/failed_when/&c).
---
- hosts: localhost
vars:
places:
alpha: /home
beta: /srv
delta: /opt
gamma: /etc
epsiolon: /code
tasks:
- stat:
path: '{{ places[item] }}'
with_items: '{{ places.keys() }}'
register: places_stats
- debug:
msg: 'it doesnt exist'
when: not item.stat.exists
with_items: '{{ places_stats.results }}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment