Skip to content

Instantly share code, notes, and snippets.

@strootman
Created November 24, 2015 19:31
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 strootman/cb5162671d94bfdea9a7 to your computer and use it in GitHub Desktop.
Save strootman/cb5162671d94bfdea9a7 to your computer and use it in GitHub Desktop.
A means of determining which inventory groups are associated with a given host
{{inventory_hostname}}
========================
{% for group in group_names %}
{{ group }}
{% endfor %}
---
---
- name: Get all groups associate with a host
hosts: all
gather_facts: false
tasks:
- name: Create file
local_action: template src=groups_for_hosts.txt.j2 dest="/tmp/groups_for_host_{{inventory_hostname}}.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment