use bash instead of python to simplify things
This commit is contained in:
parent
c0f692e8a1
commit
e5c8dfe83e
1 changed files with 8 additions and 19 deletions
27
mkinv
27
mkinv
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue