1
0
Fork 0

level up ansible stuff

This commit is contained in:
Von Random 2024-09-25 14:28:25 +03:00
parent 495e8bd09c
commit 9cfe1f008f
3 changed files with 24 additions and 1 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
.venv
inventory.yaml

21
mkinv Executable file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env python3
import sys
import yaml
def main():
hosts = {}
counter = 0
for addr in sys.argv[1:]:
hosts[f"vm{counter}"] = { "ansible_host": addr }
counter += 1
inventory = { "all": { "hosts": hosts } }
inventory_yaml = yaml.dump(inventory)
print(inventory_yaml)
# with open("./inventory.yaml", "w", encoding="utf8") as inv_file:
# inv_file.write(inventory_yaml)
if __name__ == "__main__":
main()

View file

@ -18,7 +18,7 @@ http {
server {
listen 80 default_server;
location / {
return 200 ">>>>>>>>>> My ip is: {{ inventory_hostname }} <<<<<<<<<<\n";
return 200 ">>>>>>>>>> I am {{ inventory_hostname }} ({{ ipv4.address }}) <<<<<<<<<<\n";
}
}
}