Skip to content

Instantly share code, notes, and snippets.

@mikerowehl
Created June 26, 2015 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikerowehl/f330831b42145f73c6ac to your computer and use it in GitHub Desktop.
Save mikerowehl/f330831b42145f73c6ac to your computer and use it in GitHub Desktop.
Using dynamic inventory to find something without a certain tag
- 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']
@mikerowehl
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment