From 1adab407e8a5913f41a5cccee5a831e086c559d8 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 11 Apr 2020 23:18:31 +0200 Subject: [PATCH] Add pingall and fix env vars --- autonomic/command/actions.py | 9 +++++++-- autonomic/infra.py | 3 --- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/autonomic/command/actions.py b/autonomic/command/actions.py index b8e7c8f..6f6bfec 100644 --- a/autonomic/command/actions.py +++ b/autonomic/command/actions.py @@ -5,9 +5,10 @@ from os import environ import click from PyInquirer import prompt -from autonomic.config import ACTIONS_DIR, INFRA_DIR +from autonomic.config import ACTIONS_DIR, INFRA_DIR, PASS_STORE_DIR from autonomic.infra import get_passwd, run_play from autonomic.utils import git_status, qlist +from autonomic.settings import get @click.command() @@ -16,7 +17,11 @@ def actions(ctx): """Run an Ansible action.""" env = environ.copy() - choices = ["addusers", "newhetzner", "rmhetzner", "newdokku"] + env.update({"ANSIBLE_USER": get("username")}) + env.update({"REMOTE_USER": get("username")}) + env.update({"PASSWORD_STORE_DIR": PASS_STORE_DIR}) + + choices = ["addusers", "newhetzner", "rmhetzner", "newdokku", "pingall"] question = qlist("action", "Which Ansible action?", choices,) action = prompt(question)["action"] diff --git a/autonomic/infra.py b/autonomic/infra.py index 1aa7474..23747bb 100644 --- a/autonomic/infra.py +++ b/autonomic/infra.py @@ -28,9 +28,6 @@ def members(flatten=None): def run_play(play, env=None): """Run an Ansible playbook.""" - if env is None: - env = environ.copy() - cmd = [".venv/bin/ansible-playbook", play] run(cmd, cwd=INFRA_DIR, interactive=True, env=env)