From 549dfaae6415999755f2ca722b39e8c314c67aa1 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Wed, 28 Jul 2021 18:43:09 +1200 Subject: [PATCH] gunicorn - minor refactoring (#3092) * minor refactoring in gunicorn module * added changelog fragment * reworked the gunicorn bin path part of the code, per PR * Update changelogs/fragments/3092-gunicorn-refactor.yaml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- .../fragments/3092-gunicorn-refactor.yaml | 2 ++ .../modules/web_infrastructure/gunicorn.py | 19 +++++++------------ 2 files changed, 9 insertions(+), 12 deletions(-) create mode 100644 changelogs/fragments/3092-gunicorn-refactor.yaml diff --git a/changelogs/fragments/3092-gunicorn-refactor.yaml b/changelogs/fragments/3092-gunicorn-refactor.yaml new file mode 100644 index 0000000000..114e865add --- /dev/null +++ b/changelogs/fragments/3092-gunicorn-refactor.yaml @@ -0,0 +1,2 @@ +minor_changes: + - gunicorn - search for ``gunicorn`` binary in more paths (https://github.com/ansible-collections/community.general/pull/3092). diff --git a/plugins/modules/web_infrastructure/gunicorn.py b/plugins/modules/web_infrastructure/gunicorn.py index 5703055623..4c9e5da45b 100644 --- a/plugins/modules/web_infrastructure/gunicorn.py +++ b/plugins/modules/web_infrastructure/gunicorn.py @@ -101,14 +101,12 @@ gunicorn: import os import time -# import ansible utils from ansible.module_utils.basic import AnsibleModule def search_existing_config(config, option): ''' search in config file for specified option ''' if config and os.path.isfile(config): - data_config = None with open(config, 'r') as f: for line in f: if option in line: @@ -135,15 +133,12 @@ def main(): module = AnsibleModule( argument_spec=dict( app=dict(required=True, type='str', aliases=['name']), - venv=dict(required=False, type='path', default=None, aliases=['virtualenv']), - config=dict(required=False, default=None, type='path', aliases=['conf']), - chdir=dict(required=False, type='path', default=None), - pid=dict(required=False, type='path', default=None), - user=dict(required=False, type='str'), - worker=dict(required=False, - type='str', - choices=['sync', 'eventlet', 'gevent', 'tornado ', 'gthread', 'gaiohttp'] - ), + venv=dict(type='path', aliases=['virtualenv']), + config=dict(type='path', aliases=['conf']), + chdir=dict(type='path'), + pid=dict(type='path'), + user=dict(type='str'), + worker=dict(type='str', choices=['sync', 'eventlet', 'gevent', 'tornado ', 'gthread', 'gaiohttp']), ) ) @@ -165,7 +160,7 @@ def main(): if venv: gunicorn_command = "/".join((venv, 'bin', 'gunicorn')) else: - gunicorn_command = 'gunicorn' + gunicorn_command = module.get_bin_path('gunicorn') # to daemonize the process options = ["-D"]