| 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_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 |
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_certificate_ca: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
_private_key: |
| 34 |
type: str |
| 35 |
description: Private key. |
| 36 |
auto_update_days: |
| 37 |
aliases: ['auto-update-days'] |
| 38 |
type: int |
| 39 |
description: Number of days to wait before requesting an updated CA certificate |
| 40 |
auto_update_days_warning: |
| 41 |
aliases: ['auto-update-days-warning'] |
| 42 |
type: int |
| 43 |
description: Number of days before an expiry-warning message is generated |
| 44 |
ca: |
| 45 |
type: str |
| 46 |
description: CA certificate as a PEM file. |
| 47 |
last_updated: |
| 48 |
aliases: ['last-updated'] |
| 49 |
type: int |
| 50 |
description: Time at which CA was last updated. |
| 51 |
name: |
| 52 |
type: str |
| 53 |
description: Name. |
| 54 |
required: true |
| 55 |
range: |
| 56 |
type: str |
| 57 |
description: Either global or VDOM IP address range for the CA certificate. |
| 58 |
choices: ['global', 'vdom'] |
| 59 |
scep_url: |
| 60 |
aliases: ['scep-url'] |
| 61 |
type: str |
| 62 |
description: URL of the SCEP server. |
| 63 |
source: |
| 64 |
type: str |
| 65 |
description: CA certificate source type. |
| 66 |
choices: ['factory', 'user', 'bundle', 'fortiguard'] |
| 67 |
source_ip: |
| 68 |
aliases: ['source-ip'] |
| 69 |
type: str |
| 70 |
description: Source IP address for communications to the SCEP server. |
| 71 |
trusted: |
| 72 |
type: str |
| 73 |
description: Enable/disable as a trusted CA. |
| 74 |
choices: ['disable', 'enable'] |
| 75 |
ssl_inspection_trusted: |
| 76 |
aliases: ['ssl-inspection-trusted'] |
| 77 |
type: str |
| 78 |
description: Enable/disable this CA as a trusted CA for SSL inspection. |
| 79 |
choices: ['disable', 'enable'] |
| 80 |
ca_identifier: |
| 81 |
aliases: ['ca-identifier'] |
| 82 |
type: str |
| 83 |
description: CA identifier of the SCEP server. |
| 84 |
obsolete: |
| 85 |
type: str |
| 86 |
description: Enable/disable this CA as obsoleted. |
| 87 |
choices: ['disable', 'enable'] |
| 88 |
est_url: |
| 89 |
aliases: ['est-url'] |
| 90 |
type: str |
| 91 |
description: URL of the EST server. |
| 92 |
fabric_ca: |
| 93 |
aliases: ['fabric-ca'] |
| 94 |
type: str |
| 95 |
description: Enable/disable synchronization of CA across Security Fabric. |
| 96 |
choices: ['disable', 'enable'] |
| 97 |
non_fabric_name: |
| 98 |
aliases: ['non-fabric-name'] |
| 99 |
type: str |
| 100 |
description: Name used prior to becoming a Security Fabric synchronized CA. |
| 101 |
''' |
| 102 |
|
| 103 |
EXAMPLES = ''' |
| 104 |
- name: Example playbook (generated based on argument schema) |
| 105 |
hosts: fortimanagers |
| 106 |
connection: httpapi |
| 107 |
gather_facts: false |
| 108 |
tasks: |
| 109 |
- name: CA certificate. |
| 110 |
fortinet.fortimanager.fmgr_vpn_certificate_ca: |
| 111 |
# workspace_locking_adom: <global or your adom name> |
| 112 |
adom: <your own value> |
| 113 |
state: present # <value in [present, absent]> |
| 114 |
vpn_certificate_ca: |
| 115 |
name: "your value" # Required variable, string |
| 116 |
# _private_key: <string> |
| 117 |
# auto_update_days: <integer> |
| 118 |
# auto_update_days_warning: <integer> |
| 119 |
# ca: <string> |
| 120 |
# last_updated: <integer> |
| 121 |
# range: <value in [global, vdom]> |
| 122 |
# scep_url: <string> |
| 123 |
# source: <value in [factory, user, bundle, ...]> |
| 124 |
# source_ip: <string> |
| 125 |
# trusted: <value in [disable, enable]> |
| 126 |
# ssl_inspection_trusted: <value in [disable, enable]> |
| 127 |
# ca_identifier: <string> |
| 128 |
# obsolete: <value in [disable, enable]> |
| 129 |
# est_url: <string> |
| 130 |
# fabric_ca: <value in [disable, enable]> |
| 131 |
# non_fabric_name: <string> |
| 132 |
''' |
| 133 |
|
| 134 |
RETURN = ''' |
| 135 |
meta: |
| 136 |
description: The result of the request. |
| 137 |
type: dict |
| 138 |
returned: always |
| 139 |
contains: |
| 140 |
request_url: |
| 141 |
description: The full url requested. |
| 142 |
returned: always |
| 143 |
type: str |
| 144 |
sample: /sys/login/user |
| 145 |
response_code: |
| 146 |
description: The status of api request. |
| 147 |
returned: always |
| 148 |
type: int |
| 149 |
sample: 0 |
| 150 |
response_data: |
| 151 |
description: The api response. |
| 152 |
type: list |
| 153 |
returned: always |
| 154 |
response_message: |
| 155 |
description: The descriptive message of the api response. |
| 156 |
type: str |
| 157 |
returned: always |
| 158 |
sample: OK. |
| 159 |
system_information: |
| 160 |
description: The information of the target system. |
| 161 |
type: dict |
| 162 |
returned: always |
| 163 |
rc: |
| 164 |
description: The status the request. |
| 165 |
type: int |
| 166 |
returned: always |
| 167 |
sample: 0 |
| 168 |
version_check_warning: |
| 169 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 170 |
type: list |
| 171 |
returned: complex |
| 172 |
''' |
| 173 |
from ansible.module_utils.basic import AnsibleModule |
| 174 |
from ansible.module_utils.connection import Connection |
| 175 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 176 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 177 |
|
| 178 |
|
| 179 |
def main(): |
| 180 |
urls_list = [ |
| 181 |
'/pm/config/adom/{adom}/obj/vpn/certificate/ca', |
| 182 |
'/pm/config/global/obj/vpn/certificate/ca' |
| 183 |
] |
| 184 |
module_arg_spec = { |
| 185 |
'adom': {'required': True, 'type': 'str'}, |
| 186 |
'revision_note': {'type': 'str'}, |
| 187 |
'vpn_certificate_ca': { |
| 188 |
'type': 'dict', 'v_range': [['6.0.0', '']], |
| 189 |
'options': { |
| 190 |
'_private_key': {'no_log': True, 'type': 'str'}, |
| 191 |
'auto-update-days': {'type': 'int'}, |
| 192 |
'auto-update-days-warning': {'type': 'int'}, |
| 193 |
'ca': {'type': 'str'}, |
| 194 |
'last-updated': {'type': 'int'}, |
| 195 |
'name': {'required': True, 'type': 'str'}, |
| 196 |
'range': {'choices': ['global', 'vdom'], 'type': 'str'}, |
| 197 |
'scep-url': {'type': 'str'}, |
| 198 |
'source': {'choices': ['factory', 'user', 'bundle', 'fortiguard'], 'type': 'str'}, |
| 199 |
'source-ip': {'type': 'str'}, |
| 200 |
'trusted': {'v_range': [['6.0.0', '7.2.1']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 201 |
'ssl-inspection-trusted': {'v_range': [['6.2.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 202 |
'ca-identifier': {'v_range': [['7.0.2', '']], 'type': 'str'}, |
| 203 |
'obsolete': {'v_range': [['7.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 204 |
'est-url': {'v_range': [['7.4.1', '']], 'type': 'str'}, |
| 205 |
'fabric-ca': {'v_range': [['7.4.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 206 |
'non-fabric-name': {'v_range': [['7.4.3', '']], 'type': 'str'} |
| 207 |
} |
| 208 |
} |
| 209 |
} |
| 210 |
|
| 211 |
module_option_spec = get_module_arg_spec('full crud') |
| 212 |
module_arg_spec.update(module_option_spec) |
| 213 |
check_galaxy_version(module_arg_spec) |
| 214 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'vpn_certificate_ca'), |
| 215 |
supports_check_mode=True) |
| 216 |
if not module._socket_path: |
| 217 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 218 |
connection = Connection(module._socket_path) |
| 219 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 220 |
'name', 'data', module, connection) |
| 221 |
fmgr.process_crud() |
| 222 |
module.exit_json(meta=module.params) |
| 223 |
|
| 224 |
|
| 225 |
if __name__ == '__main__': |
| 226 |
main() |