1
0
Fork 0

use bash instead of python to simplify things

This commit is contained in:
Von Random 2024-09-25 16:08:21 +03:00
parent c0f692e8a1
commit e5c8dfe83e

27
mkinv
View file

@ -1,20 +1,9 @@
#!/usr/bin/env python3
import sys
#!/usr/bin/env bash
FILENAME="./inventory.ini"
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()
counter=0
echo -n > "$FILENAME"
for i; do
echo "vm$counter ansible_host=$i" >> "$FILENAME"
((counter++))
done