mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-03-29 04:23:34 +01:00
solved path bugs in main.py
This commit is contained in:
parent
da8830493f
commit
fe85d4bd37
7
main.py
7
main.py
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import os
|
||||||
|
|
||||||
def run_ansible_vault(action, filename, password_file):
|
def run_ansible_vault(action, filename, password_file):
|
||||||
"""Execute an ansible-vault command with the specified action on a file."""
|
"""Execute an ansible-vault command with the specified action on a file."""
|
||||||
@ -32,6 +33,10 @@ def run_ansible_playbook(inventory:str, playbook:str, modes:[bool], limit:str=No
|
|||||||
subprocess.run(cmd, check=True)
|
subprocess.run(cmd, check=True)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
# Change to script dir to execute all folders relative to their
|
||||||
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
os.chdir(script_dir)
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="CyMaIS Ansible Deployment and Vault Management")
|
parser = argparse.ArgumentParser(description="CyMaIS Ansible Deployment and Vault Management")
|
||||||
subparsers = parser.add_subparsers(dest="command", required=True)
|
subparsers = parser.add_subparsers(dest="command", required=True)
|
||||||
|
|
||||||
@ -72,7 +77,7 @@ def main():
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Use a fixed playbook file "playbook.yml"
|
# Use a fixed playbook file "playbook.yml"
|
||||||
run_ansible_playbook(args.inventory, "playbook.yml", modes, args.limit, args.password_file, args.verbose)
|
run_ansible_playbook(args.inventory, f"{script_dir}/playbook.yml", modes, args.limit, args.password_file, args.verbose)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user