cli: add ioc *-all commands

This commit is contained in:
Benjamin Labrecque
2026-07-17 09:25:33 +02:00
parent d0d606a67f
commit cd09c99306
2 changed files with 91 additions and 46 deletions
+52 -7
View File
@@ -1,9 +1,7 @@
import sys
import ansible_runner
import typer
from core.ansible import run_playbook
from core.models import ServiceRegistry
from core.utils import get_git_root
ioc = typer.Typer(no_args_is_help=True)
@@ -15,6 +13,8 @@ IOC_PLAYBOOK_INSTALL = ANSIBLE_PLAYBOOKS_DIR / "ioc-install.yml"
IOC_PLAYBOOK_RESTART = ANSIBLE_PLAYBOOKS_DIR / "ioc-restart.yml"
IOC_PLAYBOOK_START = ANSIBLE_PLAYBOOKS_DIR / "ioc-start.yml"
# TODO: make sure dev/prod works correctly for all commands
@ioc.command(no_args_is_help=True)
def install(
@@ -31,6 +31,43 @@ def install(
run_playbook(playbook=str(IOC_PLAYBOOK_INSTALL), vars=[env_var, branch_var, service_name_var])
@ioc.command(no_args_is_help=True)
def install_all(
env: str = typer.Option(..., "--env"),
):
env_var = f"agebd_env={env}"
registry = ServiceRegistry.read_from_config()
services = registry.get_services()
branch_var = f"branch_name=main"
for service in services:
service_name_var = f"service_name_lower={service.name_lower}"
run_playbook(
playbook=str(IOC_PLAYBOOK_INSTALL), vars=[env_var, branch_var, service_name_var]
)
@ioc.command(no_args_is_help=True)
def start(
ioc_port: int = typer.Option(..., "--port", "-p"),
):
ioc_port_var = f"ioc_port={ioc_port}"
run_playbook(playbook=str(IOC_PLAYBOOK_START), vars=[ioc_port_var])
@ioc.command()
def start_all():
registry = ServiceRegistry.read_from_config()
services = registry.get_services()
for service in services:
ioc_port_var = f"ioc_port={service.ioc_port}"
run_playbook(playbook=str(IOC_PLAYBOOK_START), vars=[ioc_port_var])
@ioc.command(no_args_is_help=True)
def restart(
env: str = typer.Option(..., "--env"),
@@ -47,9 +84,17 @@ def restart(
@ioc.command(no_args_is_help=True)
def start(
ioc_port: int = typer.Option(..., "--port", "-p"),
def restart_all(
env: str = typer.Option(..., "--env"),
):
ioc_port_var = f"ioc_port={ioc_port}"
env_var = f"agebd_env={env}"
registry = ServiceRegistry.read_from_config()
services = registry.get_services()
run_playbook(playbook=str(IOC_PLAYBOOK_START), vars=[ioc_port_var])
branch_var = f"branch_name=main"
for service in services:
service_name_var = f"service_name_lower={service.name_lower}"
run_playbook(
playbook=str(IOC_PLAYBOOK_RESTART), vars=[env_var, branch_var, service_name_var]
)