Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_ntp_ntpserver.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_ntp_ntpserver
15 short_description: NTP server.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 system_ntp_ntpserver:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 authentication:
27 type: str
28 description:
29 - Enable/disable MD5 authentication.
30 - disable - Disable setting.
31 - enable - Enable setting.
32 choices: ['disable', 'enable']
33 id:
34 type: int
35 description: Time server ID.
36 required: true
37 key:
38 type: raw
39 description: (list) Key for authentication.
40 key_id:
41 aliases: ['key-id']
42 type: int
43 description: Key ID for authentication.
44 ntpv3:
45 type: str
46 description:
47 - Enable/disable NTPv3.
48 - disable - Disable setting.
49 - enable - Enable setting.
50 choices: ['disable', 'enable']
51 server:
52 type: str
53 description: IP address/hostname of NTP Server.
54 maxpoll:
55 type: int
56 description: Maximum poll interval in seconds as power of 2
57 minpoll:
58 type: int
59 description: Minimum poll interval in seconds as power of 2
60 '''
61
62 EXAMPLES = '''
63 - name: Example playbook
64 hosts: fortimanagers
65 gather_facts: false
66 connection: httpapi
67 vars:
68 ansible_httpapi_use_ssl: true
69 ansible_httpapi_validate_certs: false
70 ansible_httpapi_port: 443
71 tasks:
72 - name: NTP server.
73 fortinet.fortimanager.fmgr_system_ntp_ntpserver:
74 bypass_validation: false
75 state: present
76 system_ntp_ntpserver:
77 authentication: disable
78 id: 1
79 key: fortinet
80 key_id: 1
81 ntpv3: enable
82 server: ntp1.fortinet.net
83
84 - name: Gathering fortimanager facts
85 hosts: fortimanagers
86 gather_facts: false
87 connection: httpapi
88 vars:
89 ansible_httpapi_use_ssl: true
90 ansible_httpapi_validate_certs: false
91 ansible_httpapi_port: 443
92 tasks:
93 - name: Retrieve all the NTP servers
94 fortinet.fortimanager.fmgr_fact:
95 facts:
96 selector: "system_ntp_ntpserver"
97 params:
98 ntpserver: "your_value"
99 '''
100
101 RETURN = '''
102 meta:
103 description: The result of the request.
104 type: dict
105 returned: always
106 contains:
107 request_url:
108 description: The full url requested.
109 returned: always
110 type: str
111 sample: /sys/login/user
112 response_code:
113 description: The status of api request.
114 returned: always
115 type: int
116 sample: 0
117 response_data:
118 description: The api response.
119 type: list
120 returned: always
121 response_message:
122 description: The descriptive message of the api response.
123 type: str
124 returned: always
125 sample: OK.
126 system_information:
127 description: The information of the target system.
128 type: dict
129 returned: always
130 rc:
131 description: The status the request.
132 type: int
133 returned: always
134 sample: 0
135 version_check_warning:
136 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
137 type: list
138 returned: complex
139 '''
140 from ansible.module_utils.basic import AnsibleModule
141 from ansible.module_utils.connection import Connection
142 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
143 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
144
145
146 def main():
147 urls_list = [
148 '/cli/global/system/ntp/ntpserver'
149 ]
150 module_arg_spec = {
151 'system_ntp_ntpserver': {
152 'type': 'dict', 'v_range': [['6.0.0', '']],
153 'options': {
154 'authentication': {'choices': ['disable', 'enable'], 'type': 'str'},
155 'id': {'required': True, 'type': 'int'},
156 'key': {'no_log': True, 'type': 'raw'},
157 'key-id': {'no_log': True, 'type': 'int'},
158 'ntpv3': {'choices': ['disable', 'enable'], 'type': 'str'},
159 'server': {'type': 'str'},
160 'maxpoll': {'v_range': [['6.4.8', '6.4.15'], ['7.0.3', '']], 'type': 'int'},
161 'minpoll': {'v_range': [['6.4.8', '6.4.15'], ['7.0.3', '']], 'type': 'int'}
162 }
163 }
164 }
165
166 module_option_spec = get_module_arg_spec('full crud')
167 module_arg_spec.update(module_option_spec)
168 check_galaxy_version(module_arg_spec)
169 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_ntp_ntpserver'),
170 supports_check_mode=True)
171 if not module._socket_path:
172 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
173 connection = Connection(module._socket_path)
174 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
175 'id', 'data', module, connection)
176 fmgr.process_crud()
177 module.exit_json(meta=module.params)
178
179
180 if __name__ == '__main__':
181 main()