| 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_user_krbkeytab |
| 15 |
short_description: Configure Kerberos keytab entries. |
| 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 |
user_krbkeytab: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
keytab: |
| 34 |
type: str |
| 35 |
description: Base64 coded keytab file containing a pre-shared key. |
| 36 |
ldap_server: |
| 37 |
aliases: ['ldap-server'] |
| 38 |
type: raw |
| 39 |
description: (list or str) LDAP server name. |
| 40 |
name: |
| 41 |
type: str |
| 42 |
description: Kerberos keytab entry name. |
| 43 |
required: true |
| 44 |
pac_data: |
| 45 |
aliases: ['pac-data'] |
| 46 |
type: str |
| 47 |
description: Enable/disable parsing PAC data in the ticket. |
| 48 |
choices: ['disable', 'enable'] |
| 49 |
principal: |
| 50 |
type: str |
| 51 |
description: Kerberos service principal, e. |
| 52 |
password: |
| 53 |
type: raw |
| 54 |
description: (list) Password for keytab. |
| 55 |
''' |
| 56 |
|
| 57 |
EXAMPLES = ''' |
| 58 |
- name: Example playbook (generated based on argument schema) |
| 59 |
hosts: fortimanagers |
| 60 |
connection: httpapi |
| 61 |
gather_facts: false |
| 62 |
tasks: |
| 63 |
- name: Configure Kerberos keytab entries. |
| 64 |
fortinet.fortimanager.fmgr_user_krbkeytab: |
| 65 |
# workspace_locking_adom: <global or your adom name> |
| 66 |
adom: <your own value> |
| 67 |
state: present # <value in [present, absent]> |
| 68 |
user_krbkeytab: |
| 69 |
name: "your value" # Required variable, string |
| 70 |
# keytab: <string> |
| 71 |
# ldap_server: <list or string> |
| 72 |
# pac_data: <value in [disable, enable]> |
| 73 |
# principal: <string> |
| 74 |
# password: <list or string> |
| 75 |
''' |
| 76 |
|
| 77 |
RETURN = ''' |
| 78 |
meta: |
| 79 |
description: The result of the request. |
| 80 |
type: dict |
| 81 |
returned: always |
| 82 |
contains: |
| 83 |
request_url: |
| 84 |
description: The full url requested. |
| 85 |
returned: always |
| 86 |
type: str |
| 87 |
sample: /sys/login/user |
| 88 |
response_code: |
| 89 |
description: The status of api request. |
| 90 |
returned: always |
| 91 |
type: int |
| 92 |
sample: 0 |
| 93 |
response_data: |
| 94 |
description: The api response. |
| 95 |
type: list |
| 96 |
returned: always |
| 97 |
response_message: |
| 98 |
description: The descriptive message of the api response. |
| 99 |
type: str |
| 100 |
returned: always |
| 101 |
sample: OK. |
| 102 |
system_information: |
| 103 |
description: The information of the target system. |
| 104 |
type: dict |
| 105 |
returned: always |
| 106 |
rc: |
| 107 |
description: The status the request. |
| 108 |
type: int |
| 109 |
returned: always |
| 110 |
sample: 0 |
| 111 |
version_check_warning: |
| 112 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 113 |
type: list |
| 114 |
returned: complex |
| 115 |
''' |
| 116 |
from ansible.module_utils.basic import AnsibleModule |
| 117 |
from ansible.module_utils.connection import Connection |
| 118 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 119 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 120 |
|
| 121 |
|
| 122 |
def main(): |
| 123 |
urls_list = [ |
| 124 |
'/pm/config/adom/{adom}/obj/user/krb-keytab', |
| 125 |
'/pm/config/global/obj/user/krb-keytab' |
| 126 |
] |
| 127 |
module_arg_spec = { |
| 128 |
'adom': {'required': True, 'type': 'str'}, |
| 129 |
'revision_note': {'type': 'str'}, |
| 130 |
'user_krbkeytab': { |
| 131 |
'type': 'dict', 'v_range': [['6.2.1', '']], 'no_log': False, |
| 132 |
'options': { |
| 133 |
'keytab': {'v_range': [['6.2.1', '']], 'no_log': True, 'type': 'str'}, |
| 134 |
'ldap-server': {'v_range': [['6.2.1', '']], 'type': 'raw'}, |
| 135 |
'name': {'v_range': [['6.2.1', '']], 'required': True, 'type': 'str'}, |
| 136 |
'pac-data': {'v_range': [['6.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 137 |
'principal': {'v_range': [['6.2.1', '']], 'type': 'str'}, |
| 138 |
'password': {'v_range': [['6.2.2', '7.2.0'], ['7.2.5', '7.2.12'], ['7.4.2', '']], 'no_log': True, 'type': 'raw'} |
| 139 |
} |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
module_option_spec = get_module_arg_spec('full crud') |
| 144 |
module_arg_spec.update(module_option_spec) |
| 145 |
check_galaxy_version(module_arg_spec) |
| 146 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_krbkeytab'), |
| 147 |
supports_check_mode=True) |
| 148 |
if not module._socket_path: |
| 149 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 150 |
connection = Connection(module._socket_path) |
| 151 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 152 |
'name', 'data', module, connection) |
| 153 |
fmgr.process_crud() |
| 154 |
module.exit_json(meta=module.params) |
| 155 |
|
| 156 |
|
| 157 |
if __name__ == '__main__': |
| 158 |
main() |