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

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

* add changelog frag

* fix errors
pull/9618/head
Alexei Znamensky 2025-01-24 08:33:38 +13:00 committed by GitHub
parent bf5c7f8be8
commit f5cbf5acc7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 11 deletions

View File

@ -0,0 +1,2 @@
minor_changes:
- apache2_mod_proxy - use ``deps`` to handle dependencies (https://github.com/ansible-collections/community.general/pull/9612).

View File

@ -204,20 +204,14 @@ members:
"""
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\-\=]*)")
@ -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']