mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-24 14:17:22 +00:00
add pacemaker_resource plugin (#9531)
* Add initial pacemaker resource
* Additional fixes on pacemaker_resource
* Fix up module parameters
* fix doc and lint
* fix group command build
* Apply suggestions for removing status and improve descriptions
* fix cmd builder list
* Apply suggestions and add initial unit tests
* Fix unit tests expected output
* Initial refactor on pacemaker resource
Refactorization on pacemaker_resource to utilize module helpers.
* Apply suggestions and fix up initial unit test
* Apply suggestions from code review
* Fix pep8 format for utils
* Fix unit tests for pacemaker resource
* Add botmeta maintainers for new moduules
* Apply suggestions from code review
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
* Apply unit test suggestion
* Add disable and enable states for pacemaker_resource
* Fix state names and add cli_action for runner
* Remove unnecessary variables
* Fix documentation example playbook
* Fix IP Address for resource_option
* Refactor and remove unnecessary facts
* Apply suggestions from code review
---------
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
(cherry picked from commit 402f725424)
Co-authored-by: Dexter <45038532+munchtoast@users.noreply.github.com>
210 lines
6.7 KiB
YAML
210 lines
6.7 KiB
YAML
# -*- coding: utf-8 -*-
|
|
# Copyright (c) Dexter Le (dextersydney2001@gmail.com)
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
---
|
|
anchors:
|
|
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
|
test_cases:
|
|
- id: test_missing_input
|
|
input: {}
|
|
output:
|
|
failed: true
|
|
msg: "missing required arguments: name"
|
|
- id: test_present_minimal_input_resource_not_exist
|
|
input:
|
|
state: present
|
|
name: virtual-ip
|
|
resource_type:
|
|
resource_name: IPaddr2
|
|
resource_option:
|
|
- "ip=[192.168.2.1]"
|
|
output:
|
|
changed: true
|
|
previous_value:
|
|
value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
|
|
mocks:
|
|
run_command:
|
|
- command: [/testbin/pcs, resource, status, virtual-ip]
|
|
environ: *env-def
|
|
rc: 1
|
|
out: ""
|
|
err: ""
|
|
- command: [/testbin/pcs, resource, create, virtual-ip, IPaddr2, "ip=[192.168.2.1]", --wait=300]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: "Assumed agent name 'ocf:heartbeat:IPaddr2' (deduced from 'IPAddr2')"
|
|
err: ""
|
|
- command: [/testbin/pcs, resource, status, virtual-ip]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
|
|
err: ""
|
|
- id: test_present_minimal_input_resource_exists
|
|
input:
|
|
state: present
|
|
name: virtual-ip
|
|
resource_type:
|
|
resource_name: IPaddr2
|
|
resource_option:
|
|
- "ip=[192.168.2.1]"
|
|
output:
|
|
changed: false
|
|
previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
|
|
value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
|
|
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, create, virtual-ip, IPaddr2, "ip=[192.168.2.1]", --wait=300]
|
|
environ: *env-def
|
|
rc: 1
|
|
out: ""
|
|
err: "Error: 'virtual-ip' already exists\n"
|
|
- command: [/testbin/pcs, resource, status, virtual-ip]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
|
|
err: ""
|
|
- id: test_absent_minimal_input_resource_not_exist
|
|
input:
|
|
state: absent
|
|
name: virtual-ip
|
|
output:
|
|
changed: false
|
|
previous_value:
|
|
value:
|
|
mocks:
|
|
run_command:
|
|
- command: [/testbin/pcs, resource, status, virtual-ip]
|
|
environ: *env-def
|
|
rc: 1
|
|
out: ""
|
|
err: ""
|
|
- command: [/testbin/pcs, resource, remove, virtual-ip]
|
|
environ: *env-def
|
|
rc: 1
|
|
out: ""
|
|
err: "Error: Resource 'virtual-ip' does not exist.\n"
|
|
- command: [/testbin/pcs, resource, status, virtual-ip]
|
|
environ: *env-def
|
|
rc: 1
|
|
out: ""
|
|
err: ""
|
|
- id: test_absent_minimal_input_resource_exists
|
|
input:
|
|
state: absent
|
|
name: virtual-ip
|
|
output:
|
|
changed: true
|
|
previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
|
|
value:
|
|
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, remove, virtual-ip]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: ""
|
|
err: "Attempting to stop: virtual-ip... Stopped\n"
|
|
- command: [/testbin/pcs, resource, status, virtual-ip]
|
|
environ: *env-def
|
|
rc: 1
|
|
out: ""
|
|
err: ""
|
|
- id: test_enabled_minimal_input_resource_not_exists
|
|
input:
|
|
state: enabled
|
|
name: virtual-ip
|
|
output:
|
|
failed: true
|
|
msg: "pcs failed with error (rc=1): bundle/clone/group/resource/tag 'virtual-ip' does not exist"
|
|
mocks:
|
|
run_command:
|
|
- command: [/testbin/pcs, resource, status, virtual-ip]
|
|
environ: *env-def
|
|
rc: 1
|
|
out: ""
|
|
err: ""
|
|
- command: [/testbin/pcs, resource, enable, virtual-ip]
|
|
environ: *env-def
|
|
rc: 1
|
|
out: ""
|
|
err: "bundle/clone/group/resource/tag 'virtual-ip' does not exist"
|
|
- id: test_enabled_minimal_input_resource_exists
|
|
input:
|
|
state: enabled
|
|
name: virtual-ip
|
|
output:
|
|
changed: true
|
|
previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped (disabled)"
|
|
value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Starting"
|
|
mocks:
|
|
run_command:
|
|
- command: [/testbin/pcs, resource, status, virtual-ip]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped (disabled)"
|
|
err: ""
|
|
- command: [/testbin/pcs, resource, enable, virtual-ip]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: ""
|
|
err: ""
|
|
- command: [/testbin/pcs, resource, status, virtual-ip]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Starting"
|
|
err: ""
|
|
- id: test_disable_minimal_input_resource_not_exists
|
|
input:
|
|
state: disabled
|
|
name: virtual-ip
|
|
output:
|
|
failed: true
|
|
msg: "pcs failed with error (rc=1): bundle/clone/group/resource/tag 'virtual-ip' does not exist"
|
|
mocks:
|
|
run_command:
|
|
- command: [/testbin/pcs, resource, status, virtual-ip]
|
|
environ: *env-def
|
|
rc: 1
|
|
out: ""
|
|
err: ""
|
|
- command: [/testbin/pcs, resource, disable, virtual-ip]
|
|
environ: *env-def
|
|
rc: 1
|
|
out: ""
|
|
err: "bundle/clone/group/resource/tag 'virtual-ip' does not exist"
|
|
- id: test_disable_minimal_input_resource_exists
|
|
input:
|
|
state: disabled
|
|
name: virtual-ip
|
|
output:
|
|
changed: true
|
|
previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
|
|
value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped (disabled)"
|
|
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, disable, virtual-ip]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: ""
|
|
err: ""
|
|
- command: [/testbin/pcs, resource, status, virtual-ip]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped (disabled)"
|
|
err: ""
|