Add pingall and fix env vars

This commit is contained in:
Luke Murphy 2020-04-11 23:18:31 +02:00
parent 58b09694df
commit 1adab407e8
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 7 additions and 5 deletions

View File

@ -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"]

View File

@ -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)