Created
June 26, 2015 20:56
-
-
Save mikerowehl/336ed466cc50d069f3f6 to your computer and use it in GitHub Desktop.
Explicit loop with conditionals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: localhost | |
connection: local | |
gather_facts: false | |
tasks: | |
- name: Get tag Name where exists | |
debug: msg="Host {{ item }} is tagged with {{ hostvars[item]['ec2_tag_Name'] }}" | |
with_items: groups.all | |
when: hostvars[item]['ec2_tag_Name'] is defined | |
- name: Output hosts without name | |
debug: msg="Host {{ item }} has no name tag" | |
with_items: groups.all | |
when: hostvars[item]['ec2_tag_Name'] is not defined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment