| 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_cifs_profile |
| 15 |
short_description: Configure CIFS profile. |
| 16 |
version_added: "2.1.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 |
cifs_profile: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
domain_controller: |
| 34 |
aliases: ['domain-controller'] |
| 35 |
type: str |
| 36 |
description: Domain for which to decrypt CIFS traffic. |
| 37 |
name: |
| 38 |
type: str |
| 39 |
description: Profile name. |
| 40 |
required: true |
| 41 |
server_credential_type: |
| 42 |
aliases: ['server-credential-type'] |
| 43 |
type: str |
| 44 |
description: CIFS server credential type. |
| 45 |
choices: ['none', 'credential-replication', 'credential-keytab'] |
| 46 |
server_keytab: |
| 47 |
aliases: ['server-keytab'] |
| 48 |
type: list |
| 49 |
elements: dict |
| 50 |
description: Server keytab. |
| 51 |
suboptions: |
| 52 |
keytab: |
| 53 |
type: str |
| 54 |
description: Base64 encoded keytab file containing credential of the server. |
| 55 |
principal: |
| 56 |
type: str |
| 57 |
description: Service principal. |
| 58 |
password: |
| 59 |
type: raw |
| 60 |
description: (list) Password for keytab. |
| 61 |
file_filter: |
| 62 |
aliases: ['file-filter'] |
| 63 |
type: dict |
| 64 |
description: File filter. |
| 65 |
suboptions: |
| 66 |
entries: |
| 67 |
type: list |
| 68 |
elements: dict |
| 69 |
description: Entries. |
| 70 |
suboptions: |
| 71 |
action: |
| 72 |
type: str |
| 73 |
description: Action taken for matched file. |
| 74 |
choices: ['block', 'log'] |
| 75 |
comment: |
| 76 |
type: str |
| 77 |
description: Comment. |
| 78 |
direction: |
| 79 |
type: str |
| 80 |
description: Match files transmitted in the sessions originating or reply direction. |
| 81 |
choices: ['incoming', 'outgoing', 'any'] |
| 82 |
file_type: |
| 83 |
aliases: ['file-type'] |
| 84 |
type: raw |
| 85 |
description: (list or str) Select file type. |
| 86 |
filter: |
| 87 |
type: str |
| 88 |
description: Add a file filter. |
| 89 |
protocol: |
| 90 |
type: list |
| 91 |
elements: str |
| 92 |
description: Protocols to apply with. |
| 93 |
choices: ['cifs'] |
| 94 |
log: |
| 95 |
type: str |
| 96 |
description: Enable/disable file filter logging. |
| 97 |
choices: ['disable', 'enable'] |
| 98 |
status: |
| 99 |
type: str |
| 100 |
description: Enable/disable file filter. |
| 101 |
choices: ['disable', 'enable'] |
| 102 |
''' |
| 103 |
|
| 104 |
EXAMPLES = ''' |
| 105 |
- name: Example playbook (generated based on argument schema) |
| 106 |
hosts: fortimanagers |
| 107 |
connection: httpapi |
| 108 |
gather_facts: false |
| 109 |
tasks: |
| 110 |
- name: Configure CIFS profile. |
| 111 |
fortinet.fortimanager.fmgr_cifs_profile: |
| 112 |
# workspace_locking_adom: <global or your adom name> |
| 113 |
adom: <your own value> |
| 114 |
state: present # <value in [present, absent]> |
| 115 |
cifs_profile: |
| 116 |
name: "your value" # Required variable, string |
| 117 |
# domain_controller: <string> |
| 118 |
# server_credential_type: <value in [none, credential-replication, credential-keytab]> |
| 119 |
# server_keytab: |
| 120 |
# - keytab: <string> |
| 121 |
# principal: <string> |
| 122 |
# password: <list or string> |
| 123 |
# file_filter: |
| 124 |
# entries: |
| 125 |
# - action: <value in [block, log]> |
| 126 |
# comment: <string> |
| 127 |
# direction: <value in [incoming, outgoing, any]> |
| 128 |
# file_type: <list or string> |
| 129 |
# filter: <string> |
| 130 |
# protocol: ["cifs"] |
| 131 |
# log: <value in [disable, enable]> |
| 132 |
# status: <value in [disable, enable]> |
| 133 |
''' |
| 134 |
|
| 135 |
RETURN = ''' |
| 136 |
meta: |
| 137 |
description: The result of the request. |
| 138 |
type: dict |
| 139 |
returned: always |
| 140 |
contains: |
| 141 |
request_url: |
| 142 |
description: The full url requested. |
| 143 |
returned: always |
| 144 |
type: str |
| 145 |
sample: /sys/login/user |
| 146 |
response_code: |
| 147 |
description: The status of api request. |
| 148 |
returned: always |
| 149 |
type: int |
| 150 |
sample: 0 |
| 151 |
response_data: |
| 152 |
description: The api response. |
| 153 |
type: list |
| 154 |
returned: always |
| 155 |
response_message: |
| 156 |
description: The descriptive message of the api response. |
| 157 |
type: str |
| 158 |
returned: always |
| 159 |
sample: OK. |
| 160 |
system_information: |
| 161 |
description: The information of the target system. |
| 162 |
type: dict |
| 163 |
returned: always |
| 164 |
rc: |
| 165 |
description: The status the request. |
| 166 |
type: int |
| 167 |
returned: always |
| 168 |
sample: 0 |
| 169 |
version_check_warning: |
| 170 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 171 |
type: list |
| 172 |
returned: complex |
| 173 |
''' |
| 174 |
from ansible.module_utils.basic import AnsibleModule |
| 175 |
from ansible.module_utils.connection import Connection |
| 176 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 177 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 178 |
|
| 179 |
|
| 180 |
def main(): |
| 181 |
urls_list = [ |
| 182 |
'/pm/config/adom/{adom}/obj/cifs/profile', |
| 183 |
'/pm/config/global/obj/cifs/profile' |
| 184 |
] |
| 185 |
module_arg_spec = { |
| 186 |
'adom': {'required': True, 'type': 'str'}, |
| 187 |
'revision_note': {'type': 'str'}, |
| 188 |
'cifs_profile': { |
| 189 |
'type': 'dict', 'v_range': [['6.2.0', '']], |
| 190 |
'options': { |
| 191 |
'domain-controller': {'v_range': [['6.2.0', '']], 'type': 'str'}, |
| 192 |
'name': {'v_range': [['6.2.0', '']], 'required': True, 'type': 'str'}, |
| 193 |
'server-credential-type': {'v_range': [['6.2.0', '']], 'choices': ['none', 'credential-replication', 'credential-keytab'], 'type': 'str'}, |
| 194 |
'server-keytab': { |
| 195 |
'v_range': [['6.2.0', '']], |
| 196 |
'no_log': True, |
| 197 |
'type': 'list', |
| 198 |
'options': { |
| 199 |
'keytab': {'v_range': [['6.2.0', '']], 'no_log': True, 'type': 'str'}, |
| 200 |
'principal': {'v_range': [['6.2.0', '']], 'type': 'str'}, |
| 201 |
'password': {'v_range': [['6.2.2', '']], 'no_log': True, 'type': 'raw'} |
| 202 |
}, |
| 203 |
'elements': 'dict' |
| 204 |
}, |
| 205 |
'file-filter': { |
| 206 |
'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']], |
| 207 |
'type': 'dict', |
| 208 |
'options': { |
| 209 |
'entries': { |
| 210 |
'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']], |
| 211 |
'type': 'list', |
| 212 |
'options': { |
| 213 |
'action': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']], 'choices': ['block', 'log'], 'type': 'str'}, |
| 214 |
'comment': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']], 'type': 'str'}, |
| 215 |
'direction': { |
| 216 |
'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']], |
| 217 |
'choices': ['incoming', 'outgoing', 'any'], |
| 218 |
'type': 'str' |
| 219 |
}, |
| 220 |
'file-type': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']], 'type': 'raw'}, |
| 221 |
'filter': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']], 'type': 'str'}, |
| 222 |
'protocol': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']], 'type': 'list', 'choices': ['cifs'], 'elements': 'str'} |
| 223 |
}, |
| 224 |
'elements': 'dict' |
| 225 |
}, |
| 226 |
'log': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 227 |
'status': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'} |
| 228 |
} |
| 229 |
} |
| 230 |
} |
| 231 |
} |
| 232 |
} |
| 233 |
|
| 234 |
module_option_spec = get_module_arg_spec('full crud') |
| 235 |
module_arg_spec.update(module_option_spec) |
| 236 |
check_galaxy_version(module_arg_spec) |
| 237 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'cifs_profile'), |
| 238 |
supports_check_mode=True) |
| 239 |
if not module._socket_path: |
| 240 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 241 |
connection = Connection(module._socket_path) |
| 242 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 243 |
'name', 'data', module, connection) |
| 244 |
fmgr.process_crud() |
| 245 |
module.exit_json(meta=module.params) |
| 246 |
|
| 247 |
|
| 248 |
if __name__ == '__main__': |
| 249 |
main() |