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
|
#!/usr/bin/env bash
|
||||||
import sys
|
FILENAME="./inventory.ini"
|
||||||
|
|
||||||
FILENAME = "./inventory.ini"
|
counter=0
|
||||||
|
echo -n > "$FILENAME"
|
||||||
|
for i; do
|
||||||
def main():
|
echo "vm$counter ansible_host=$i" >> "$FILENAME"
|
||||||
hosts = []
|
((counter++))
|
||||||
counter = 0
|
done
|
||||||
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()
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue