| 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_vpn_ipsec_manualkey |
| 15 |
short_description: Configure IPsec manual keys. |
| 16 |
version_added: "2.12.0" |
| 17 |
extends_documentation_fragment: |
| 18 |
- fortinet.fortimanager.general |
| 19 |
- fortinet.fortimanager.general.full_crud |
| 20 |
options: |
| 21 |
revision_note: |
| 22 |
description: The change note that can be specified when an object is created or updated. |
| 23 |
type: str |
| 24 |
adom: |
| 25 |
description: The parameter (adom) in requested url. |
| 26 |
type: str |
| 27 |
required: true |
| 28 |
vpn_ipsec_manualkey: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
authentication: |
| 34 |
type: str |
| 35 |
description: Authentication algorithm. |
| 36 |
choices: ['null', 'md5', 'sha1', 'sha256', 'sha384', 'sha512'] |
| 37 |
authkey: |
| 38 |
type: list |
| 39 |
elements: str |
| 40 |
description: Hexadecimal authentication key in 16-digit |
| 41 |
enckey: |
| 42 |
type: list |
| 43 |
elements: str |
| 44 |
description: Hexadecimal encryption key in 16-digit |
| 45 |
encryption: |
| 46 |
type: str |
| 47 |
description: Encryption algorithm. |
| 48 |
choices: ['null', 'des', '3des', 'aes128', 'aes192', 'aes256', 'aria128', |
| 49 |
'aria192', 'aria256', 'seed'] |
| 50 |
interface: |
| 51 |
type: list |
| 52 |
elements: str |
| 53 |
description: Name of the physical, aggregate, or VLAN interface. |
| 54 |
local_gw: |
| 55 |
aliases: ['local-gw'] |
| 56 |
type: str |
| 57 |
description: Local gateway. |
| 58 |
localspi: |
| 59 |
type: str |
| 60 |
description: Local SPI, a hexadecimal 8-digit |
| 61 |
name: |
| 62 |
type: str |
| 63 |
description: IPsec tunnel name. |
| 64 |
required: true |
| 65 |
npu_offload: |
| 66 |
aliases: ['npu-offload'] |
| 67 |
type: str |
| 68 |
description: Enable/disable NPU offloading. |
| 69 |
choices: ['disable', 'enable'] |
| 70 |
remote_gw: |
| 71 |
aliases: ['remote-gw'] |
| 72 |
type: str |
| 73 |
description: Peer gateway. |
| 74 |
remotespi: |
| 75 |
type: str |
| 76 |
description: Remote SPI, a hexadecimal 8-digit |
| 77 |
''' |
| 78 |
|
| 79 |
EXAMPLES = ''' |
| 80 |
- name: Example playbook (generated based on argument schema) |
| 81 |
hosts: fortimanagers |
| 82 |
connection: httpapi |
| 83 |
gather_facts: false |
| 84 |
tasks: |
| 85 |
- name: Configure IPsec manual keys. |
| 86 |
fortinet.fortimanager.fmgr_vpn_ipsec_manualkey: |
| 87 |
# workspace_locking_adom: <global or your adom name> |
| 88 |
adom: <your own value> |
| 89 |
state: present # <value in [present, absent]> |
| 90 |
vpn_ipsec_manualkey: |
| 91 |
name: "your value" # Required variable, string |
| 92 |
# authentication: <value in [null, md5, sha1, ...]> |
| 93 |
# authkey: <list or string> |
| 94 |
# enckey: <list or string> |
| 95 |
# encryption: <value in [null, des, 3des, ...]> |
| 96 |
# interface: <list or string> |
| 97 |
# local_gw: <string> |
| 98 |
# localspi: <string> |
| 99 |
# npu_offload: <value in [disable, enable]> |
| 100 |
# remote_gw: <string> |
| 101 |
# remotespi: <string> |
| 102 |
''' |
| 103 |
|
| 104 |
RETURN = ''' |
| 105 |
meta: |
| 106 |
description: The result of the request. |
| 107 |
type: dict |
| 108 |
returned: always |
| 109 |
contains: |
| 110 |
request_url: |
| 111 |
description: The full url requested. |
| 112 |
returned: always |
| 113 |
type: str |
| 114 |
sample: /sys/login/user |
| 115 |
response_code: |
| 116 |
description: The status of api request. |
| 117 |
returned: always |
| 118 |
type: int |
| 119 |
sample: 0 |
| 120 |
response_data: |
| 121 |
description: The api response. |
| 122 |
type: list |
| 123 |
returned: always |
| 124 |
response_message: |
| 125 |
description: The descriptive message of the api response. |
| 126 |
type: str |
| 127 |
returned: always |
| 128 |
sample: OK. |
| 129 |
system_information: |
| 130 |
description: The information of the target system. |
| 131 |
type: dict |
| 132 |
returned: always |
| 133 |
rc: |
| 134 |
description: The status the request. |
| 135 |
type: int |
| 136 |
returned: always |
| 137 |
sample: 0 |
| 138 |
version_check_warning: |
| 139 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 140 |
type: list |
| 141 |
returned: complex |
| 142 |
''' |
| 143 |
from ansible.module_utils.basic import AnsibleModule |
| 144 |
from ansible.module_utils.connection import Connection |
| 145 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 146 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 147 |
|
| 148 |
|
| 149 |
def main(): |
| 150 |
urls_list = [ |
| 151 |
'/pm/config/adom/{adom}/obj/vpn/ipsec/manualkey', |
| 152 |
'/pm/config/global/obj/vpn/ipsec/manualkey' |
| 153 |
] |
| 154 |
module_arg_spec = { |
| 155 |
'adom': {'required': True, 'type': 'str'}, |
| 156 |
'revision_note': {'type': 'str'}, |
| 157 |
'vpn_ipsec_manualkey': { |
| 158 |
'type': 'dict', 'v_range': [['7.6.4', '']], 'no_log': False, |
| 159 |
'options': { |
| 160 |
'authentication': {'v_range': [['7.6.4', '']], 'choices': ['null', 'md5', 'sha1', 'sha256', 'sha384', 'sha512'], 'type': 'str'}, |
| 161 |
'authkey': {'v_range': [['7.6.4', '']], 'no_log': True, 'type': 'list', 'elements': 'str'}, |
| 162 |
'enckey': {'v_range': [['7.6.4', '']], 'no_log': True, 'type': 'list', 'elements': 'str'}, |
| 163 |
'encryption': { |
| 164 |
'v_range': [['7.6.4', '']], |
| 165 |
'choices': ['null', 'des', '3des', 'aes128', 'aes192', 'aes256', 'aria128', 'aria192', 'aria256', 'seed'], |
| 166 |
'type': 'str' |
| 167 |
}, |
| 168 |
'interface': {'v_range': [['7.6.4', '']], 'type': 'list', 'elements': 'str'}, |
| 169 |
'local-gw': {'v_range': [['7.6.4', '']], 'type': 'str'}, |
| 170 |
'localspi': {'v_range': [['7.6.4', '']], 'type': 'str'}, |
| 171 |
'name': {'v_range': [['7.6.4', '']], 'required': True, 'type': 'str'}, |
| 172 |
'npu-offload': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 173 |
'remote-gw': {'v_range': [['7.6.4', '']], 'type': 'str'}, |
| 174 |
'remotespi': {'v_range': [['7.6.4', '']], 'type': 'str'} |
| 175 |
} |
| 176 |
} |
| 177 |
} |
| 178 |
|
| 179 |
module_option_spec = get_module_arg_spec('full crud') |
| 180 |
module_arg_spec.update(module_option_spec) |
| 181 |
check_galaxy_version(module_arg_spec) |
| 182 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'vpn_ipsec_manualkey'), |
| 183 |
supports_check_mode=True) |
| 184 |
if not module._socket_path: |
| 185 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 186 |
connection = Connection(module._socket_path) |
| 187 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 188 |
'name', 'data', module, connection) |
| 189 |
fmgr.process_crud() |
| 190 |
module.exit_json(meta=module.params) |
| 191 |
|
| 192 |
|
| 193 |
if __name__ == '__main__': |
| 194 |
main() |