Skip to content

Commit

Permalink
[PR #9612/f5cbf5ac backport][stable-10] apache2-mod-proxy: use deps t…
Browse files Browse the repository at this point in the history
…o handle dependencies (#9617)

apache2-mod-proxy: use deps to handle dependencies (#9612)

* apache2-mod-proxy: use deps to handle dependencies

* add changelog frag

* fix errors

(cherry picked from commit f5cbf5a)

Co-authored-by: Alexei Znamensky <[email protected]>
  • Loading branch information
patchback[bot] and russoz authored Jan 23, 2025
1 parent 9490378 commit 13be47c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/9612-apache2-mod-proxy-revamp5.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- apache2_mod_proxy - use ``deps`` to handle dependencies (https://github.com/ansible-collections/community.general/pull/9612).
15 changes: 4 additions & 11 deletions plugins/modules/apache2_mod_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,20 +204,14 @@
"""

import re
import traceback

from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible_collections.community.general.plugins.module_utils import deps
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.urls import fetch_url
from ansible.module_utils.six import iteritems

BEAUTIFUL_SOUP_IMP_ERR = None
try:
with deps.declare("BeautifulSoup"):
from BeautifulSoup import BeautifulSoup
except ImportError:
BEAUTIFUL_SOUP_IMP_ERR = traceback.format_exc()
HAS_BEAUTIFULSOUP = False
else:
HAS_BEAUTIFULSOUP = True

# balancer member attributes extraction regexp:
EXPRESSION = re.compile(r"(b=([\w\.\-]+)&w=(https?|ajp|wss?|ftp|[sf]cgi)://([\w\.\-]+):?(\d*)([/\w\.\-]*)&?[\w\-\=]*)")
Expand Down Expand Up @@ -381,8 +375,7 @@ def main():
supports_check_mode=True
)

if HAS_BEAUTIFULSOUP is False:
module.fail_json(msg=missing_required_lib('BeautifulSoup'), exception=BEAUTIFUL_SOUP_IMP_ERR)
deps.validate(module)

if module.params['state'] is not None:
states = module.params['state']
Expand Down

0 comments on commit 13be47c

Please sign in to comment.