Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_certificate_oftp.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 __metaclass__ = type
7
8 ANSIBLE_METADATA = {'status': ['preview'],
9 'supported_by': 'community',
10 'metadata_version': '1.1'}
11
12 DOCUMENTATION = '''
13 ---
14 module: fmgr_system_certificate_oftp
15 short_description: OFTP certificates and keys.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.partial_crud
20 options:
21 system_certificate_oftp:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 certificate:
27 type: raw
28 description: (list) PEM format certificate.
29 comment:
30 type: str
31 description: OFTP certificate comment.
32 custom:
33 type: str
34 description:
35 - Enable/disable custom certificate.
36 - disable - Disable setting.
37 - enable - Enable setting.
38 choices: ['disable', 'enable']
39 password:
40 type: raw
41 description: (list) Password for encrypted private-key, unset for non-encrypted.
42 private_key:
43 aliases: ['private-key']
44 type: raw
45 description: (list) PEM format private key.
46 local:
47 type: str
48 description: Choose from a local certificates.
49 mode:
50 type: str
51 description:
52 - Mode of certificates used by oftpd.
53 - default - Default mode.
54 - custom - Use custom certificate.
55 - local - Use a local certificate.
56 choices: ['default', 'custom', 'local']
57 '''
58
59 EXAMPLES = '''
60 - name: Example playbook (generated based on argument schema)
61 hosts: fortimanagers
62 connection: httpapi
63 gather_facts: false
64 tasks:
65 - name: OFTP certificates and keys.
66 fortinet.fortimanager.fmgr_system_certificate_oftp:
67 # workspace_locking_adom: <global or your adom name>
68 system_certificate_oftp:
69 # certificate: <list or string>
70 # comment: <string>
71 # custom: <value in [disable, enable]>
72 # password: <list or string>
73 # private_key: <list or string>
74 # local: <string>
75 # mode: <value in [default, custom, local]>
76 '''
77
78 RETURN = '''
79 meta:
80 description: The result of the request.
81 type: dict
82 returned: always
83 contains:
84 request_url:
85 description: The full url requested.
86 returned: always
87 type: str
88 sample: /sys/login/user
89 response_code:
90 description: The status of api request.
91 returned: always
92 type: int
93 sample: 0
94 response_data:
95 description: The api response.
96 type: list
97 returned: always
98 response_message:
99 description: The descriptive message of the api response.
100 type: str
101 returned: always
102 sample: OK.
103 system_information:
104 description: The information of the target system.
105 type: dict
106 returned: always
107 rc:
108 description: The status the request.
109 type: int
110 returned: always
111 sample: 0
112 version_check_warning:
113 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
114 type: list
115 returned: complex
116 '''
117 from ansible.module_utils.basic import AnsibleModule
118 from ansible.module_utils.connection import Connection
119 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
120 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
121
122
123 def main():
124 urls_list = [
125 '/cli/global/system/certificate/oftp'
126 ]
127 module_arg_spec = {
128 'system_certificate_oftp': {
129 'type': 'dict', 'v_range': [['6.0.0', '']],
130 'options': {
131 'certificate': {'type': 'raw'},
132 'comment': {'type': 'str'},
133 'custom': {'v_range': [['6.0.0', '6.2.3'], ['6.4.0', '6.4.0']], 'choices': ['disable', 'enable'], 'type': 'str'},
134 'password': {'no_log': True, 'type': 'raw'},
135 'private-key': {'no_log': True, 'type': 'raw'},
136 'local': {'v_range': [['6.2.5', '6.2.13'], ['6.4.1', '']], 'type': 'str'},
137 'mode': {'v_range': [['6.2.5', '6.2.13'], ['6.4.1', '']], 'choices': ['default', 'custom', 'local'], 'type': 'str'}
138 }
139 }
140 }
141
142 module_option_spec = get_module_arg_spec('partial crud')
143 module_arg_spec.update(module_option_spec)
144 check_galaxy_version(module_arg_spec)
145 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_certificate_oftp'),
146 supports_check_mode=True)
147 if not module._socket_path:
148 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
149 connection = Connection(module._socket_path)
150 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
151 None, 'data', module, connection)
152 fmgr.process_partial_crud()
153 module.exit_json(meta=module.params)
154
155
156 if __name__ == '__main__':
157 main()