Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_certificate_local.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_local
15 short_description: Local keys and certificates.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 system_certificate_local:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 certificate:
27 type: raw
28 description: (list) Certificate.
29 comment:
30 type: str
31 description: Local certificate comment.
32 csr:
33 type: raw
34 description: (list) Certificate Signing Request.
35 name:
36 type: str
37 description: Name of local certificate.
38 required: true
39 password:
40 type: raw
41 description: (list) Local certificate password.
42 private_key:
43 aliases: ['private-key']
44 type: raw
45 description: (list) Local certificate private-key.
46 '''
47
48 EXAMPLES = '''
49 - name: Example playbook (generated based on argument schema)
50 hosts: fortimanagers
51 connection: httpapi
52 gather_facts: false
53 tasks:
54 - name: Local keys and certificates.
55 fortinet.fortimanager.fmgr_system_certificate_local:
56 # workspace_locking_adom: <global or your adom name>
57 state: present # <value in [present, absent]>
58 system_certificate_local:
59 name: "your value" # Required variable, string
60 # certificate: <list or string>
61 # comment: <string>
62 # csr: <list or string>
63 # password: <list or string>
64 # private_key: <list or string>
65 '''
66
67 RETURN = '''
68 meta:
69 description: The result of the request.
70 type: dict
71 returned: always
72 contains:
73 request_url:
74 description: The full url requested.
75 returned: always
76 type: str
77 sample: /sys/login/user
78 response_code:
79 description: The status of api request.
80 returned: always
81 type: int
82 sample: 0
83 response_data:
84 description: The api response.
85 type: list
86 returned: always
87 response_message:
88 description: The descriptive message of the api response.
89 type: str
90 returned: always
91 sample: OK.
92 system_information:
93 description: The information of the target system.
94 type: dict
95 returned: always
96 rc:
97 description: The status the request.
98 type: int
99 returned: always
100 sample: 0
101 version_check_warning:
102 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
103 type: list
104 returned: complex
105 '''
106 from ansible.module_utils.basic import AnsibleModule
107 from ansible.module_utils.connection import Connection
108 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
109 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
110
111
112 def main():
113 urls_list = [
114 '/cli/global/system/certificate/local'
115 ]
116 module_arg_spec = {
117 'system_certificate_local': {
118 'type': 'dict', 'v_range': [['6.0.0', '']],
119 'options': {
120 'certificate': {'type': 'raw'},
121 'comment': {'type': 'str'},
122 'csr': {'type': 'raw'},
123 'name': {'required': True, 'type': 'str'},
124 'password': {'no_log': True, 'type': 'raw'},
125 'private-key': {'no_log': True, 'type': 'raw'}
126 }
127 }
128 }
129
130 module_option_spec = get_module_arg_spec('full crud')
131 module_arg_spec.update(module_option_spec)
132 check_galaxy_version(module_arg_spec)
133 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_certificate_local'),
134 supports_check_mode=True)
135 if not module._socket_path:
136 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
137 connection = Connection(module._socket_path)
138 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
139 'name', 'data', module, connection)
140 fmgr.process_crud()
141 module.exit_json(meta=module.params)
142
143
144 if __name__ == '__main__':
145 main()