Created
September 4, 2019 02:06
-
-
Save PoplarYang/95ad58716cb29fbaf1e1b411b8781fc8 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
def tes(node, inventory): | |
from ansible.parsing.dataloader import DataLoader | |
from ansible.vars.manager import VariableManager | |
from ansible.inventory.manager import InventoryManager | |
from ansible.vars.hostvars import HostVars | |
dl = DataLoader() | |
#dl.load_from_file("vars.yml") | |
im = InventoryManager(loader=dl, sources=[inventory_dir]) | |
vm = VariableManager(loader=dl, inventory=im) | |
#host = im.get_host(nodes) | |
hostvars = HostVars(im, vm, dl) | |
#vm.set_host_variable(host=host, varname="AAA", value="aaa") | |
#print(vm.get_vars(host=host)) | |
return hostvars[node] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment