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

23
mkinv
View file

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