Debian Codegraph @

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