From af6f481b8d1d00720c765d2ad849f710f311e6eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milio=20Gonzalez?= Date: Wed, 20 Aug 2025 19:38:59 -0400 Subject: [PATCH 1/2] When `--verbose` is checked, increase verbosity of ansible playbooks execution --- ctf/__init__.py | 1 + ctf/__main__.py | 3 ++- ctf/deploy.py | 4 +++- ctf/templates/inventory.j2 | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ctf/__init__.py b/ctf/__init__.py index 352f421..6407ea1 100644 --- a/ctf/__init__.py +++ b/ctf/__init__.py @@ -15,6 +15,7 @@ ENV = {} +state = {"verbose": False} for k, v in os.environ.items(): ENV[k] = v diff --git a/ctf/__main__.py b/ctf/__main__.py index 118025c..27624b5 100644 --- a/ctf/__main__.py +++ b/ctf/__main__.py @@ -6,7 +6,7 @@ from typer import Typer from typing_extensions import Annotated -from ctf import ENV, LOG +from ctf import ENV, LOG, state from ctf.check import app as check_app from ctf.deploy import app as deploy_app from ctf.destroy import app as destroy_app @@ -52,6 +52,7 @@ def global_options( if verbose: LOG.setLevel(logging.DEBUG) LOG.handlers[0].setLevel(logging.DEBUG) + state["verbose"] = True if location: ENV["CTF_ROOT_DIR"] = location diff --git a/ctf/deploy.py b/ctf/deploy.py index 49a7e3f..6c49036 100644 --- a/ctf/deploy.py +++ b/ctf/deploy.py @@ -7,7 +7,7 @@ import typer from typing_extensions import Annotated -from ctf import ENV +from ctf import ENV, state from ctf.destroy import destroy from ctf.generate import generate from ctf.logger import LOG @@ -224,6 +224,8 @@ def deploy( def run_ansible_playbook(remote: str, production: bool, track: str, path: str) -> None: extra_args = [] + if state["verbose"]: + extra_args.append("-vvv") if remote: extra_args += ["-e", f"ansible_incus_remote={remote}"] diff --git a/ctf/templates/inventory.j2 b/ctf/templates/inventory.j2 index bfa674e..aa0d3e4 100644 --- a/ctf/templates/inventory.j2 +++ b/ctf/templates/inventory.j2 @@ -1,7 +1,7 @@ # This YAML file defines all machines that Ansible needs to know about to run playbooks and configure machines. all: hosts: - # The following line defines how this machine will be refered to in ansible scripts. + # The following line defines how this machine will be referred to in ansible scripts. {{ data.name }}: # This one tells ansible that this host is reached using incus, and the name of the machine in incus is `{{ data.name }}`. ansible_incus_host: {{ data.name }} From 4a2fe3501242bf3cea9045a68532161370f7a424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milio=20Gonzalez?= Date: Wed, 20 Aug 2025 20:34:05 -0400 Subject: [PATCH 2/2] rename state to STATE --- ctf/__init__.py | 2 +- ctf/__main__.py | 4 ++-- ctf/deploy.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ctf/__init__.py b/ctf/__init__.py index 6407ea1..245a937 100644 --- a/ctf/__init__.py +++ b/ctf/__init__.py @@ -15,7 +15,7 @@ ENV = {} -state = {"verbose": False} +STATE = {"verbose": False} for k, v in os.environ.items(): ENV[k] = v diff --git a/ctf/__main__.py b/ctf/__main__.py index 27624b5..78e6edd 100644 --- a/ctf/__main__.py +++ b/ctf/__main__.py @@ -6,7 +6,7 @@ from typer import Typer from typing_extensions import Annotated -from ctf import ENV, LOG, state +from ctf import ENV, LOG, STATE from ctf.check import app as check_app from ctf.deploy import app as deploy_app from ctf.destroy import app as destroy_app @@ -52,7 +52,7 @@ def global_options( if verbose: LOG.setLevel(logging.DEBUG) LOG.handlers[0].setLevel(logging.DEBUG) - state["verbose"] = True + STATE["verbose"] = True if location: ENV["CTF_ROOT_DIR"] = location diff --git a/ctf/deploy.py b/ctf/deploy.py index 6c49036..66cb4c9 100644 --- a/ctf/deploy.py +++ b/ctf/deploy.py @@ -7,7 +7,7 @@ import typer from typing_extensions import Annotated -from ctf import ENV, state +from ctf import ENV, STATE from ctf.destroy import destroy from ctf.generate import generate from ctf.logger import LOG @@ -224,7 +224,7 @@ def deploy( def run_ansible_playbook(remote: str, production: bool, track: str, path: str) -> None: extra_args = [] - if state["verbose"]: + if STATE["verbose"]: extra_args.append("-vvv") if remote: extra_args += ["-e", f"ansible_incus_remote={remote}"]