Created
June 26, 2015 20:52
-
-
Save mikerowehl/f330831b42145f73c6ac to your computer and use it in GitHub Desktop.
Using dynamic inventory to find something without a certain tag
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: tag_clusterType_* | |
connection: local | |
gather_facts: false | |
tasks: | |
- name: Get everything in a cluster | |
debug: msg="Host {{ hostvars[inventory_hostname]['ec2_tag_Name'] }} is in cluster {{ hostvars[inventory_hostname]['ec2_tag_clusterType'] }}" | |
- hosts: all:!tag_clusterType_* | |
connection: local | |
gather_facts: false | |
tasks: | |
- name: Everything else | |
debug: var=hostvars[inventory_hostname]['ec2_tag_Name'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Filtering for the negative case is a bit weird, cause just !tag_clusterType_* as a pattern is a syntax error. So we need to explicitly say all, and then filter down to anything that doesn't have a matching tag.