| 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_ocspserver |
| 15 |
short_description: OCSP server configuration. |
| 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_ocspserver: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
cert: |
| 34 |
type: str |
| 35 |
description: OCSP server certificate. |
| 36 |
name: |
| 37 |
type: str |
| 38 |
description: OCSP server entry name. |
| 39 |
required: true |
| 40 |
secondary_cert: |
| 41 |
aliases: ['secondary-cert'] |
| 42 |
type: str |
| 43 |
description: Secondary OCSP server certificate. |
| 44 |
secondary_url: |
| 45 |
aliases: ['secondary-url'] |
| 46 |
type: str |
| 47 |
description: Secondary OCSP server URL. |
| 48 |
source_ip: |
| 49 |
aliases: ['source-ip'] |
| 50 |
type: str |
| 51 |
description: Source IP address for communications to the OCSP server. |
| 52 |
unavail_action: |
| 53 |
aliases: ['unavail-action'] |
| 54 |
type: str |
| 55 |
description: Action when server is unavailable |
| 56 |
choices: ['revoke', 'ignore'] |
| 57 |
url: |
| 58 |
type: str |
| 59 |
description: OCSP server URL. |
| 60 |
''' |
| 61 |
|
| 62 |
EXAMPLES = ''' |
| 63 |
- name: Example playbook (generated based on argument schema) |
| 64 |
hosts: fortimanagers |
| 65 |
connection: httpapi |
| 66 |
gather_facts: false |
| 67 |
tasks: |
| 68 |
- name: OCSP server configuration. |
| 69 |
fortinet.fortimanager.fmgr_vpn_certificate_ocspserver: |
| 70 |
# workspace_locking_adom: <global or your adom name> |
| 71 |
adom: <your own value> |
| 72 |
state: present # <value in [present, absent]> |
| 73 |
vpn_certificate_ocspserver: |
| 74 |
name: "your value" # Required variable, string |
| 75 |
# cert: <string> |
| 76 |
# secondary_cert: <string> |
| 77 |
# secondary_url: <string> |
| 78 |
# source_ip: <string> |
| 79 |
# unavail_action: <value in [revoke, ignore]> |
| 80 |
# url: <string> |
| 81 |
''' |
| 82 |
|
| 83 |
RETURN = ''' |
| 84 |
meta: |
| 85 |
description: The result of the request. |
| 86 |
type: dict |
| 87 |
returned: always |
| 88 |
contains: |
| 89 |
request_url: |
| 90 |
description: The full url requested. |
| 91 |
returned: always |
| 92 |
type: str |
| 93 |
sample: /sys/login/user |
| 94 |
response_code: |
| 95 |
description: The status of api request. |
| 96 |
returned: always |
| 97 |
type: int |
| 98 |
sample: 0 |
| 99 |
response_data: |
| 100 |
description: The api response. |
| 101 |
type: list |
| 102 |
returned: always |
| 103 |
response_message: |
| 104 |
description: The descriptive message of the api response. |
| 105 |
type: str |
| 106 |
returned: always |
| 107 |
sample: OK. |
| 108 |
system_information: |
| 109 |
description: The information of the target system. |
| 110 |
type: dict |
| 111 |
returned: always |
| 112 |
rc: |
| 113 |
description: The status the request. |
| 114 |
type: int |
| 115 |
returned: always |
| 116 |
sample: 0 |
| 117 |
version_check_warning: |
| 118 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 119 |
type: list |
| 120 |
returned: complex |
| 121 |
''' |
| 122 |
from ansible.module_utils.basic import AnsibleModule |
| 123 |
from ansible.module_utils.connection import Connection |
| 124 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 125 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 126 |
|
| 127 |
|
| 128 |
def main(): |
| 129 |
urls_list = [ |
| 130 |
'/pm/config/adom/{adom}/obj/vpn/certificate/ocsp-server', |
| 131 |
'/pm/config/global/obj/vpn/certificate/ocsp-server' |
| 132 |
] |
| 133 |
module_arg_spec = { |
| 134 |
'adom': {'required': True, 'type': 'str'}, |
| 135 |
'revision_note': {'type': 'str'}, |
| 136 |
'vpn_certificate_ocspserver': { |
| 137 |
'type': 'dict', 'v_range': [['6.0.0', '']], |
| 138 |
'options': { |
| 139 |
'cert': {'type': 'str'}, |
| 140 |
'name': {'required': True, 'type': 'str'}, |
| 141 |
'secondary-cert': {'type': 'str'}, |
| 142 |
'secondary-url': {'type': 'str'}, |
| 143 |
'source-ip': {'type': 'str'}, |
| 144 |
'unavail-action': {'choices': ['revoke', 'ignore'], 'type': 'str'}, |
| 145 |
'url': {'type': 'str'} |
| 146 |
} |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
module_option_spec = get_module_arg_spec('full crud') |
| 151 |
module_arg_spec.update(module_option_spec) |
| 152 |
check_galaxy_version(module_arg_spec) |
| 153 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'vpn_certificate_ocspserver'), |
| 154 |
supports_check_mode=True) |
| 155 |
if not module._socket_path: |
| 156 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 157 |
connection = Connection(module._socket_path) |
| 158 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 159 |
'name', 'data', module, connection) |
| 160 |
fmgr.process_crud() |
| 161 |
module.exit_json(meta=module.params) |
| 162 |
|
| 163 |
|
| 164 |
if __name__ == '__main__': |
| 165 |
main() |