refactor: change run/ to tmp/
This commit is contained in:
parent
5ffeba96ed
commit
ffbbf62c7c
21
main.py
21
main.py
@ -1,3 +1,4 @@
|
||||
import os
|
||||
import logging
|
||||
import urllib3
|
||||
from typing import Callable, List
|
||||
@ -112,14 +113,18 @@ def main():
|
||||
vm_ip_worker2 = get_vm_ip(proxmox, node, vm_ids['worker2'])
|
||||
proxmox.logout()
|
||||
|
||||
with open('run/vm_ids' ,'w') as ofile:
|
||||
vm_ids = f'{vm_id_master}\t{vm_names["master"]}\n'
|
||||
vm_ids += f'{vm_id_worker1}\t{vm_names["worker1"]}\n'
|
||||
vm_ids += f'{vm_id_worker2}\t{vm_names["worker2"]}\n'
|
||||
logger.info(vm_ids)
|
||||
ofile.write(vm_ids)
|
||||
tmp_path = './tmp'
|
||||
if not os.path.exists(tmp_path):
|
||||
os.makedirs(tmp_path)
|
||||
|
||||
with open('run/hosts' ,'w') as ofile:
|
||||
with open(f'{tmp_path}/vm_ids' ,'w') as ofile:
|
||||
vm_ids_file = f'{vm_ids["master"]}\t{vm_names["master"]}\n'
|
||||
vm_ids_file += f'{vm_ids["worker1"]}\t{vm_names["worker1"]}\n'
|
||||
vm_ids_file += f'{vm_ids["worker2"]}\t{vm_names["worker2"]}\n'
|
||||
logger.info(vm_ids_file)
|
||||
ofile.write(vm_ids_file)
|
||||
|
||||
with open(f'{tmp_path}/hosts' ,'w') as ofile:
|
||||
hosts = f'{vm_ip_master}\t{vm_names["master"]}\n'
|
||||
hosts += f'{vm_ip_worker1}\t{vm_names["worker1"]}\n'
|
||||
hosts += f'{vm_ip_worker2}\t{vm_names["worker2"]}\n'
|
||||
@ -152,7 +157,7 @@ def main():
|
||||
},
|
||||
}
|
||||
|
||||
with open('run/generated_inventory.yaml', 'w') as ofile:
|
||||
with open(f'{tmp_path}/generated_inventory.yaml', 'w') as ofile:
|
||||
yaml.dump(inventory, ofile)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user