2020-03-09 10:11:07 +01:00
|
|
|
#!/usr/bin/python
|
2021-08-08 10:40:22 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2022-08-05 13:17:19 +02:00
|
|
|
# Copyright (c) 2016, Adfinis SyGroup AG
|
2020-03-09 10:11:07 +01:00
|
|
|
# Tobias Rueetschi <tobias.ruetschi@adfinis-sygroup.ch>
|
2022-08-05 13:17:19 +02:00
|
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
---
|
|
|
|
module: udm_share
|
|
|
|
author:
|
|
|
|
- Tobias Rüetschi (@keachi)
|
|
|
|
short_description: Manage samba shares on a univention corporate server
|
|
|
|
description:
|
|
|
|
- "This module allows to manage samba shares on a univention corporate
|
|
|
|
server (UCS).
|
|
|
|
It uses the python API of the UCS to create a new object or edit it."
|
|
|
|
requirements:
|
|
|
|
- Python >= 2.6
|
|
|
|
options:
|
|
|
|
state:
|
|
|
|
default: "present"
|
|
|
|
choices: [ present, absent ]
|
|
|
|
description:
|
|
|
|
- Whether the share is present or not.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
name:
|
|
|
|
required: true
|
|
|
|
description:
|
|
|
|
- Name
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
host:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
- Host FQDN (server which provides the share), e.g. C({{
|
2022-09-06 08:05:16 +02:00
|
|
|
ansible_fqdn }}). Required if I(state=present).
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
path:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-09-06 08:05:16 +02:00
|
|
|
- Directory on the providing server, e.g. C(/home). Required if I(state=present).
|
2020-11-27 21:16:47 +01:00
|
|
|
type: path
|
|
|
|
sambaName:
|
2020-03-09 10:11:07 +01:00
|
|
|
required: false
|
|
|
|
description:
|
2022-09-06 08:05:16 +02:00
|
|
|
- Windows name. Required if I(state=present).
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_name ]
|
2020-03-09 10:11:07 +01:00
|
|
|
ou:
|
|
|
|
required: true
|
|
|
|
description:
|
|
|
|
- Organisational unit, inside the LDAP Base DN.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
owner:
|
2020-11-27 21:16:47 +01:00
|
|
|
default: '0'
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Directory owner of the share's root directory.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
group:
|
|
|
|
default: '0'
|
|
|
|
description:
|
|
|
|
- Directory owner group of the share's root directory.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
directorymode:
|
|
|
|
default: '00755'
|
|
|
|
description:
|
|
|
|
- Permissions for the share's root directory.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
root_squash:
|
2020-11-27 21:16:47 +01:00
|
|
|
default: true
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Modify user ID for root user (root squashing).
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
2020-03-09 10:11:07 +01:00
|
|
|
subtree_checking:
|
2020-11-27 21:16:47 +01:00
|
|
|
default: true
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Subtree checking.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
2020-03-09 10:11:07 +01:00
|
|
|
sync:
|
|
|
|
default: 'sync'
|
|
|
|
description:
|
|
|
|
- NFS synchronisation.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
writeable:
|
2020-11-27 21:16:47 +01:00
|
|
|
default: true
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- NFS write access.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
sambaBlockSize:
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Blocking size.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_block_size ]
|
|
|
|
sambaBlockingLocks:
|
|
|
|
default: true
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Blocking locks.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_blocking_locks ]
|
2020-11-26 12:27:37 +01:00
|
|
|
sambaBrowseable:
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
2020-11-26 12:27:37 +01:00
|
|
|
- Show in Windows network environment.
|
|
|
|
type: bool
|
|
|
|
default: True
|
|
|
|
aliases: [ samba_browsable ]
|
2020-11-27 21:16:47 +01:00
|
|
|
sambaCreateMode:
|
2020-03-09 10:11:07 +01:00
|
|
|
default: '0744'
|
|
|
|
description:
|
|
|
|
- File mode.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_create_mode ]
|
|
|
|
sambaCscPolicy:
|
2020-03-09 10:11:07 +01:00
|
|
|
default: 'manual'
|
|
|
|
description:
|
|
|
|
- Client-side caching policy.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_csc_policy ]
|
|
|
|
sambaCustomSettings:
|
2020-03-09 10:11:07 +01:00
|
|
|
default: []
|
|
|
|
description:
|
|
|
|
- Option name in smb.conf and its value.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: list
|
|
|
|
aliases: [ samba_custom_settings ]
|
|
|
|
sambaDirectoryMode:
|
2020-03-09 10:11:07 +01:00
|
|
|
default: '0755'
|
|
|
|
description:
|
|
|
|
- Directory mode.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_directory_mode ]
|
|
|
|
sambaDirectorySecurityMode:
|
2020-03-09 10:11:07 +01:00
|
|
|
default: '0777'
|
|
|
|
description:
|
|
|
|
- Directory security mode.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_directory_security_mode ]
|
|
|
|
sambaDosFilemode:
|
|
|
|
default: false
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Users with write access may modify permissions.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_dos_filemode ]
|
|
|
|
sambaFakeOplocks:
|
|
|
|
default: false
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Fake oplocks.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_fake_oplocks ]
|
|
|
|
sambaForceCreateMode:
|
|
|
|
default: false
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Force file mode.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_force_create_mode ]
|
|
|
|
sambaForceDirectoryMode:
|
|
|
|
default: false
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Force directory mode.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_force_directory_mode ]
|
|
|
|
sambaForceDirectorySecurityMode:
|
|
|
|
default: false
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Force directory security mode.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_force_directory_security_mode ]
|
|
|
|
sambaForceGroup:
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Force group.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_force_group ]
|
|
|
|
sambaForceSecurityMode:
|
|
|
|
default: false
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Force security mode.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_force_security_mode ]
|
|
|
|
sambaForceUser:
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Force user.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_force_user ]
|
|
|
|
sambaHideFiles:
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Hide files.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_hide_files ]
|
|
|
|
sambaHideUnreadable:
|
|
|
|
default: false
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Hide unreadable files/directories.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_hide_unreadable ]
|
|
|
|
sambaHostsAllow:
|
2020-03-09 10:11:07 +01:00
|
|
|
default: []
|
|
|
|
description:
|
|
|
|
- Allowed host/network.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: list
|
|
|
|
aliases: [ samba_hosts_allow ]
|
|
|
|
sambaHostsDeny:
|
2020-03-09 10:11:07 +01:00
|
|
|
default: []
|
|
|
|
description:
|
|
|
|
- Denied host/network.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: list
|
|
|
|
aliases: [ samba_hosts_deny ]
|
|
|
|
sambaInheritAcls:
|
|
|
|
default: true
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Inherit ACLs.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_inherit_acls ]
|
|
|
|
sambaInheritOwner:
|
|
|
|
default: false
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Create files/directories with the owner of the parent directory.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_inherit_owner ]
|
|
|
|
sambaInheritPermissions:
|
|
|
|
default: false
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Create files/directories with permissions of the parent directory.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_inherit_permissions ]
|
|
|
|
sambaInvalidUsers:
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Invalid users or groups.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_invalid_users ]
|
|
|
|
sambaLevel2Oplocks:
|
|
|
|
default: true
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Level 2 oplocks.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_level_2_oplocks ]
|
|
|
|
sambaLocking:
|
|
|
|
default: true
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Locking.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_locking ]
|
|
|
|
sambaMSDFSRoot:
|
|
|
|
default: false
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- MSDFS root.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_msdfs_root ]
|
|
|
|
sambaNtAclSupport:
|
|
|
|
default: true
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- NT ACL support.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_nt_acl_support ]
|
|
|
|
sambaOplocks:
|
|
|
|
default: true
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Oplocks.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_oplocks ]
|
|
|
|
sambaPostexec:
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Postexec script.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_postexec ]
|
|
|
|
sambaPreexec:
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Preexec script.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_preexec ]
|
|
|
|
sambaPublic:
|
|
|
|
default: false
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Allow anonymous read-only access with a guest user.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_public ]
|
|
|
|
sambaSecurityMode:
|
2020-03-09 10:11:07 +01:00
|
|
|
default: '0777'
|
|
|
|
description:
|
|
|
|
- Security mode.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_security_mode ]
|
|
|
|
sambaStrictLocking:
|
2020-03-09 10:11:07 +01:00
|
|
|
default: 'Auto'
|
|
|
|
description:
|
|
|
|
- Strict locking.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_strict_locking ]
|
|
|
|
sambaVFSObjects:
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- VFS objects.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_vfs_objects ]
|
|
|
|
sambaValidUsers:
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Valid users or groups.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_valid_users ]
|
|
|
|
sambaWriteList:
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Restrict write access to these users/groups.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: str
|
|
|
|
aliases: [ samba_write_list ]
|
|
|
|
sambaWriteable:
|
|
|
|
default: true
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Samba write access.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: bool
|
|
|
|
aliases: [ samba_writeable ]
|
2020-03-09 10:11:07 +01:00
|
|
|
nfs_hosts:
|
|
|
|
default: []
|
|
|
|
description:
|
|
|
|
- Only allow access for this host, IP address or network.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: list
|
|
|
|
nfsCustomSettings:
|
2020-03-09 10:11:07 +01:00
|
|
|
default: []
|
|
|
|
description:
|
|
|
|
- Option name in exports file.
|
2020-11-27 21:16:47 +01:00
|
|
|
type: list
|
|
|
|
aliases: [ nfs_custom_settings ]
|
2020-03-09 10:11:07 +01:00
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
2020-05-15 12:12:41 +02:00
|
|
|
- name: Create a share named home on the server ucs.example.com with the path /home
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.udm_share:
|
2020-03-09 10:11:07 +01:00
|
|
|
name: home
|
|
|
|
path: /home
|
|
|
|
host: ucs.example.com
|
|
|
|
sambaName: Home
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
RETURN = '''# '''
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
from ansible_collections.community.general.plugins.module_utils.univention_umc import (
|
|
|
|
umc_module_for_add,
|
|
|
|
umc_module_for_edit,
|
|
|
|
ldap_search,
|
|
|
|
base_dn,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
module = AnsibleModule(
|
|
|
|
argument_spec=dict(
|
|
|
|
name=dict(required=True,
|
|
|
|
type='str'),
|
|
|
|
ou=dict(required=True,
|
|
|
|
type='str'),
|
|
|
|
owner=dict(type='str',
|
|
|
|
default='0'),
|
|
|
|
group=dict(type='str',
|
|
|
|
default='0'),
|
2022-04-24 07:41:24 +02:00
|
|
|
path=dict(type='path'),
|
2020-03-09 10:11:07 +01:00
|
|
|
directorymode=dict(type='str',
|
|
|
|
default='00755'),
|
2022-04-24 07:41:24 +02:00
|
|
|
host=dict(type='str'),
|
2020-03-09 10:11:07 +01:00
|
|
|
root_squash=dict(type='bool',
|
|
|
|
default=True),
|
|
|
|
subtree_checking=dict(type='bool',
|
|
|
|
default=True),
|
|
|
|
sync=dict(type='str',
|
|
|
|
default='sync'),
|
|
|
|
writeable=dict(type='bool',
|
|
|
|
default=True),
|
|
|
|
sambaBlockSize=dict(type='str',
|
2022-04-24 07:41:24 +02:00
|
|
|
aliases=['samba_block_size']),
|
2020-03-09 10:11:07 +01:00
|
|
|
sambaBlockingLocks=dict(type='bool',
|
|
|
|
aliases=['samba_blocking_locks'],
|
|
|
|
default=True),
|
|
|
|
sambaBrowseable=dict(type='bool',
|
|
|
|
aliases=['samba_browsable'],
|
|
|
|
default=True),
|
|
|
|
sambaCreateMode=dict(type='str',
|
|
|
|
aliases=['samba_create_mode'],
|
|
|
|
default='0744'),
|
|
|
|
sambaCscPolicy=dict(type='str',
|
|
|
|
aliases=['samba_csc_policy'],
|
|
|
|
default='manual'),
|
|
|
|
sambaCustomSettings=dict(type='list',
|
|
|
|
aliases=['samba_custom_settings'],
|
|
|
|
default=[]),
|
|
|
|
sambaDirectoryMode=dict(type='str',
|
|
|
|
aliases=['samba_directory_mode'],
|
|
|
|
default='0755'),
|
|
|
|
sambaDirectorySecurityMode=dict(type='str',
|
|
|
|
aliases=['samba_directory_security_mode'],
|
|
|
|
default='0777'),
|
|
|
|
sambaDosFilemode=dict(type='bool',
|
|
|
|
aliases=['samba_dos_filemode'],
|
|
|
|
default=False),
|
|
|
|
sambaFakeOplocks=dict(type='bool',
|
|
|
|
aliases=['samba_fake_oplocks'],
|
|
|
|
default=False),
|
|
|
|
sambaForceCreateMode=dict(type='bool',
|
|
|
|
aliases=['samba_force_create_mode'],
|
|
|
|
default=False),
|
|
|
|
sambaForceDirectoryMode=dict(type='bool',
|
|
|
|
aliases=['samba_force_directory_mode'],
|
|
|
|
default=False),
|
|
|
|
sambaForceDirectorySecurityMode=dict(type='bool',
|
|
|
|
aliases=['samba_force_directory_security_mode'],
|
|
|
|
default=False),
|
|
|
|
sambaForceGroup=dict(type='str',
|
2022-04-24 07:41:24 +02:00
|
|
|
aliases=['samba_force_group']),
|
2020-03-09 10:11:07 +01:00
|
|
|
sambaForceSecurityMode=dict(type='bool',
|
|
|
|
aliases=['samba_force_security_mode'],
|
|
|
|
default=False),
|
|
|
|
sambaForceUser=dict(type='str',
|
2022-04-24 07:41:24 +02:00
|
|
|
aliases=['samba_force_user']),
|
2020-03-09 10:11:07 +01:00
|
|
|
sambaHideFiles=dict(type='str',
|
2022-04-24 07:41:24 +02:00
|
|
|
aliases=['samba_hide_files']),
|
2020-03-09 10:11:07 +01:00
|
|
|
sambaHideUnreadable=dict(type='bool',
|
|
|
|
aliases=['samba_hide_unreadable'],
|
|
|
|
default=False),
|
|
|
|
sambaHostsAllow=dict(type='list',
|
|
|
|
aliases=['samba_hosts_allow'],
|
|
|
|
default=[]),
|
|
|
|
sambaHostsDeny=dict(type='list',
|
|
|
|
aliases=['samba_hosts_deny'],
|
|
|
|
default=[]),
|
|
|
|
sambaInheritAcls=dict(type='bool',
|
|
|
|
aliases=['samba_inherit_acls'],
|
|
|
|
default=True),
|
|
|
|
sambaInheritOwner=dict(type='bool',
|
|
|
|
aliases=['samba_inherit_owner'],
|
|
|
|
default=False),
|
|
|
|
sambaInheritPermissions=dict(type='bool',
|
|
|
|
aliases=['samba_inherit_permissions'],
|
|
|
|
default=False),
|
|
|
|
sambaInvalidUsers=dict(type='str',
|
2022-04-24 07:41:24 +02:00
|
|
|
aliases=['samba_invalid_users']),
|
2020-03-09 10:11:07 +01:00
|
|
|
sambaLevel2Oplocks=dict(type='bool',
|
|
|
|
aliases=['samba_level_2_oplocks'],
|
|
|
|
default=True),
|
|
|
|
sambaLocking=dict(type='bool',
|
|
|
|
aliases=['samba_locking'],
|
|
|
|
default=True),
|
|
|
|
sambaMSDFSRoot=dict(type='bool',
|
|
|
|
aliases=['samba_msdfs_root'],
|
|
|
|
default=False),
|
|
|
|
sambaName=dict(type='str',
|
2022-04-24 07:41:24 +02:00
|
|
|
aliases=['samba_name']),
|
2020-03-09 10:11:07 +01:00
|
|
|
sambaNtAclSupport=dict(type='bool',
|
|
|
|
aliases=['samba_nt_acl_support'],
|
|
|
|
default=True),
|
|
|
|
sambaOplocks=dict(type='bool',
|
|
|
|
aliases=['samba_oplocks'],
|
|
|
|
default=True),
|
|
|
|
sambaPostexec=dict(type='str',
|
2022-04-24 07:41:24 +02:00
|
|
|
aliases=['samba_postexec']),
|
2020-03-09 10:11:07 +01:00
|
|
|
sambaPreexec=dict(type='str',
|
2022-04-24 07:41:24 +02:00
|
|
|
aliases=['samba_preexec']),
|
2020-03-09 10:11:07 +01:00
|
|
|
sambaPublic=dict(type='bool',
|
|
|
|
aliases=['samba_public'],
|
|
|
|
default=False),
|
|
|
|
sambaSecurityMode=dict(type='str',
|
|
|
|
aliases=['samba_security_mode'],
|
|
|
|
default='0777'),
|
|
|
|
sambaStrictLocking=dict(type='str',
|
|
|
|
aliases=['samba_strict_locking'],
|
|
|
|
default='Auto'),
|
|
|
|
sambaVFSObjects=dict(type='str',
|
2022-04-24 07:41:24 +02:00
|
|
|
aliases=['samba_vfs_objects']),
|
2020-03-09 10:11:07 +01:00
|
|
|
sambaValidUsers=dict(type='str',
|
2022-04-24 07:41:24 +02:00
|
|
|
aliases=['samba_valid_users']),
|
2020-03-09 10:11:07 +01:00
|
|
|
sambaWriteList=dict(type='str',
|
2022-04-24 07:41:24 +02:00
|
|
|
aliases=['samba_write_list']),
|
2020-03-09 10:11:07 +01:00
|
|
|
sambaWriteable=dict(type='bool',
|
|
|
|
aliases=['samba_writeable'],
|
|
|
|
default=True),
|
|
|
|
nfs_hosts=dict(type='list',
|
|
|
|
default=[]),
|
|
|
|
nfsCustomSettings=dict(type='list',
|
|
|
|
aliases=['nfs_custom_settings'],
|
|
|
|
default=[]),
|
|
|
|
state=dict(default='present',
|
|
|
|
choices=['present', 'absent'],
|
|
|
|
type='str')
|
|
|
|
),
|
|
|
|
supports_check_mode=True,
|
|
|
|
required_if=([
|
|
|
|
('state', 'present', ['path', 'host', 'sambaName'])
|
|
|
|
])
|
|
|
|
)
|
|
|
|
name = module.params['name']
|
|
|
|
state = module.params['state']
|
|
|
|
changed = False
|
|
|
|
diff = None
|
|
|
|
|
|
|
|
obj = list(ldap_search(
|
|
|
|
'(&(objectClass=univentionShare)(cn={0}))'.format(name),
|
|
|
|
attr=['cn']
|
|
|
|
))
|
|
|
|
|
|
|
|
exists = bool(len(obj))
|
|
|
|
container = 'cn=shares,ou={0},{1}'.format(module.params['ou'], base_dn())
|
|
|
|
dn = 'cn={0},{1}'.format(name, container)
|
|
|
|
|
|
|
|
if state == 'present':
|
|
|
|
try:
|
|
|
|
if not exists:
|
|
|
|
obj = umc_module_for_add('shares/share', container)
|
|
|
|
else:
|
|
|
|
obj = umc_module_for_edit('shares/share', dn)
|
|
|
|
|
|
|
|
module.params['printablename'] = '{0} ({1})'.format(name, module.params['host'])
|
|
|
|
for k in obj.keys():
|
|
|
|
if module.params[k] is True:
|
|
|
|
module.params[k] = '1'
|
|
|
|
elif module.params[k] is False:
|
|
|
|
module.params[k] = '0'
|
|
|
|
obj[k] = module.params[k]
|
|
|
|
|
|
|
|
diff = obj.diff()
|
|
|
|
if exists:
|
|
|
|
for k in obj.keys():
|
|
|
|
if obj.hasChanged(k):
|
|
|
|
changed = True
|
|
|
|
else:
|
|
|
|
changed = True
|
|
|
|
if not module.check_mode:
|
|
|
|
if not exists:
|
|
|
|
obj.create()
|
|
|
|
elif changed:
|
|
|
|
obj.modify()
|
|
|
|
except Exception as err:
|
|
|
|
module.fail_json(
|
|
|
|
msg='Creating/editing share {0} in {1} failed: {2}'.format(
|
|
|
|
name,
|
|
|
|
container,
|
|
|
|
err,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
if state == 'absent' and exists:
|
|
|
|
try:
|
|
|
|
obj = umc_module_for_edit('shares/share', dn)
|
|
|
|
if not module.check_mode:
|
|
|
|
obj.remove()
|
|
|
|
changed = True
|
|
|
|
except Exception as err:
|
|
|
|
module.fail_json(
|
|
|
|
msg='Removing share {0} in {1} failed: {2}'.format(
|
|
|
|
name,
|
|
|
|
container,
|
|
|
|
err,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
module.exit_json(
|
|
|
|
changed=changed,
|
|
|
|
name=name,
|
|
|
|
diff=diff,
|
|
|
|
container=container
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|