2016-06-10 12:43:19 +02:00
|
|
|
#!/usr/bin/python
|
2016-05-24 17:02:17 +02:00
|
|
|
# -*- coding: UTF-8 -*-
|
|
|
|
|
2016-06-10 12:44:26 +02:00
|
|
|
# Copyright (c) 2016, Adfinis SyGroup AG
|
|
|
|
# Tobias Rueetschi <tobias.ruetschi@adfinis-sygroup.ch>
|
|
|
|
#
|
|
|
|
# This file is part of Ansible
|
|
|
|
#
|
|
|
|
# Ansible is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Ansible is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
2016-05-24 17:02:17 +02:00
|
|
|
|
2016-06-10 12:54:50 +02:00
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
2016-06-10 12:42:44 +02:00
|
|
|
from ansible.module_utils.univention_umc import (
|
|
|
|
umc_module_for_add,
|
|
|
|
umc_module_for_edit,
|
|
|
|
ldap_search,
|
|
|
|
base_dn,
|
2016-05-24 17:02:17 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2016-06-10 14:09:25 +02:00
|
|
|
DOCUMENTATION = '''
|
|
|
|
---
|
|
|
|
module: udm_share
|
|
|
|
version_added: "2.2"
|
|
|
|
author: "Tobias Rueetschi (@2-B)"
|
|
|
|
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:
|
|
|
|
required: false
|
|
|
|
default: "present"
|
|
|
|
choices: [ present, absent ]
|
|
|
|
description:
|
|
|
|
- Whether the share is present or not.
|
|
|
|
name:
|
|
|
|
required: true
|
|
|
|
description:
|
|
|
|
- Name
|
|
|
|
host:
|
|
|
|
required: false
|
|
|
|
default: None
|
|
|
|
description:
|
2016-06-16 16:27:01 +02:00
|
|
|
- Host FQDN (server which provides the share), e.g. C({{
|
|
|
|
ansible_fqdn }}). Required if C(state=present).
|
|
|
|
path:
|
|
|
|
required: false
|
|
|
|
default: None
|
|
|
|
description:
|
|
|
|
- Directory on the providing server, e.g. C(/home). Required if C(state=present).
|
2016-08-30 19:04:42 +02:00
|
|
|
samba_name:
|
2016-06-16 16:27:01 +02:00
|
|
|
required: false
|
|
|
|
default: None
|
|
|
|
description:
|
|
|
|
- Windows name. Required if C(state=present).
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaName ]
|
2016-06-10 14:09:25 +02:00
|
|
|
ou:
|
|
|
|
required: true
|
|
|
|
description:
|
|
|
|
- Organisational unit, inside the LDAP Base DN.
|
|
|
|
owner:
|
|
|
|
required: false
|
|
|
|
default: 0
|
|
|
|
description:
|
|
|
|
- Directory owner of the share's root directory.
|
|
|
|
group:
|
|
|
|
required: false
|
|
|
|
default: '0'
|
|
|
|
description:
|
|
|
|
- Directory owner group of the share's root directory.
|
|
|
|
directorymode:
|
|
|
|
required: false
|
|
|
|
default: '00755'
|
|
|
|
description:
|
|
|
|
- Permissions for the share's root directory.
|
|
|
|
root_squash:
|
|
|
|
required: false
|
|
|
|
default: '1'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Modify user ID for root user (root squashing).
|
|
|
|
subtree_checking:
|
|
|
|
required: false
|
|
|
|
default: '1'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Subtree checking.
|
|
|
|
sync:
|
|
|
|
required: false
|
|
|
|
default: 'sync'
|
|
|
|
description:
|
|
|
|
- NFS synchronisation.
|
|
|
|
writeable:
|
|
|
|
required: false
|
|
|
|
default: '1'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- NFS write access.
|
2016-08-30 19:04:42 +02:00
|
|
|
samba_block_size:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: None
|
|
|
|
description:
|
|
|
|
- Blocking size.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaBlockSize ]
|
|
|
|
samba_blocking_locks:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '1'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Blocking locks.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaBlockingLocks ]
|
|
|
|
samba_browseable:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '1'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Show in Windows network environment.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaBrowseable ]
|
|
|
|
samba_create_mode:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '0744'
|
|
|
|
description:
|
|
|
|
- File mode.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaCreateMode ]
|
|
|
|
samba_csc_policy:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: 'manual'
|
|
|
|
description:
|
|
|
|
- Client-side caching policy.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaCscPolicy ]
|
|
|
|
samba_custom_settings:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: []
|
|
|
|
description:
|
|
|
|
- Option name in smb.conf and its value.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaCustomSettings ]
|
|
|
|
samba_directory_mode:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '0755'
|
|
|
|
description:
|
|
|
|
- Directory mode.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaDirectoryMode ]
|
|
|
|
samba_directory_security_mode:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '0777'
|
|
|
|
description:
|
|
|
|
- Directory security mode.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaDirectorySecurityMode ]
|
|
|
|
samba_dos_filemode:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '0'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Users with write access may modify permissions.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaDosFilemode ]
|
|
|
|
samba_fake_oplocks:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '0'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Fake oplocks.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaFakeOplocks ]
|
|
|
|
samba_force_create_mode:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '0'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Force file mode.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaForceCreateMode ]
|
|
|
|
samba_force_directory_mode:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '0'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Force directory mode.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaForceDirectoryMode ]
|
|
|
|
samba_force_directory_security_mode:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '0'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Force directory security mode.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaForceDirectorySecurityMode ]
|
|
|
|
samba_force_group:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: None
|
|
|
|
description:
|
|
|
|
- Force group.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaForceGroup ]
|
|
|
|
samba_force_security_mode:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '0'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Force security mode.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaForceSecurityMode ]
|
|
|
|
samba_force_user:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: None
|
|
|
|
description:
|
|
|
|
- Force user.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaForceUser ]
|
|
|
|
samba_hide_files:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: None
|
|
|
|
description:
|
|
|
|
- Hide files.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaHideFiles ]
|
|
|
|
samba_hide_unreadable:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '0'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Hide unreadable files/directories.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaHideUnreadable ]
|
|
|
|
samba_hosts_allow:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: []
|
|
|
|
description:
|
|
|
|
- Allowed host/network.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaHostsAllow ]
|
|
|
|
samba_hosts_deny:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: []
|
|
|
|
description:
|
|
|
|
- Denied host/network.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaHostsDeny ]
|
|
|
|
samba_inherit_acls:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '1'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Inherit ACLs.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaInheritAcls ]
|
|
|
|
samba_inherit_owner:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '0'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Create files/directories with the owner of the parent directory.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaInheritOwner ]
|
|
|
|
samba_inherit_permissions:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '0'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Create files/directories with permissions of the parent directory.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaInheritPermissions ]
|
|
|
|
samba_invalid_users:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: None
|
|
|
|
description:
|
|
|
|
- Invalid users or groups.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaInvalidUsers ]
|
|
|
|
samba_level_2_oplocks:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '1'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Level 2 oplocks.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaLevel2Oplocks ]
|
|
|
|
samba_locking:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '1'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Locking.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaLocking ]
|
|
|
|
samba_msdfs_root:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '0'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- MSDFS root.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaMSDFSRoot ]
|
|
|
|
samba_nt_acl_support:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '1'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- NT ACL support.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaNtAclSupport ]
|
|
|
|
samba_oplocks:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '1'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Oplocks.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaOplocks ]
|
|
|
|
samba_postexec:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: None
|
|
|
|
description:
|
|
|
|
- Postexec script.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaPostexec ]
|
|
|
|
samba_preexec:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: None
|
|
|
|
description:
|
|
|
|
- Preexec script.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaPreexec ]
|
|
|
|
samba_public:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '0'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Allow anonymous read-only access with a guest user.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaPublic ]
|
|
|
|
samba_security_mode:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '0777'
|
|
|
|
description:
|
|
|
|
- Security mode.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaSecurityMode ]
|
|
|
|
samba_strict_locking:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: 'Auto'
|
|
|
|
description:
|
|
|
|
- Strict locking.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaStrictLocking ]
|
|
|
|
samba_vfs_objects:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: None
|
|
|
|
description:
|
|
|
|
- VFS objects.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaVFSObjects ]
|
|
|
|
samba_valid_users:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: None
|
|
|
|
description:
|
|
|
|
- Valid users or groups.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaValidUsers ]
|
|
|
|
samba_write_list:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: None
|
|
|
|
description:
|
|
|
|
- Restrict write access to these users/groups.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaWriteList ]
|
|
|
|
samba_writeable:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: '1'
|
2016-06-16 17:16:21 +02:00
|
|
|
choices: [ '0', '1' ]
|
2016-06-10 14:09:25 +02:00
|
|
|
description:
|
|
|
|
- Samba write access.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ sambaWriteable ]
|
2016-06-10 14:09:25 +02:00
|
|
|
nfs_hosts:
|
|
|
|
required: false
|
|
|
|
default: []
|
|
|
|
description:
|
|
|
|
- Only allow access for this host, IP address or network.
|
2016-08-30 19:04:42 +02:00
|
|
|
nfs_custom_settings:
|
2016-06-10 14:09:25 +02:00
|
|
|
required: false
|
|
|
|
default: []
|
|
|
|
description:
|
|
|
|
- Option name in exports file.
|
2016-08-30 19:04:42 +02:00
|
|
|
aliases: [ nfsCustomSettings ]
|
2016-06-10 14:09:25 +02:00
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
2016-06-16 17:19:53 +02:00
|
|
|
# Create a share named home on the server ucs.example.com with the path /home.
|
2016-09-01 22:47:38 +02:00
|
|
|
- udm_share: name=home
|
2016-06-16 17:19:53 +02:00
|
|
|
path=/home
|
|
|
|
host=ucs.example.com
|
|
|
|
sambaName=Home
|
2016-06-10 14:09:25 +02:00
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
RETURN = '''# '''
|
|
|
|
|
|
|
|
|
2016-05-24 17:02:17 +02:00
|
|
|
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'),
|
|
|
|
path = dict(type='path',
|
|
|
|
default=None),
|
|
|
|
directorymode = dict(type='str',
|
|
|
|
default='00755'),
|
|
|
|
host = dict(type='str',
|
|
|
|
default=None),
|
2016-06-16 17:16:21 +02:00
|
|
|
root_squash = dict(type='bool',
|
|
|
|
default=True),
|
|
|
|
subtree_checking = dict(type='bool',
|
|
|
|
default=True),
|
2016-05-24 17:02:17 +02:00
|
|
|
sync = dict(type='str',
|
|
|
|
default='sync'),
|
2016-06-16 17:16:21 +02:00
|
|
|
writeable = dict(type='bool',
|
|
|
|
default=True),
|
2016-05-24 17:02:17 +02:00
|
|
|
sambaBlockSize = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_block_size'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default=None),
|
2016-06-16 17:16:21 +02:00
|
|
|
sambaBlockingLocks = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_blocking_locks'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=True),
|
|
|
|
sambaBrowseable = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_browsable'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=True),
|
2016-05-24 17:02:17 +02:00
|
|
|
sambaCreateMode = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_create_mode'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default='0744'),
|
|
|
|
sambaCscPolicy = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_csc_policy'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default='manual'),
|
|
|
|
sambaCustomSettings = dict(type='list',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_custom_settings'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default=[]),
|
|
|
|
sambaDirectoryMode = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_directory_mode'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default='0755'),
|
|
|
|
sambaDirectorySecurityMode = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_directory_security_mode'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default='0777'),
|
2016-06-16 17:16:21 +02:00
|
|
|
sambaDosFilemode = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_dos_filemode'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=False),
|
|
|
|
sambaFakeOplocks = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_fake_oplocks'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=False),
|
|
|
|
sambaForceCreateMode = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_force_create_mode'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=False),
|
|
|
|
sambaForceDirectoryMode = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_force_directory_mode'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=False),
|
|
|
|
sambaForceDirectorySecurityMode = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_force_directory_security_mode'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=False),
|
2016-05-24 17:02:17 +02:00
|
|
|
sambaForceGroup = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_force_group'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default=None),
|
2016-06-16 17:16:21 +02:00
|
|
|
sambaForceSecurityMode = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_force_security_mode'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=False),
|
2016-05-24 17:02:17 +02:00
|
|
|
sambaForceUser = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_force_user'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default=None),
|
|
|
|
sambaHideFiles = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_hide_files'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default=None),
|
2016-06-16 17:16:21 +02:00
|
|
|
sambaHideUnreadable = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_hide_unreadable'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=False),
|
2016-05-24 17:02:17 +02:00
|
|
|
sambaHostsAllow = dict(type='list',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_hosts_allow'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default=[]),
|
|
|
|
sambaHostsDeny = dict(type='list',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_hosts_deny'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default=[]),
|
2016-06-16 17:16:21 +02:00
|
|
|
sambaInheritAcls = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_inherit_acls'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=True),
|
|
|
|
sambaInheritOwner = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_inherit_owner'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=False),
|
|
|
|
sambaInheritPermissions = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_inherit_permissions'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=False),
|
2016-05-24 17:02:17 +02:00
|
|
|
sambaInvalidUsers = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_invalid_users'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default=None),
|
2016-06-16 17:16:21 +02:00
|
|
|
sambaLevel2Oplocks = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_level_2_oplocks'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=True),
|
|
|
|
sambaLocking = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_locking'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=True),
|
|
|
|
sambaMSDFSRoot = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_msdfs_root'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=False),
|
2016-05-24 17:02:17 +02:00
|
|
|
sambaName = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_name'],
|
2016-06-07 14:48:58 +02:00
|
|
|
default=None),
|
2016-06-16 17:16:21 +02:00
|
|
|
sambaNtAclSupport = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_nt_acl_support'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=True),
|
|
|
|
sambaOplocks = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_oplocks'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=True),
|
2016-05-24 17:02:17 +02:00
|
|
|
sambaPostexec = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_postexec'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default=None),
|
|
|
|
sambaPreexec = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_preexec'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default=None),
|
2016-06-16 17:16:21 +02:00
|
|
|
sambaPublic = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_public'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=False),
|
2016-05-24 17:02:17 +02:00
|
|
|
sambaSecurityMode = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_security_mode'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default='0777'),
|
|
|
|
sambaStrictLocking = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_strict_locking'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default='Auto'),
|
|
|
|
sambaVFSObjects = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_vfs_objects'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default=None),
|
|
|
|
sambaValidUsers = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_valid_users'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default=None),
|
|
|
|
sambaWriteList = dict(type='str',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_write_list'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default=None),
|
2016-06-16 17:16:21 +02:00
|
|
|
sambaWriteable = dict(type='bool',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['samba_writeable'],
|
2016-06-16 17:16:21 +02:00
|
|
|
default=True),
|
2016-05-24 17:02:17 +02:00
|
|
|
nfs_hosts = dict(type='list',
|
|
|
|
default=[]),
|
|
|
|
nfsCustomSettings = dict(type='list',
|
2016-08-30 19:12:24 +02:00
|
|
|
aliases=['nfs_custom_settings'],
|
2016-05-24 17:02:17 +02:00
|
|
|
default=[]),
|
2016-08-30 18:04:41 +02:00
|
|
|
state = dict(default='present',
|
|
|
|
choices=['present', 'absent'],
|
|
|
|
type='str')
|
2016-05-24 17:02:17 +02:00
|
|
|
),
|
2016-06-10 12:43:39 +02:00
|
|
|
supports_check_mode=True,
|
|
|
|
required_if = ([
|
|
|
|
('state', 'present', ['path', 'host', 'sambaName'])
|
|
|
|
])
|
2016-05-24 17:02:17 +02:00
|
|
|
)
|
|
|
|
name = module.params['name']
|
|
|
|
state = module.params['state']
|
|
|
|
changed = False
|
|
|
|
|
|
|
|
obj = list(ldap_search(
|
|
|
|
'(&(objectClass=univentionShare)(cn={}))'.format(name),
|
|
|
|
attr=['cn']
|
|
|
|
))
|
|
|
|
|
|
|
|
exists = bool(len(obj))
|
2016-06-10 12:42:44 +02:00
|
|
|
container = 'cn=shares,ou={},{}'.format(module.params['ou'], base_dn())
|
2016-05-24 17:02:17 +02:00
|
|
|
dn = 'cn={},{}'.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'] = '{} ({})'.format(name, module.params['host'])
|
|
|
|
for k in obj.keys():
|
2016-08-30 18:04:41 +02:00
|
|
|
if module.params[k] is True:
|
2016-06-16 17:16:21 +02:00
|
|
|
module.params[k] = '1'
|
2016-08-30 18:04:41 +02:00
|
|
|
elif module.params[k] is False:
|
2016-06-16 17:16:21 +02:00
|
|
|
module.params[k] = '0'
|
2016-05-24 17:02:17 +02:00
|
|
|
obj[k] = module.params[k]
|
|
|
|
|
|
|
|
diff = obj.diff()
|
2016-06-07 14:48:58 +02:00
|
|
|
if exists:
|
|
|
|
for k in obj.keys():
|
|
|
|
if obj.hasChanged(k):
|
2016-08-30 18:04:41 +02:00
|
|
|
changed = True
|
2016-06-07 14:48:58 +02:00
|
|
|
else:
|
2016-08-30 18:04:41 +02:00
|
|
|
changed = True
|
2016-05-24 17:02:17 +02:00
|
|
|
if not module.check_mode:
|
|
|
|
if not exists:
|
|
|
|
obj.create()
|
|
|
|
elif changed:
|
|
|
|
obj.modify()
|
2016-08-30 18:04:41 +02:00
|
|
|
except BaseException as err:
|
2016-05-24 17:02:17 +02:00
|
|
|
module.fail_json(
|
2016-08-30 18:04:41 +02:00
|
|
|
msg='Creating/editing share {} in {} failed: {}'.format(
|
|
|
|
name,
|
|
|
|
container,
|
|
|
|
err,
|
|
|
|
)
|
2016-05-24 17:02:17 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
if state == 'absent' and exists:
|
|
|
|
try:
|
|
|
|
obj = umc_module_for_edit('shares/share', dn)
|
|
|
|
if not module.check_mode:
|
|
|
|
obj.remove()
|
|
|
|
changed = True
|
2016-08-30 18:04:41 +02:00
|
|
|
except BaseException as err:
|
2016-05-24 17:02:17 +02:00
|
|
|
module.fail_json(
|
2016-08-30 18:04:41 +02:00
|
|
|
msg='Removing share {} in {} failed: {}'.format(
|
|
|
|
name,
|
|
|
|
container,
|
|
|
|
err,
|
|
|
|
)
|
2016-05-24 17:02:17 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
module.exit_json(
|
|
|
|
changed=changed,
|
|
|
|
name=name,
|
|
|
|
diff=diff,
|
|
|
|
container=container
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|