diff --git a/alakazam.py b/alakazam.py index 7e3fa28..18c23d9 100755 --- a/alakazam.py +++ b/alakazam.py @@ -43,11 +43,11 @@ def abra(*args, machine_output=False, ignore_error=False): process = subprocess.run(command, capture_output=True) if process.stderr: logging.debug(process.stderr.decode()) + if process.stdout: + logging.debug(process.stdout.decode()) if process.returncode and not ignore_error: raise RuntimeError( f'{" ".join(command)} \n STDOUT: \n {process.stdout.decode()} \n STDERR: {process.stderr.decode()}') - if process.stderr: - logging.error(process.stderr.decode()) if machine_output: return json.loads(process.stdout.decode()) return process.stdout.decode() @@ -160,7 +160,7 @@ def get_generated_secret(domain, secret_name): secret = secret.splitlines()[3].split("|")[2].strip() else: secret = abra( - "app", "run", domain, "app", f"cat /var/run/secrets/{secret_name}" + "app", "run", domain, "worker", "cat", f"/var/run/secrets/{secret_name}" ) return secret @@ -203,6 +203,7 @@ def execute_cmds(app): for cmd in all_cmds: container = cmd.split()[0] cmd = cmd.split()[1] + logging.info(f"Run '{cmd}' in {domain}:{container}") if container == "local": print(abra("app", "cmd", "--local", domain, cmd, ignore_error=True)) else: @@ -268,7 +269,7 @@ def deploy_apps(apps): deployed_domains = get_deployed_apps() for app in INSTANCE["apps"]: domain = map_subdomain(app) - if (apps and app in apps) or domain not in deployed_domains: + if (apps and app in apps) or (not apps and domain not in deployed_domains): print(f'deploy {domain}') print(abra("app", "deploy", "-C", "-n", domain)) logging.info(f'execute commands for {domain}') @@ -304,20 +305,26 @@ def cmds(apps): @cli.command() -def purge_apps(): +@click.option('-a', '--apps', multiple=True) +def purge_apps(apps): """ Completely remove all the apps """ - for recipe in INSTANCE["apps"]: - domain = map_subdomain(recipe) + if not apps: + apps = INSTANCE["apps"] + for app in apps: + domain = map_subdomain(app) logging.info(f'purge {domain}') abra("app", "rm", "-n", domain) print(f"{domain} purged") @cli.command() -def purge_secrets(): +@click.option('-a', '--apps', multiple=True) +def purge_secrets(apps): """ Remove all the apps secrets """ - for recipe in INSTANCE["apps"]: - domain = map_subdomain(recipe) + if not apps: + apps = INSTANCE["apps"] + for app in apps: + domain = map_subdomain(app) logging.info(f'purge secrets from {domain}') stored_secrets = abra("app", "secret", "ls", domain) if "true" in stored_secrets: diff --git a/combine.yml b/combine.yml index e5e1662..fbd544f 100644 --- a/combine.yml +++ b/combine.yml @@ -67,6 +67,11 @@ nextcloud: - SECRET_ONLYOFFICE_JWT_VERSION execute: - app install_onlyoffice + collabora: + uncomment: + - COLLABORA_URL + execute: + - app install_collabora onlyoffice: nextcloud: uncomment: