Allow interactive calls
This commit is contained in:
parent
9c692f2335
commit
58b09694df
@ -30,8 +30,9 @@ def run_play(play, env=None):
|
|||||||
"""Run an Ansible playbook."""
|
"""Run an Ansible playbook."""
|
||||||
if env is None:
|
if env is None:
|
||||||
env = environ.copy()
|
env = environ.copy()
|
||||||
|
|
||||||
cmd = [".venv/bin/ansible-playbook", play]
|
cmd = [".venv/bin/ansible-playbook", play]
|
||||||
run(cmd, cwd=INFRA_DIR, env=env)
|
run(cmd, cwd=INFRA_DIR, interactive=True, env=env)
|
||||||
|
|
||||||
|
|
||||||
def get_passwd(path):
|
def get_passwd(path):
|
||||||
|
@ -8,7 +8,7 @@ things here.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from os import chdir
|
from os import chdir
|
||||||
from subprocess import check_output
|
from subprocess import check_output, call
|
||||||
|
|
||||||
from psutil import process_iter
|
from psutil import process_iter
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ from autonomic.logger import log
|
|||||||
from autonomic.yaml import yaml
|
from autonomic.yaml import yaml
|
||||||
|
|
||||||
|
|
||||||
def run(cmd, cwd=None, **kwargs):
|
def run(cmd, cwd=None, interactive=False, **kwargs):
|
||||||
"""Run a system command.
|
"""Run a system command.
|
||||||
|
|
||||||
Please note, all **kwargs will be passed into the check_output command so
|
Please note, all **kwargs will be passed into the check_output command so
|
||||||
@ -27,7 +27,11 @@ def run(cmd, cwd=None, **kwargs):
|
|||||||
if cwd:
|
if cwd:
|
||||||
chdir(cwd)
|
chdir(cwd)
|
||||||
log.info("Changed directory to {}".format(cwd))
|
log.info("Changed directory to {}".format(cwd))
|
||||||
|
|
||||||
log.info("Running {}".format(" ".join(cmd)))
|
log.info("Running {}".format(" ".join(cmd)))
|
||||||
|
|
||||||
|
if interactive:
|
||||||
|
return call(cmd, **kwargs)
|
||||||
return check_output(cmd, **kwargs)
|
return check_output(cmd, **kwargs)
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
msg = "{} failed! Saw {}".format(" ".join(cmd), str(exception))
|
msg = "{} failed! Saw {}".format(" ".join(cmd), str(exception))
|
||||||
@ -90,6 +94,7 @@ def git_status(fpath):
|
|||||||
"""Check if Git reports changes to be committed."""
|
"""Check if Git reports changes to be committed."""
|
||||||
cmd = ["git", "status", "--porcelain"]
|
cmd = ["git", "status", "--porcelain"]
|
||||||
output = run(cmd, cwd=fpath)
|
output = run(cmd, cwd=fpath)
|
||||||
|
|
||||||
if output is not None:
|
if output is not None:
|
||||||
msg = "warning: git reports uncommitted changes in {}".format(fpath)
|
msg = "warning: git reports uncommitted changes in {}".format(fpath)
|
||||||
log.warning(msg)
|
log.warning(msg)
|
||||||
|
Reference in New Issue
Block a user