diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 5b59a48..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.venv -inventory.yaml diff --git a/mkinv b/mkinv index 7f6b4c3..9efc049 100755 --- a/mkinv +++ b/mkinv @@ -1,20 +1,19 @@ #!/usr/bin/env python3 import sys -import yaml + +FILENAME = "./inventory.ini" def main(): - hosts = {} + hosts = [] counter = 0 for addr in sys.argv[1:]: - hosts[f"vm{counter}"] = { "ansible_host": addr } + hosts.append(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) + inventory = "\n".join(hosts) + with open(FILENAME, "w", encoding="utf8") as inv_file: + inv_file.write(inventory + "\n") if __name__ == "__main__": diff --git a/nginx.conf.j2 b/nginx.conf.j2 index ccd68e5..41f3c52 100644 --- a/nginx.conf.j2 +++ b/nginx.conf.j2 @@ -18,7 +18,7 @@ http { server { listen 80 default_server; location / { - return 200 ">>>>>>>>>> I am {{ inventory_hostname }} ({{ ipv4.address }}) <<<<<<<<<<\n"; + return 200 ">>>>>>>>>> I am {{ inventory_hostname }} ({{ ansible_host }}) <<<<<<<<<<\n"; } } }