Solved different bugs e.g. csp and optimized deploy help

This commit is contained in:
2025-06-04 19:50:11 +02:00
parent 6d857663fb
commit 24cd75ac26
6 changed files with 78 additions and 20 deletions

View File

@@ -5,7 +5,7 @@ import subprocess
import os
import datetime
def run_ansible_playbook(inventory, playbook, modes, limit=None, password_file=None, verbose=0, skip_tests=False):
def run_ansible_playbook(inventory, playbook, modes, limit=None, password_file=None, verbose=0, skip_tests:bool=False):
start_time = datetime.datetime.now()
print(f"\n▶️ Script started at: {start_time.isoformat()}\n")
@@ -44,20 +44,60 @@ def run_ansible_playbook(inventory, playbook, modes, limit=None, password_file=N
def main():
script_dir = os.path.dirname(os.path.realpath(__file__))
parser = argparse.ArgumentParser(description="Run Ansible Playbooks")
parser = argparse.ArgumentParser(
description="Run the central Ansible deployment script to manage infrastructure, updates, and tests."
)
parser.add_argument("inventory", help="Path to the inventory file")
parser.add_argument("--limit", help="Limit execution to a specific server")
parser.add_argument("--host-type", choices=["server", "personal-computer"], default="server")
parser.add_argument("--reset", action="store_true")
parser.add_argument("--test", action="store_true")
parser.add_argument("--update", action="store_true")
parser.add_argument("--backup", action="store_true")
parser.add_argument("--cleanup", action="store_true")
parser.add_argument("--debug", action="store_true")
parser.add_argument("--password-file")
parser.add_argument("--skip-tests", action="store_true")
parser.add_argument("-v", "--verbose", action="count", default=0)
parser.add_argument(
"inventory",
help="Path to the inventory file (INI or YAML) containing hosts and variables."
)
parser.add_argument(
"--limit",
help="Restrict execution to a specific host or host group from the inventory."
)
parser.add_argument(
"--host-type",
choices=["server", "personal-computer"],
default="server",
help="Specify whether the target is a server or a personal computer. Affects role selection and variables."
)
parser.add_argument(
"--reset", action="store_true",
help="Reset all CyMaIS files and configurations, and run the entire playbook (not just individual roles)."
)
parser.add_argument(
"--test", action="store_true",
help="Run test routines instead of production tasks. Useful for local testing and CI pipelines."
)
parser.add_argument(
"--update", action="store_true",
help="Enable the update procedure to bring software and roles up to date."
)
parser.add_argument(
"--backup", action="store_true",
help="Perform a full backup of critical data and configurations before the update process."
)
parser.add_argument(
"--cleanup", action="store_true",
help="Clean up unused files and outdated configurations after all tasks are complete."
)
parser.add_argument(
"--debug", action="store_true",
help="Enable detailed debug output for Ansible and this script."
)
parser.add_argument(
"--password-file",
help="Path to the file containing the Vault password. If not provided, prompts for the password interactively."
)
parser.add_argument(
"--skip-tests", action="store_true",
help="Skip running 'make test' even if tests are normally enabled."
)
parser.add_argument(
"-v", "--verbose", action="count", default=0,
help="Increase verbosity level. Multiple -v flags increase detail (e.g., -vvv for maximum log output)."
)
args = parser.parse_args()