Update config_template to use the builtin _get_remote_user function

This change will ensure the config_template module is able to pull the appropriate
remote use when creating a temp file or directory.

Related-Bug: #1884816
Change-Id: I36b13db4d0b722e7c6c7244ab142003193a56ffe
Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
Kevin Carter 2020-06-25 11:14:46 -05:00 committed by Kevin Carter (cloudnull)
parent 51356b811c
commit 4ed672e399

View File

@ -781,17 +781,18 @@ class ActionModule(ActionBase):
def run(self, tmp=None, task_vars=None):
"""Run the method"""
try:
remote_user = task_vars.get('ansible_user')
if not remote_user:
remote_user = task_vars.get('ansible_ssh_user')
if not remote_user:
remote_user = self._play_context.remote_user
if not tmp:
if not tmp:
try:
remote_user = self._get_remote_user()
except Exception:
remote_user = task_vars.get('ansible_user')
if not remote_user:
remote_user = task_vars.get('ansible_ssh_user')
if not remote_user:
remote_user = self._play_context.remote_user
try:
tmp = self._make_tmp_path(remote_user)
except TypeError:
if not tmp:
except TypeError:
tmp = self._make_tmp_path()
_status, _vars = self._load_options_and_status(task_vars=task_vars)