-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
291 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/python | ||
from __future__ import annotations | ||
|
||
from ansible.module_utils.common.arg_spec import ArgumentSpecValidator | ||
import sys | ||
|
||
class PVECM: | ||
def __init__(self, command, module): | ||
self.command = command | ||
self.module = module | ||
|
||
def argument_spec(self): | ||
argument_spec = dict() | ||
|
||
|
||
|
||
@staticmethod | ||
def arg_spec_link(): | ||
link_args = dict() | ||
|
||
for n in range(8): | ||
link_args[f'link{n}'] = dict(type='dict', required=False, default=None, options=dict( | ||
address=dict(type='str', required=False, default=None), | ||
priority=dict(type='int', required=False, default=None), | ||
)) | ||
|
||
return link_args | ||
|
||
def add (module, **parameters): | ||
link_options = dict( | ||
address = dict(type='str', required=False, default=None), | ||
priority = dict(type='int', required=False, default=None), | ||
) | ||
argument_spec = dict( | ||
hostname=dict(type='str', required=True), | ||
fingerprint=dict(type='str', required=False, default=None), | ||
force=dict(type='bool', required=False, default=False), | ||
link0=dict(type='dict', required=False, default=None, options=link_options), | ||
link1=dict(type='dict', required=False, default=None, options=link_options), | ||
link2=dict(type='dict', required=False, default=None, options=link_options), | ||
link3=dict(type='dict', required=False, default=None, options=link_options), | ||
link4=dict(type='dict', required=False, default=None, options=link_options), | ||
link5=dict(type='dict', required=False, default=None, options=link_options), | ||
link6=dict(type='dict', required=False, default=None, options=link_options), | ||
link7=dict(type='dict', required=False, default=None, options=link_options), | ||
nodeid=dict(type='int', required=False, default=None), | ||
use_ssh=dict(type='bool', required=False, default=False), | ||
votes=dict(type='int', required=False, default=None), | ||
) | ||
|
||
validator = ArgumentSpecValidator(argument_spec) | ||
result = validator.validate(parameters) | ||
|
||
if result.error_messages: | ||
sys.exit("Validation failed: {0}".format(", ".join(result.error_messages))) | ||
|
||
valid_params = result.validated_parameters | ||
|
||
def status(module): | ||
return module.run_command(['pvecm', 'status']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/python | ||
|
||
from ansible.module_utils.basic import AnsibleModule | ||
import ansible_collections.aybarsm.linux.plugins.module_utils.pvecm as pvecm | ||
|
||
def main(): | ||
module = AnsibleModule( | ||
argument_spec = dict( | ||
command=dict(type='str', required=True, choices=['add', 'status']), | ||
), | ||
supports_check_mode=False | ||
) | ||
|
||
rc, out, err = pvecm.status(module) | ||
|
||
result = {"changed": False} | ||
result['response'] = {'stdout': out, 'stderr': err, 'rc': rc} | ||
|
||
module.exit_json(**result) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/python | ||
|
||
from ansible.module_utils.basic import AnsibleModule | ||
# import ansible_collections.aybarsm.linux.plugins.module_utils.pvecm as pvecm | ||
|
||
def main(): | ||
module = AnsibleModule( | ||
argument_spec = dict( | ||
command=dict(type='str', required=True, choices=['create', 'delete', 'get', 'ls', 'set']), | ||
path=dict(type='str', required=True), | ||
noproxy=dict(type='bool', required=False, default=False), | ||
human_readable=dict(type='bool', required=False, default=False), | ||
noborder=dict(type='bool', required=False, default=False), | ||
noheader=dict(type='bool', required=False, default=False), | ||
output_format=dict(type='str', required=False, default='json', choices=['json', 'json-pretty', 'text', 'yaml']), | ||
), | ||
supports_check_mode=False | ||
) | ||
|
||
# rc, out, err = pvecm.status(module) | ||
|
||
result = {"changed": False} | ||
result['response'] = locals() | ||
|
||
module.exit_json(**result) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/python | ||
|
||
from ansible.module_utils.basic import AnsibleModule | ||
# import ansible_collections.aybarsm.linux.plugins.module_utils.pvecm as pvecm | ||
|
||
def main(): | ||
module = AnsibleModule( | ||
argument_spec = dict( | ||
path=dict(type='path', required=True), | ||
options=dict(type='dict', required=False), | ||
noproxy=dict(type='bool', required=False, default=False), | ||
human_readable=dict(type='bool', required=False, default=False), | ||
noborder=dict(type='bool', required=False, default=False), | ||
noheader=dict(type='bool', required=False, default=False), | ||
output_format=dict(type='str', required=False, default='json', choices=['json', 'json-pretty', 'text', 'yaml']), | ||
), | ||
supports_check_mode=True | ||
) | ||
|
||
# rc, out, err = pvecm.status(module) | ||
|
||
result = {"changed": False} | ||
result['response'] = module.params | ||
|
||
module.exit_json(**result) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,4 +44,3 @@ | |
when: | ||
- auth__users_all | type_debug == 'list' | ||
- auth__users_all | length > 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.