Skip to content

Commit

Permalink
apache2-mod-proxy: make state option a list (#9600)
Browse files Browse the repository at this point in the history
* apache2-mod-proxy: make state option a list

* add changelog frag

* Update plugins/modules/apache2_mod_proxy.py

* Update changelogs/fragments/9600-apache2-mod-proxy-revamp2.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit a4562bc)
  • Loading branch information
russoz authored and patchback[bot] committed Jan 23, 2025
1 parent dbd19a5 commit 8bbf156
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/9600-apache2-mod-proxy-revamp2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- apache2_mod_proxy - change type of ``state`` to a list of strings. No change for the users (https://github.com/ansible-collections/community.general/pull/9600).
21 changes: 9 additions & 12 deletions plugins/modules/apache2_mod_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@
be specified here. If undefined, apache2_mod_proxy module will return a members list of dictionaries of all the current
balancer pool members' attributes.
state:
type: str
type: list
elements: str
choices: [present, absent, enabled, disabled, drained, hot_standby, ignore_errors]
description:
- Desired state of the member host. (absent|disabled),drained,hot_standby,ignore_errors can be simultaneously invoked
by separating them with a comma (for example V(state=drained,ignore_errors)).
- 'Accepted state values: [V(present), V(absent), V(enabled), V(disabled), V(drained), V(hot_standby), V(ignore_errors)].'
- Desired state of the member host.
- States can be simultaneously invoked by separating them with a comma (for example V(state=drained,ignore_errors)),
but it is recommended to specify them as a proper YAML list.
- States V(present) and V(absent) must be used without any other state.
tls:
description:
- Use https to access balancer management page.
Expand Down Expand Up @@ -369,7 +372,7 @@ def main():
balancer_vhost=dict(required=True, type='str'),
balancer_url_suffix=dict(default="/balancer-manager/", type='str'),
member_host=dict(type='str'),
state=dict(type='str'),
state=dict(type='list', elements='str', choices=['present', 'absent', 'enabled', 'disabled', 'drained', 'hot_standby', 'ignore_errors']),
tls=dict(default=False, type='bool'),
validate_certs=dict(default=True, type='bool')
),
Expand All @@ -380,15 +383,9 @@ def main():
module.fail_json(msg=missing_required_lib('BeautifulSoup'), exception=BEAUTIFUL_SOUP_IMP_ERR)

if module.params['state'] is not None:
states = module.params['state'].split(',')
states = module.params['state']
if (len(states) > 1) and (("present" in states) or ("enabled" in states)):
module.fail_json(msg="state present/enabled is mutually exclusive with other states!")
else:
for _state in states:
if _state not in ['present', 'absent', 'enabled', 'disabled', 'drained', 'hot_standby', 'ignore_errors']:
module.fail_json(
msg="State can only take values amongst 'present', 'absent', 'enabled', 'disabled', 'drained', 'hot_standby', 'ignore_errors'."
)
else:
states = ['None']

Expand Down

0 comments on commit 8bbf156

Please sign in to comment.