Created
June 30, 2017 00:41
-
-
Save retr0h/21101944a98106ef12c31c559c9d1b29 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
import os | |
import ansible.constants | |
import ansible.inventory | |
import ansible.playbook | |
import ansible.plugins.callback | |
import ansible.parsing.dataloader | |
import ansible.utils.vars | |
import ansible.vars | |
import pprint | |
pp = pprint.PrettyPrinter(indent=2) | |
host_list = os.path.expanduser( | |
'~/git/ansible-inventory/pas3/4.1.6-vpp-local/pas3.mc') | |
v = ansible.vars.VariableManager() | |
loader = ansible.parsing.dataloader.DataLoader() | |
inventory = ansible.inventory.Inventory( | |
loader=loader, variable_manager=v, host_list=host_list) | |
play = ansible.playbook.play.Play.load( | |
dict( | |
hosts=['all'], | |
gather_facts=False, | |
roles=['cisco.motd'], ), | |
loader=loader, | |
variable_manager=v, ) | |
all_hosts = [h for h in inventory.get_hosts(pattern=None or "all")] | |
for host in all_hosts: | |
res = v.get_vars( | |
loader=loader, | |
play=play, | |
host=host, | |
include_hostvars=True, | |
include_delegate_to=True, ) | |
pp.pprint(res) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment