This commit is contained in:
@@ -4,6 +4,7 @@ import sys
|
||||
import ansible_runner
|
||||
import typer
|
||||
|
||||
from core.enums import IOC_ENV
|
||||
from core.utils import get_git_root
|
||||
|
||||
ioc = typer.Typer(no_args_is_help=True)
|
||||
@@ -11,7 +12,11 @@ ioc = typer.Typer(no_args_is_help=True)
|
||||
REPO_ROOT = get_git_root(__file__)
|
||||
|
||||
|
||||
def run_playbook(playbook: str, vars: list[str]):
|
||||
def run_playbook(playbook: str, env: IOC_ENV, vars: list[str]):
|
||||
env_str = str(env)
|
||||
if env_str not in ["dev", "prod"]:
|
||||
raise ValueError("env must be 'dev' or 'prod'")
|
||||
|
||||
current_env = os.environ.copy()
|
||||
current_env["ANSIBLE_CONFIG"] = f"{REPO_ROOT}/ansible/ansible.cfg"
|
||||
|
||||
@@ -21,7 +26,7 @@ def run_playbook(playbook: str, vars: list[str]):
|
||||
cmdline_args=[
|
||||
playbook,
|
||||
"-i",
|
||||
f"{REPO_ROOT}/ansible/hosts.yml",
|
||||
f"{REPO_ROOT}/ansible/inventories/{env_str}/hosts.yml",
|
||||
*extra_vars,
|
||||
"-v",
|
||||
],
|
||||
|
||||
+10
-1
@@ -3,4 +3,13 @@ from enum import Enum
|
||||
|
||||
class ServiceStatus(str, Enum):
|
||||
ACTIVE = "active"
|
||||
DISABLED = "disabled"
|
||||
DISABLED = "disabled"
|
||||
|
||||
|
||||
class IOC_ENV(str, Enum):
|
||||
PROD = "prod"
|
||||
DEV = "dev"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.value
|
||||
|
||||
|
||||
Reference in New Issue
Block a user