From 4e38036bbd3e905c877abbf5b2361a0de1c146a8 Mon Sep 17 00:00:00 2001 From: Eric Brown Date: Thu, 5 Apr 2018 13:31:21 -0700 Subject: [PATCH] Replace the hard-coded temp path in gunicorn module (#38349) The gunicorn module has a hard-coded reference to '/tmp' which may or may not be the actual temp directory for an operating system. This patch replaces '/tmp' with module.tmpdir which should resolve to the correct temp directory for the OS. Fixes Issue #36953 Signed-off-by: Eric Brown --- .../modules/web_infrastructure/gunicorn.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/ansible/modules/web_infrastructure/gunicorn.py b/lib/ansible/modules/web_infrastructure/gunicorn.py index 2a2acad619..b209c144a6 100644 --- a/lib/ansible/modules/web_infrastructure/gunicorn.py +++ b/lib/ansible/modules/web_infrastructure/gunicorn.py @@ -130,14 +130,6 @@ def main(): 'user': '-u', } - # temporary files in case no option provided - tmp_error_log = '/tmp/gunicorn.temp.error.log' - tmp_pid_file = '/tmp/gunicorn.temp.pid' - - # remove temp file if exists - remove_tmp_file(tmp_pid_file) - remove_tmp_file(tmp_error_log) - module = AnsibleModule( argument_spec=dict( app=dict(required=True, type='str', aliases=['name']), @@ -153,6 +145,14 @@ def main(): ) ) + # temporary files in case no option provided + tmp_error_log = os.path.join(module.tmpdir, 'gunicorn.temp.error.log') + tmp_pid_file = os.path.join(module.tmpdir, 'gunicorn.temp.pid') + + # remove temp file if exists + remove_tmp_file(tmp_pid_file) + remove_tmp_file(tmp_error_log) + # obtain app name and venv params = module.params app = params['app']