feat: generate ansible inventory

This commit is contained in:
Александр Степченко 2023-10-24 12:22:14 +03:00
parent 9471705d84
commit 4af20f91a2

28
main.py
View File

@ -4,6 +4,7 @@ from typing import Callable, List
from time import sleep
from pathlib import Path
import yaml
from proxmoxer import ProxmoxAPI
from functions import clone_template, get_vm_ip
@ -113,7 +114,34 @@ def main():
ofile.write(hosts)
proxmox.logout()
inventory = {
'workers': {
'hosts': {
'worker1': {
'ansible_host': vm_ip_worker1,
'ansible_user': 'root',
},
'worker2': {
'ansible_host': vm_ip_worker2,
'ansible_user': 'root',
},
},
},
'all_vms': {
'hosts': {
'master': {
'ansible_host': vm_ip_master,
'ansible_user': 'root',
},
},
'children': {
'workers'
},
},
}
with open('run/generated_inventory.yaml', 'w') as ofile:
yaml.dump(inventory, ofile)
if __name__ == '__main__':
main()