Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_certificate_ca.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_ca
15 short_description: CA certificate.
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_ca:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 ca:
27 type: raw
28 description: (list) CA certificate.
29 comment:
30 type: str
31 description: CA certificate comment.
32 name:
33 type: str
34 description: Name.
35 required: true
36 '''
37
38 EXAMPLES = '''
39 - name: Example playbook
40 hosts: fortimanagers
41 gather_facts: false
42 connection: httpapi
43 vars:
44 ansible_httpapi_use_ssl: true
45 ansible_httpapi_validate_certs: false
46 ansible_httpapi_port: 443
47 tasks:
48 - name: CA certificate.
49 fortinet.fortimanager.fmgr_system_certificate_ca:
50 bypass_validation: true
51 state: present
52 system_certificate_ca:
53 ca: ["need a valid cert"]
54 comment: ansible-comment
55 name: ansible-test-ca
56
57 - name: Gathering fortimanager facts
58 hosts: fortimanagers
59 gather_facts: false
60 connection: httpapi
61 vars:
62 ansible_httpapi_use_ssl: true
63 ansible_httpapi_validate_certs: false
64 ansible_httpapi_port: 443
65 tasks:
66 - name: Retrieve all the CA certificates
67 fortinet.fortimanager.fmgr_fact:
68 facts:
69 selector: "system_certificate_ca"
70 params:
71 ca: "your_value"
72 '''
73
74 RETURN = '''
75 meta:
76 description: The result of the request.
77 type: dict
78 returned: always
79 contains:
80 request_url:
81 description: The full url requested.
82 returned: always
83 type: str
84 sample: /sys/login/user
85 response_code:
86 description: The status of api request.
87 returned: always
88 type: int
89 sample: 0
90 response_data:
91 description: The api response.
92 type: list
93 returned: always
94 response_message:
95 description: The descriptive message of the api response.
96 type: str
97 returned: always
98 sample: OK.
99 system_information:
100 description: The information of the target system.
101 type: dict
102 returned: always
103 rc:
104 description: The status the request.
105 type: int
106 returned: always
107 sample: 0
108 version_check_warning:
109 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
110 type: list
111 returned: complex
112 '''
113 from ansible.module_utils.basic import AnsibleModule
114 from ansible.module_utils.connection import Connection
115 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
116 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
117
118
119 def main():
120 urls_list = [
121 '/cli/global/system/certificate/ca'
122 ]
123 module_arg_spec = {
124 'system_certificate_ca': {
125 'type': 'dict', 'v_range': [['6.0.0', '']],
126 'options': {'ca': {'type': 'raw'}, 'comment': {'type': 'str'}, 'name': {'required': True, 'type': 'str'}}
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_ca'),
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()