1
0
Fork 0
yatf/mkinv

20 lines
391 B
Python
Executable file

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