Created
April 6, 2018 02:32
-
-
Save mrlesmithjr/3c149124f2894c572939bf41c6bc5ad5 to your computer and use it in GitHub Desktop.
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
{{ ansible_managed|comment }} | |
{% set _groups = [] %} | |
{% for vm in vms %} | |
{% if vm['groups'] is defined %} | |
{% for _group in vm['groups'] %} | |
{% set _ = _groups.append(_group) %} | |
{% endfor %} | |
{% endif %} | |
{% endfor %} | |
{% set _groups = _groups|unique|sort|list %} | |
{% for _group in _groups %} | |
[{{ _group }}] | |
{% for vm in vms %} | |
{% if vm['groups'] is defined and vm['state'] == "present" %} | |
{% for __group in vm['groups'] %} | |
{% if __group == _group %} | |
{% for host in groups['provisioned_vms'] %} | |
{% if host == vm['name'] %} | |
{{ host }} ansible_host={{ hostvars[host]['ansible_host'] }} mac_address={{ hostvars[host]['mac_address'] }} uuid={{ hostvars[host]['uuid'] }} | |
{% endif %} | |
{% endfor %} | |
{% endif %} | |
{% endfor %} | |
{% endif %} | |
{% endfor %} | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment