| 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_application_casi_profile |
| 15 |
short_description: Cloud Access Security Inspection. |
| 16 |
version_added: "2.2.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 |
application_casi_profile: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
app_replacemsg: |
| 34 |
aliases: ['app-replacemsg'] |
| 35 |
type: str |
| 36 |
description: Enable/disable replacement messages for blocked applications. |
| 37 |
choices: ['disable', 'enable'] |
| 38 |
comment: |
| 39 |
type: str |
| 40 |
description: Comment. |
| 41 |
entries: |
| 42 |
type: list |
| 43 |
elements: dict |
| 44 |
description: Entries. |
| 45 |
suboptions: |
| 46 |
action: |
| 47 |
type: str |
| 48 |
description: Action. |
| 49 |
choices: ['pass', 'block', 'reset'] |
| 50 |
application: |
| 51 |
type: raw |
| 52 |
description: (list) Application ID. |
| 53 |
id: |
| 54 |
type: int |
| 55 |
description: Entry ID. |
| 56 |
log: |
| 57 |
type: str |
| 58 |
description: Enable/disable logging. |
| 59 |
choices: ['disable', 'enable'] |
| 60 |
name: |
| 61 |
type: str |
| 62 |
description: Profile name. |
| 63 |
required: true |
| 64 |
replacemsg_group: |
| 65 |
aliases: ['replacemsg-group'] |
| 66 |
type: str |
| 67 |
description: Replacement message group. |
| 68 |
''' |
| 69 |
|
| 70 |
EXAMPLES = ''' |
| 71 |
- name: Example playbook (generated based on argument schema) |
| 72 |
hosts: fortimanagers |
| 73 |
connection: httpapi |
| 74 |
gather_facts: false |
| 75 |
tasks: |
| 76 |
- name: Cloud Access Security Inspection. |
| 77 |
fortinet.fortimanager.fmgr_application_casi_profile: |
| 78 |
# workspace_locking_adom: <global or your adom name> |
| 79 |
adom: <your own value> |
| 80 |
state: present # <value in [present, absent]> |
| 81 |
application_casi_profile: |
| 82 |
name: "your value" # Required variable, string |
| 83 |
# app_replacemsg: <value in [disable, enable]> |
| 84 |
# comment: <string> |
| 85 |
# entries: |
| 86 |
# - action: <value in [pass, block, reset]> |
| 87 |
# application: <list or integer> |
| 88 |
# id: <integer> |
| 89 |
# log: <value in [disable, enable]> |
| 90 |
# replacemsg_group: <string> |
| 91 |
''' |
| 92 |
|
| 93 |
RETURN = ''' |
| 94 |
meta: |
| 95 |
description: The result of the request. |
| 96 |
type: dict |
| 97 |
returned: always |
| 98 |
contains: |
| 99 |
request_url: |
| 100 |
description: The full url requested. |
| 101 |
returned: always |
| 102 |
type: str |
| 103 |
sample: /sys/login/user |
| 104 |
response_code: |
| 105 |
description: The status of api request. |
| 106 |
returned: always |
| 107 |
type: int |
| 108 |
sample: 0 |
| 109 |
response_data: |
| 110 |
description: The api response. |
| 111 |
type: list |
| 112 |
returned: always |
| 113 |
response_message: |
| 114 |
description: The descriptive message of the api response. |
| 115 |
type: str |
| 116 |
returned: always |
| 117 |
sample: OK. |
| 118 |
system_information: |
| 119 |
description: The information of the target system. |
| 120 |
type: dict |
| 121 |
returned: always |
| 122 |
rc: |
| 123 |
description: The status the request. |
| 124 |
type: int |
| 125 |
returned: always |
| 126 |
sample: 0 |
| 127 |
version_check_warning: |
| 128 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 129 |
type: list |
| 130 |
returned: complex |
| 131 |
''' |
| 132 |
from ansible.module_utils.basic import AnsibleModule |
| 133 |
from ansible.module_utils.connection import Connection |
| 134 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 135 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 136 |
|
| 137 |
|
| 138 |
def main(): |
| 139 |
urls_list = [ |
| 140 |
'/pm/config/adom/{adom}/obj/application/casi/profile', |
| 141 |
'/pm/config/global/obj/application/casi/profile' |
| 142 |
] |
| 143 |
module_arg_spec = { |
| 144 |
'adom': {'required': True, 'type': 'str'}, |
| 145 |
'revision_note': {'type': 'str'}, |
| 146 |
'application_casi_profile': { |
| 147 |
'type': 'dict', 'v_range': [['6.2.0', '6.2.13']], |
| 148 |
'options': { |
| 149 |
'app-replacemsg': {'v_range': [['6.2.0', '6.2.13']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 150 |
'comment': {'v_range': [['6.2.0', '6.2.13']], 'type': 'str'}, |
| 151 |
'entries': { |
| 152 |
'v_range': [['6.2.0', '6.2.13']], |
| 153 |
'type': 'list', |
| 154 |
'options': { |
| 155 |
'action': {'v_range': [['6.2.0', '6.2.13']], 'choices': ['pass', 'block', 'reset'], 'type': 'str'}, |
| 156 |
'application': {'v_range': [['6.2.0', '6.2.13']], 'type': 'raw'}, |
| 157 |
'id': {'v_range': [['6.2.0', '6.2.13']], 'type': 'int'}, |
| 158 |
'log': {'v_range': [['6.2.0', '6.2.13']], 'choices': ['disable', 'enable'], 'type': 'str'} |
| 159 |
}, |
| 160 |
'elements': 'dict' |
| 161 |
}, |
| 162 |
'name': {'v_range': [['6.2.0', '6.2.13']], 'required': True, 'type': 'str'}, |
| 163 |
'replacemsg-group': {'v_range': [['6.2.0', '6.2.13']], 'type': 'str'} |
| 164 |
} |
| 165 |
} |
| 166 |
} |
| 167 |
|
| 168 |
module_option_spec = get_module_arg_spec('full crud') |
| 169 |
module_arg_spec.update(module_option_spec) |
| 170 |
check_galaxy_version(module_arg_spec) |
| 171 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'application_casi_profile'), |
| 172 |
supports_check_mode=True) |
| 173 |
if not module._socket_path: |
| 174 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 175 |
connection = Connection(module._socket_path) |
| 176 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 177 |
'name', 'data', module, connection) |
| 178 |
fmgr.process_crud() |
| 179 |
module.exit_json(meta=module.params) |
| 180 |
|
| 181 |
|
| 182 |
if __name__ == '__main__': |
| 183 |
main() |