2024-09-25 14:28:25 +03:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import sys
|
2024-09-25 14:45:32 +03:00
|
|
|
|
|
|
|
FILENAME = "./inventory.ini"
|
2024-09-25 14:28:25 +03:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2024-09-25 14:45:32 +03:00
|
|
|
hosts = []
|
2024-09-25 14:28:25 +03:00
|
|
|
counter = 0
|
|
|
|
for addr in sys.argv[1:]:
|
2024-09-25 14:45:32 +03:00
|
|
|
hosts.append(f"vm{counter} ansible_host={addr}")
|
2024-09-25 14:28:25 +03:00
|
|
|
counter += 1
|
|
|
|
|
2024-09-25 14:45:32 +03:00
|
|
|
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()
|