Merge "Ensure the ansible log file always has a correct UID"
This commit is contained in:
commit
42a10178c7
@ -587,8 +587,9 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None,
|
|||||||
|
|
||||||
env['TRIPLEO_PLAN_NAME'] = plan
|
env['TRIPLEO_PLAN_NAME'] = plan
|
||||||
|
|
||||||
|
get_uid = int(os.getenv('SUDO_UID', os.getuid()))
|
||||||
try:
|
try:
|
||||||
user_pwd = pwd.getpwuid(int(os.getenv('SUDO_UID', os.getuid())))
|
user_pwd = pwd.getpwuid(get_uid)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
home = constants.CLOUD_HOME_DIR
|
home = constants.CLOUD_HOME_DIR
|
||||||
else:
|
else:
|
||||||
@ -685,7 +686,15 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None,
|
|||||||
f.write('{} $@\n'.format(' '.join(runner_config.command)))
|
f.write('{} $@\n'.format(' '.join(runner_config.command)))
|
||||||
os.chmod(command_path, 0o750)
|
os.chmod(command_path, 0o750)
|
||||||
|
|
||||||
status, rc = runner.run()
|
try:
|
||||||
|
status, rc = runner.run()
|
||||||
|
finally:
|
||||||
|
# NOTE(cloudnull): After a playbook executes, ensure the log
|
||||||
|
# file, if it exists, was created with
|
||||||
|
# appropriate ownership.
|
||||||
|
_log_path = r_opts['envvars']['ANSIBLE_LOG_PATH']
|
||||||
|
if os.path.isfile(_log_path):
|
||||||
|
os.chown(_log_path, get_uid, -1)
|
||||||
|
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
err_msg = (
|
err_msg = (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user