1
0
Fork 0
yatf/mkinv

21 lines
391 B
Text
Raw Normal View History

2024-09-25 14:28:25 +03:00
#!/usr/bin/env python3
import sys
FILENAME = "./inventory.ini"
2024-09-25 14:28:25 +03:00
def main():
hosts = []
2024-09-25 14:28:25 +03:00
counter = 0
for addr in sys.argv[1:]:
hosts.append(f"vm{counter} ansible_host={addr}")
2024-09-25 14:28:25 +03:00
counter += 1
inventory = "\n".join(hosts)
with open(FILENAME, "w", encoding="utf8") as inv_file:
inv_file.write(inventory + "\n")
2024-09-25 14:28:25 +03:00
if __name__ == "__main__":
main()