1
0
Fork 0
yatf/mkinv

21 lines
462 B
Python
Executable file

#!/usr/bin/env python3
import sys
import yaml
def main():
hosts = {}
counter = 0
for addr in sys.argv[1:]:
hosts[f"vm{counter}"] = { "ansible_host": addr }
counter += 1
inventory = { "all": { "hosts": hosts } }
inventory_yaml = yaml.dump(inventory)
print(inventory_yaml)
# with open("./inventory.yaml", "w", encoding="utf8") as inv_file:
# inv_file.write(inventory_yaml)
if __name__ == "__main__":
main()