1
0
Fork 0
yatf/mkinv

22 lines
462 B
Text
Raw Normal View History

2024-09-25 14:28:25 +03:00
#!/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()