mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-03 04:34:24 -07:00
Merge a7087fdee0
into 84b5d38c51
This commit is contained in:
commit
10bc477c08
3 changed files with 102 additions and 8 deletions
|
@ -99,6 +99,13 @@ class PacemakerCluster(StateModuleHelper):
|
||||||
self.vars.set('previous_value', self._get()['out'])
|
self.vars.set('previous_value', self._get()['out'])
|
||||||
self.vars.set('value', self.vars.previous_value, change=True, diff=True)
|
self.vars.set('value', self.vars.previous_value, change=True, diff=True)
|
||||||
|
|
||||||
|
if self.module.params['state'] == "cleanup":
|
||||||
|
self.module.deprecate(
|
||||||
|
'The value `cleanup` for "state" is being deprecated',
|
||||||
|
version='12.0.0',
|
||||||
|
collection_name='community.general'
|
||||||
|
)
|
||||||
|
|
||||||
if not self.module.params['state']:
|
if not self.module.params['state']:
|
||||||
self.module.deprecate(
|
self.module.deprecate(
|
||||||
'Parameter "state" values not set is being deprecated. Make sure to provide a value for "state"',
|
'Parameter "state" values not set is being deprecated. Make sure to provide a value for "state"',
|
||||||
|
|
|
@ -27,13 +27,14 @@ options:
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Indicate desired state for cluster resource.
|
- Indicate desired state for cluster resource.
|
||||||
choices: [present, absent, enabled, disabled]
|
- The state V(cleanup) has been added in community.general 12.0.0.
|
||||||
default: present
|
choices: [present, absent, enabled, disabled, cleanup]
|
||||||
|
required: true
|
||||||
type: str
|
type: str
|
||||||
name:
|
name:
|
||||||
description:
|
description:
|
||||||
- Specify the resource name to create.
|
- Specify the resource name to create.
|
||||||
required: true
|
- This is required if O(state=present), O(state=absent), O(state=enabled), or O(state=disabled).
|
||||||
type: str
|
type: str
|
||||||
resource_type:
|
resource_type:
|
||||||
description:
|
description:
|
||||||
|
@ -140,9 +141,9 @@ from ansible_collections.community.general.plugins.module_utils.pacemaker import
|
||||||
class PacemakerResource(StateModuleHelper):
|
class PacemakerResource(StateModuleHelper):
|
||||||
module = dict(
|
module = dict(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
state=dict(type='str', default='present', choices=[
|
state=dict(type='str', required=True, choices=[
|
||||||
'present', 'absent', 'enabled', 'disabled']),
|
'present', 'absent', 'enabled', 'disabled', 'cleanup']),
|
||||||
name=dict(type='str', required=True),
|
name=dict(type='str'),
|
||||||
resource_type=dict(type='dict', options=dict(
|
resource_type=dict(type='dict', options=dict(
|
||||||
resource_name=dict(type='str'),
|
resource_name=dict(type='str'),
|
||||||
resource_standard=dict(type='str'),
|
resource_standard=dict(type='str'),
|
||||||
|
@ -160,7 +161,13 @@ class PacemakerResource(StateModuleHelper):
|
||||||
)),
|
)),
|
||||||
wait=dict(type='int', default=300),
|
wait=dict(type='int', default=300),
|
||||||
),
|
),
|
||||||
required_if=[('state', 'present', ['resource_type', 'resource_option'])],
|
required_if=[
|
||||||
|
('state', 'present', ['resource_type', 'resource_option', 'name']),
|
||||||
|
('state', 'absent', ['name']),
|
||||||
|
('state', 'enabled', ['name']),
|
||||||
|
('state', 'disabled', ['name']),
|
||||||
|
('state', ['present', 'absent', 'enabled', 'disabled'], ['name']),
|
||||||
|
],
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -208,6 +215,13 @@ class PacemakerResource(StateModuleHelper):
|
||||||
with self.runner('cli_action state name', output_process=self._process_command_output(True, "Stopped"), check_mode_skip=True) as ctx:
|
with self.runner('cli_action state name', output_process=self._process_command_output(True, "Stopped"), check_mode_skip=True) as ctx:
|
||||||
ctx.run(cli_action='resource')
|
ctx.run(cli_action='resource')
|
||||||
|
|
||||||
|
def state_cleanup(self):
|
||||||
|
runner_args = ['cli_action', 'state']
|
||||||
|
if self.module.params['name']:
|
||||||
|
runner_args.append('name')
|
||||||
|
with self.runner(runner_args, output_process=self._process_command_output(True, "Clean"), check_mode_skip=True) as ctx:
|
||||||
|
ctx.run(cli_action='resource')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
PacemakerResource.execute()
|
PacemakerResource.execute()
|
||||||
|
|
|
@ -11,7 +11,7 @@ test_cases:
|
||||||
input: {}
|
input: {}
|
||||||
output:
|
output:
|
||||||
failed: true
|
failed: true
|
||||||
msg: "missing required arguments: name"
|
msg: "missing required arguments: state"
|
||||||
- id: test_present_minimal_input_resource_not_exist
|
- id: test_present_minimal_input_resource_not_exist
|
||||||
input:
|
input:
|
||||||
state: present
|
state: present
|
||||||
|
@ -381,3 +381,76 @@ test_cases:
|
||||||
rc: 0
|
rc: 0
|
||||||
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped (disabled)"
|
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped (disabled)"
|
||||||
err: ""
|
err: ""
|
||||||
|
- id: test_cleanup_minimal_input_initial_resources_not_exist
|
||||||
|
input:
|
||||||
|
state: cleanup
|
||||||
|
output:
|
||||||
|
changed: false
|
||||||
|
previous_value: "NO resources configured"
|
||||||
|
value: "NO resources configured"
|
||||||
|
mocks:
|
||||||
|
run_command:
|
||||||
|
- command: [/testbin/pcs, resource, status]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: "NO resources configured"
|
||||||
|
err: ""
|
||||||
|
- command: [/testbin/pcs, resource, cleanup]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: "Cleaned up all resources on all nodes"
|
||||||
|
err: ""
|
||||||
|
- command: [/testbin/pcs, resource, status]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: "NO resources configured"
|
||||||
|
err: ""
|
||||||
|
- id: test_cleanup_minimal_input_initial_resources_exists
|
||||||
|
input:
|
||||||
|
state: cleanup
|
||||||
|
output:
|
||||||
|
changed: true
|
||||||
|
previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
|
||||||
|
value: "NO resources configured"
|
||||||
|
mocks:
|
||||||
|
run_command:
|
||||||
|
- command: [/testbin/pcs, resource, status]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
|
||||||
|
err: ""
|
||||||
|
- command: [/testbin/pcs, resource, cleanup]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: "Cleaned up all resources on all nodes"
|
||||||
|
err: ""
|
||||||
|
- command: [/testbin/pcs, resource, status]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: "NO resources configured"
|
||||||
|
err: ""
|
||||||
|
- id: test_cleanup_specific_minimal_input_initial_resources_exists
|
||||||
|
input:
|
||||||
|
state: cleanup
|
||||||
|
name: virtual-ip
|
||||||
|
output:
|
||||||
|
changed: true
|
||||||
|
previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
|
||||||
|
value: "NO resources configured"
|
||||||
|
mocks:
|
||||||
|
run_command:
|
||||||
|
- command: [/testbin/pcs, resource, status, virtual-ip]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
|
||||||
|
err: ""
|
||||||
|
- command: [/testbin/pcs, resource, cleanup, virtual-ip]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: "Cleaned up virtual-ip on X"
|
||||||
|
err: ""
|
||||||
|
- command: [/testbin/pcs, resource, status, virtual-ip]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: "NO resources configured"
|
||||||
|
err: ""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue