1
0
Fork 0

level up ansible stuff

This commit is contained in:
Von Random 2024-09-25 14:28:25 +03:00
parent 495e8bd09c
commit 9cfe1f008f
3 changed files with 24 additions and 1 deletions

21
mkinv Executable file
View file

@ -0,0 +1,21 @@
#!/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()