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']