2020-09-22 17:33:59 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
# Copyright: (c) 2020, Matt Martz <matt@sivel.net>
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
module = AnsibleModule(
|
|
|
|
{
|
2020-10-22 21:05:59 +02:00
|
|
|
'required': {
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'required_one_of_one': {},
|
|
|
|
'required_one_of_two': {},
|
|
|
|
'required_by_one': {},
|
|
|
|
'required_by_two': {},
|
|
|
|
'required_by_three': {},
|
2020-09-22 17:33:59 +02:00
|
|
|
'state': {
|
|
|
|
'type': 'str',
|
|
|
|
'choices': ['absent', 'present'],
|
|
|
|
},
|
|
|
|
'path': {},
|
|
|
|
'content': {},
|
2020-09-30 15:56:27 +02:00
|
|
|
'mapping': {
|
|
|
|
'type': 'dict',
|
|
|
|
},
|
2020-10-22 21:05:59 +02:00
|
|
|
'required_one_of': {
|
|
|
|
'required_one_of': [['thing', 'other']],
|
|
|
|
'type': 'list',
|
|
|
|
'elements': 'dict',
|
|
|
|
'options': {
|
|
|
|
'thing': {},
|
|
|
|
'other': {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'required_by': {
|
|
|
|
'required_by': {'thing': 'other'},
|
|
|
|
'type': 'list',
|
|
|
|
'elements': 'dict',
|
|
|
|
'options': {
|
|
|
|
'thing': {},
|
|
|
|
'other': {},
|
|
|
|
},
|
|
|
|
},
|
2020-09-30 22:38:12 +02:00
|
|
|
'required_together': {
|
|
|
|
'required_together': [['thing', 'other']],
|
|
|
|
'type': 'list',
|
|
|
|
'elements': 'dict',
|
|
|
|
'options': {
|
|
|
|
'thing': {},
|
|
|
|
'other': {},
|
|
|
|
'another': {},
|
2020-10-06 20:15:02 +02:00
|
|
|
},
|
2020-09-30 22:38:12 +02:00
|
|
|
},
|
|
|
|
'required_if': {
|
|
|
|
'required_if': (
|
|
|
|
('thing', 'foo', ('other',), True),
|
|
|
|
),
|
|
|
|
'type': 'list',
|
|
|
|
'elements': 'dict',
|
|
|
|
'options': {
|
|
|
|
'thing': {},
|
|
|
|
'other': {},
|
|
|
|
'another': {},
|
2020-10-06 20:15:02 +02:00
|
|
|
},
|
2020-09-30 22:38:12 +02:00
|
|
|
},
|
2020-10-02 21:53:09 +02:00
|
|
|
'json': {
|
|
|
|
'type': 'json',
|
|
|
|
},
|
|
|
|
'fail_on_missing_params': {
|
|
|
|
'type': 'list',
|
|
|
|
'default': [],
|
|
|
|
},
|
|
|
|
'needed_param': {},
|
2020-10-05 23:02:11 +02:00
|
|
|
'required_together_one': {},
|
|
|
|
'required_together_two': {},
|
2020-10-06 20:15:02 +02:00
|
|
|
'suboptions_list_no_elements': {
|
|
|
|
'type': 'list',
|
|
|
|
'options': {
|
|
|
|
'thing': {},
|
|
|
|
},
|
|
|
|
},
|
2020-10-06 23:00:28 +02:00
|
|
|
'choices_with_strings_like_bools': {
|
|
|
|
'type': 'str',
|
|
|
|
'choices': [
|
|
|
|
'on',
|
|
|
|
'off',
|
|
|
|
],
|
|
|
|
},
|
2020-11-02 17:35:13 +01:00
|
|
|
'choices': {
|
|
|
|
'type': 'str',
|
|
|
|
'choices': [
|
|
|
|
'foo',
|
|
|
|
'bar',
|
|
|
|
],
|
2020-11-06 15:41:41 +01:00
|
|
|
},
|
|
|
|
'list_choices': {
|
|
|
|
'type': 'list',
|
|
|
|
'choices': [
|
|
|
|
'foo',
|
|
|
|
'bar',
|
|
|
|
'baz',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
'primary': {
|
|
|
|
'type': 'str',
|
|
|
|
'aliases': [
|
|
|
|
'alias',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
'password': {
|
|
|
|
'type': 'str',
|
|
|
|
'no_log': True,
|
|
|
|
},
|
|
|
|
'not_a_password': {
|
|
|
|
'type': 'str',
|
|
|
|
'no_log': False,
|
|
|
|
},
|
|
|
|
'maybe_password': {
|
|
|
|
'type': 'str',
|
|
|
|
},
|
|
|
|
'int': {
|
|
|
|
'type': 'int',
|
|
|
|
},
|
2020-09-22 17:33:59 +02:00
|
|
|
},
|
|
|
|
required_if=(
|
|
|
|
('state', 'present', ('path', 'content'), True),
|
|
|
|
),
|
|
|
|
mutually_exclusive=(
|
|
|
|
('path', 'content'),
|
|
|
|
),
|
2020-10-22 21:05:59 +02:00
|
|
|
required_one_of=(
|
|
|
|
('required_one_of_one', 'required_one_of_two'),
|
|
|
|
),
|
|
|
|
required_by={
|
|
|
|
'required_by_one': ('required_by_two', 'required_by_three'),
|
|
|
|
},
|
2020-10-05 23:02:11 +02:00
|
|
|
required_together=(
|
|
|
|
('required_together_one', 'required_together_two'),
|
|
|
|
),
|
2020-09-22 17:33:59 +02:00
|
|
|
)
|
|
|
|
|
2020-10-02 21:53:09 +02:00
|
|
|
module.fail_on_missing_params(module.params['fail_on_missing_params'])
|
|
|
|
|
2020-09-22 17:33:59 +02:00
|
|
|
module.exit_json(**module.params)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|