disable gitignore, use ini inventory to avoid pyyaml
This commit is contained in:
parent
9cfe1f008f
commit
f0031c427e
3 changed files with 8 additions and 11 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
.venv
|
||||
inventory.yaml
|
15
mkinv
15
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__":
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue