| 1 |
|
| 2 |
from __future__ import absolute_import, division, print_function |
| 3 |
|
| 4 |
|
| 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_devprof_system_ntp |
| 15 |
short_description: Configure system NTP information. |
| 16 |
version_added: "1.0.0" |
| 17 |
extends_documentation_fragment: |
| 18 |
- fortinet.fortimanager.general |
| 19 |
- fortinet.fortimanager.general.partial_crud |
| 20 |
options: |
| 21 |
adom: |
| 22 |
description: The parameter (adom) in requested url. |
| 23 |
type: str |
| 24 |
required: true |
| 25 |
devprof: |
| 26 |
description: The parameter (devprof) in requested url. |
| 27 |
type: str |
| 28 |
required: true |
| 29 |
devprof_system_ntp: |
| 30 |
description: The top level parameters set. |
| 31 |
required: false |
| 32 |
type: dict |
| 33 |
suboptions: |
| 34 |
ntpserver: |
| 35 |
type: list |
| 36 |
elements: dict |
| 37 |
description: Ntpserver. |
| 38 |
suboptions: |
| 39 |
authentication: |
| 40 |
type: str |
| 41 |
description: Enable/disable MD5 authentication. |
| 42 |
choices: ['disable', 'enable'] |
| 43 |
id: |
| 44 |
type: int |
| 45 |
description: NTP server ID. |
| 46 |
key: |
| 47 |
type: raw |
| 48 |
description: (list) Key for MD5 authentication. |
| 49 |
key_id: |
| 50 |
aliases: ['key-id'] |
| 51 |
type: int |
| 52 |
description: Key ID for authentication. |
| 53 |
ntpv3: |
| 54 |
type: str |
| 55 |
description: Enable to use NTPv3 instead of NTPv4. |
| 56 |
choices: ['disable', 'enable'] |
| 57 |
server: |
| 58 |
type: str |
| 59 |
description: IP address or hostname of the NTP Server. |
| 60 |
interface: |
| 61 |
type: str |
| 62 |
description: Specify outgoing interface to reach server. |
| 63 |
interface_select_method: |
| 64 |
aliases: ['interface-select-method'] |
| 65 |
type: str |
| 66 |
description: Specify how to select outgoing interface to reach server. |
| 67 |
choices: ['auto', 'sdwan', 'specify'] |
| 68 |
ip_type: |
| 69 |
aliases: ['ip-type'] |
| 70 |
type: str |
| 71 |
description: Choose to connect to IPv4 or/and IPv6 NTP server. |
| 72 |
choices: ['IPv6', 'IPv4', 'Both'] |
| 73 |
key_type: |
| 74 |
aliases: ['key-type'] |
| 75 |
type: str |
| 76 |
description: Select NTP authentication type. |
| 77 |
choices: ['SHA1', 'SHA256', 'MD5'] |
| 78 |
vrf_select: |
| 79 |
aliases: ['vrf-select'] |
| 80 |
type: int |
| 81 |
description: VRF ID used for connection to server. |
| 82 |
ntpsync: |
| 83 |
type: str |
| 84 |
description: Enable/disable setting the FortiGate system time by synchronizing with an NTP Server. |
| 85 |
choices: ['disable', 'enable'] |
| 86 |
source_ip6: |
| 87 |
aliases: ['source-ip6'] |
| 88 |
type: str |
| 89 |
description: Source IPv6 address for communication to the NTP server. |
| 90 |
syncinterval: |
| 91 |
type: int |
| 92 |
description: NTP synchronization interval |
| 93 |
type: |
| 94 |
type: str |
| 95 |
description: Use the FortiGuard NTP server or any other available NTP Server. |
| 96 |
choices: ['fortiguard', 'custom'] |
| 97 |
authentication: |
| 98 |
type: str |
| 99 |
description: Enable/disable authentication. |
| 100 |
choices: ['disable', 'enable'] |
| 101 |
key: |
| 102 |
type: raw |
| 103 |
description: (list) Key for authentication. |
| 104 |
key_id: |
| 105 |
aliases: ['key-id'] |
| 106 |
type: int |
| 107 |
description: Key ID for authentication. |
| 108 |
key_type: |
| 109 |
aliases: ['key-type'] |
| 110 |
type: str |
| 111 |
description: Key type for authentication |
| 112 |
choices: ['MD5', 'SHA1', 'SHA256'] |
| 113 |
interface: |
| 114 |
type: raw |
| 115 |
description: |
| 116 |
- (list) |
| 117 |
- Support meta variable |
| 118 |
- FortiGate interface |
| 119 |
server_mode: |
| 120 |
aliases: ['server-mode'] |
| 121 |
type: str |
| 122 |
description: Enable/disable FortiGate NTP Server Mode. |
| 123 |
choices: ['disable', 'enable'] |
| 124 |
source_ip: |
| 125 |
aliases: ['source-ip'] |
| 126 |
type: str |
| 127 |
description: |
| 128 |
- Support meta variable |
| 129 |
- Source IP address for communication to the NTP server. |
| 130 |
''' |
| 131 |
|
| 132 |
EXAMPLES = ''' |
| 133 |
- name: Example playbook (generated based on argument schema) |
| 134 |
hosts: fortimanagers |
| 135 |
connection: httpapi |
| 136 |
gather_facts: false |
| 137 |
tasks: |
| 138 |
- name: Configure system NTP information. |
| 139 |
fortinet.fortimanager.fmgr_devprof_system_ntp: |
| 140 |
# workspace_locking_adom: <global or your adom name> |
| 141 |
adom: <your own value> |
| 142 |
devprof: <your own value> |
| 143 |
devprof_system_ntp: |
| 144 |
# ntpserver: |
| 145 |
# - authentication: <value in [disable, enable]> |
| 146 |
# id: <integer> |
| 147 |
# key: <list or string> |
| 148 |
# key_id: <integer> |
| 149 |
# ntpv3: <value in [disable, enable]> |
| 150 |
# server: <string> |
| 151 |
# interface: <string> |
| 152 |
# interface_select_method: <value in [auto, sdwan, specify]> |
| 153 |
# ip_type: <value in [IPv6, IPv4, Both]> |
| 154 |
# key_type: <value in [SHA1, SHA256, MD5]> |
| 155 |
# vrf_select: <integer> |
| 156 |
# ntpsync: <value in [disable, enable]> |
| 157 |
# source_ip6: <string> |
| 158 |
# syncinterval: <integer> |
| 159 |
# type: <value in [fortiguard, custom]> |
| 160 |
# authentication: <value in [disable, enable]> |
| 161 |
# key: <list or string> |
| 162 |
# key_id: <integer> |
| 163 |
# key_type: <value in [MD5, SHA1, SHA256]> |
| 164 |
# interface: <list or string> |
| 165 |
# server_mode: <value in [disable, enable]> |
| 166 |
# source_ip: <string> |
| 167 |
''' |
| 168 |
|
| 169 |
RETURN = ''' |
| 170 |
meta: |
| 171 |
description: The result of the request. |
| 172 |
type: dict |
| 173 |
returned: always |
| 174 |
contains: |
| 175 |
request_url: |
| 176 |
description: The full url requested. |
| 177 |
returned: always |
| 178 |
type: str |
| 179 |
sample: /sys/login/user |
| 180 |
response_code: |
| 181 |
description: The status of api request. |
| 182 |
returned: always |
| 183 |
type: int |
| 184 |
sample: 0 |
| 185 |
response_data: |
| 186 |
description: The api response. |
| 187 |
type: list |
| 188 |
returned: always |
| 189 |
response_message: |
| 190 |
description: The descriptive message of the api response. |
| 191 |
type: str |
| 192 |
returned: always |
| 193 |
sample: OK. |
| 194 |
system_information: |
| 195 |
description: The information of the target system. |
| 196 |
type: dict |
| 197 |
returned: always |
| 198 |
rc: |
| 199 |
description: The status the request. |
| 200 |
type: int |
| 201 |
returned: always |
| 202 |
sample: 0 |
| 203 |
version_check_warning: |
| 204 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 205 |
type: list |
| 206 |
returned: complex |
| 207 |
''' |
| 208 |
from ansible.module_utils.basic import AnsibleModule |
| 209 |
from ansible.module_utils.connection import Connection |
| 210 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 211 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 212 |
|
| 213 |
|
| 214 |
def main(): |
| 215 |
urls_list = [ |
| 216 |
'/pm/config/adom/{adom}/devprof/{devprof}/system/ntp' |
| 217 |
] |
| 218 |
module_arg_spec = { |
| 219 |
'adom': {'required': True, 'type': 'str'}, |
| 220 |
'devprof': {'required': True, 'type': 'str'}, |
| 221 |
'devprof_system_ntp': { |
| 222 |
'type': 'dict', 'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], |
| 223 |
'options': { |
| 224 |
'ntpserver': { |
| 225 |
'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], |
| 226 |
'type': 'list', |
| 227 |
'options': { |
| 228 |
'authentication': { |
| 229 |
'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], |
| 230 |
'choices': ['disable', 'enable'], |
| 231 |
'type': 'str' |
| 232 |
}, |
| 233 |
'id': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'type': 'int'}, |
| 234 |
'key': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'no_log': True, 'type': 'raw'}, |
| 235 |
'key-id': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'no_log': True, 'type': 'int'}, |
| 236 |
'ntpv3': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 237 |
'server': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'type': 'str'}, |
| 238 |
'interface': {'v_range': [['6.2.7', '6.2.13'], ['6.4.3', '7.0.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'}, |
| 239 |
'interface-select-method': { |
| 240 |
'v_range': [['6.2.7', '6.2.13'], ['6.4.3', '7.0.2'], ['7.2.6', '7.2.12'], ['7.4.3', '']], |
| 241 |
'choices': ['auto', 'sdwan', 'specify'], |
| 242 |
'type': 'str' |
| 243 |
}, |
| 244 |
'ip-type': {'v_range': [['7.4.2', '']], 'choices': ['IPv6', 'IPv4', 'Both'], 'type': 'str'}, |
| 245 |
'key-type': {'v_range': [['7.4.3', '']], 'choices': ['SHA1', 'SHA256', 'MD5'], 'type': 'str'}, |
| 246 |
'vrf-select': {'v_range': [['7.6.2', '']], 'type': 'int'} |
| 247 |
}, |
| 248 |
'elements': 'dict' |
| 249 |
}, |
| 250 |
'ntpsync': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 251 |
'source-ip6': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'type': 'str'}, |
| 252 |
'syncinterval': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'type': 'int'}, |
| 253 |
'type': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'choices': ['fortiguard', 'custom'], 'type': 'str'}, |
| 254 |
'authentication': {'v_range': [['6.2.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 255 |
'key': {'v_range': [['6.2.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'no_log': True, 'type': 'raw'}, |
| 256 |
'key-id': {'v_range': [['6.2.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'no_log': True, 'type': 'int'}, |
| 257 |
'key-type': {'v_range': [['6.2.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'choices': ['MD5', 'SHA1', 'SHA256'], 'type': 'str'}, |
| 258 |
'interface': {'v_range': [['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'}, |
| 259 |
'server-mode': {'v_range': [['7.2.6', '7.2.12'], ['7.4.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 260 |
'source-ip': {'v_range': [['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'} |
| 261 |
} |
| 262 |
} |
| 263 |
} |
| 264 |
|
| 265 |
module_option_spec = get_module_arg_spec('partial crud') |
| 266 |
module_arg_spec.update(module_option_spec) |
| 267 |
check_galaxy_version(module_arg_spec) |
| 268 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'devprof_system_ntp'), |
| 269 |
supports_check_mode=True) |
| 270 |
if not module._socket_path: |
| 271 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 272 |
connection = Connection(module._socket_path) |
| 273 |
fmgr = NAPIManager('partial crud', module_arg_spec, urls_list, |
| 274 |
None, 'data', module, connection) |
| 275 |
fmgr.process_partial_crud() |
| 276 |
module.exit_json(meta=module.params) |
| 277 |
|
| 278 |
|
| 279 |
if __name__ == '__main__': |
| 280 |
main() |