
    Vh#F                     l    d dl mZmZmZ eZdZdZdZd dl	m
Z
 d dlmZmZmZmZ d Zedk(  r e        y	y	)
    )absolute_importdivisionprint_functionu  
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.
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: partial
options:
  state:
    default: "present"
    choices: [present, absent]
    description:
      - Whether the share is present or not.
    type: str
  name:
    required: true
    description:
      - Name.
    type: str
  host:
    required: false
    description:
      - Host FQDN (server which provides the share), for example V({{ ansible_fqdn }}). Required if O(state=present).
    type: str
  path:
    required: false
    description:
      - Directory on the providing server, for example V(/home). Required if O(state=present).
    type: path
  sambaName:
    required: false
    description:
      - Windows name. Required if O(state=present).
    type: str
    aliases: [samba_name]
  ou:
    required: true
    description:
      - Organisational unit, inside the LDAP Base DN.
    type: str
  owner:
    default: '0'
    description:
      - Directory owner of the share's root directory.
    type: str
  group:
    default: '0'
    description:
      - Directory owner group of the share's root directory.
    type: str
  directorymode:
    default: '00755'
    description:
      - Permissions for the share's root directory.
    type: str
  root_squash:
    default: true
    description:
      - Modify user ID for root user (root squashing).
    type: bool
  subtree_checking:
    default: true
    description:
      - Subtree checking.
    type: bool
  sync:
    default: 'sync'
    description:
      - NFS synchronisation.
    type: str
  writeable:
    default: true
    description:
      - NFS write access.
    type: bool
  sambaBlockSize:
    description:
      - Blocking size.
    type: str
    aliases: [samba_block_size]
  sambaBlockingLocks:
    default: true
    description:
      - Blocking locks.
    type: bool
    aliases: [samba_blocking_locks]
  sambaBrowseable:
    description:
      - Show in Windows network environment.
    type: bool
    default: true
    aliases: [samba_browsable]
  sambaCreateMode:
    default: '0744'
    description:
      - File mode.
    type: str
    aliases: [samba_create_mode]
  sambaCscPolicy:
    default: 'manual'
    description:
      - Client-side caching policy.
    type: str
    aliases: [samba_csc_policy]
  sambaCustomSettings:
    default: []
    description:
      - Option name in C(smb.conf) and its value.
    type: list
    elements: dict
    aliases: [samba_custom_settings]
  sambaDirectoryMode:
    default: '0755'
    description:
      - Directory mode.
    type: str
    aliases: [samba_directory_mode]
  sambaDirectorySecurityMode:
    default: '0777'
    description:
      - Directory security mode.
    type: str
    aliases: [samba_directory_security_mode]
  sambaDosFilemode:
    default: false
    description:
      - Users with write access may modify permissions.
    type: bool
    aliases: [samba_dos_filemode]
  sambaFakeOplocks:
    default: false
    description:
      - Fake oplocks.
    type: bool
    aliases: [samba_fake_oplocks]
  sambaForceCreateMode:
    default: false
    description:
      - Force file mode.
    type: bool
    aliases: [samba_force_create_mode]
  sambaForceDirectoryMode:
    default: false
    description:
      - Force directory mode.
    type: bool
    aliases: [samba_force_directory_mode]
  sambaForceDirectorySecurityMode:
    default: false
    description:
      - Force directory security mode.
    type: bool
    aliases: [samba_force_directory_security_mode]
  sambaForceGroup:
    description:
      - Force group.
    type: str
    aliases: [samba_force_group]
  sambaForceSecurityMode:
    default: false
    description:
      - Force security mode.
    type: bool
    aliases: [samba_force_security_mode]
  sambaForceUser:
    description:
      - Force user.
    type: str
    aliases: [samba_force_user]
  sambaHideFiles:
    description:
      - Hide files.
    type: str
    aliases: [samba_hide_files]
  sambaHideUnreadable:
    default: false
    description:
      - Hide unreadable files/directories.
    type: bool
    aliases: [samba_hide_unreadable]
  sambaHostsAllow:
    default: []
    description:
      - Allowed host/network.
    type: list
    elements: str
    aliases: [samba_hosts_allow]
  sambaHostsDeny:
    default: []
    description:
      - Denied host/network.
    type: list
    elements: str
    aliases: [samba_hosts_deny]
  sambaInheritAcls:
    default: true
    description:
      - Inherit ACLs.
    type: bool
    aliases: [samba_inherit_acls]
  sambaInheritOwner:
    default: false
    description:
      - Create files/directories with the owner of the parent directory.
    type: bool
    aliases: [samba_inherit_owner]
  sambaInheritPermissions:
    default: false
    description:
      - Create files/directories with permissions of the parent directory.
    type: bool
    aliases: [samba_inherit_permissions]
  sambaInvalidUsers:
    description:
      - Invalid users or groups.
    type: str
    aliases: [samba_invalid_users]
  sambaLevel2Oplocks:
    default: true
    description:
      - Level 2 oplocks.
    type: bool
    aliases: [samba_level_2_oplocks]
  sambaLocking:
    default: true
    description:
      - Locking.
    type: bool
    aliases: [samba_locking]
  sambaMSDFSRoot:
    default: false
    description:
      - MSDFS root.
    type: bool
    aliases: [samba_msdfs_root]
  sambaNtAclSupport:
    default: true
    description:
      - NT ACL support.
    type: bool
    aliases: [samba_nt_acl_support]
  sambaOplocks:
    default: true
    description:
      - Oplocks.
    type: bool
    aliases: [samba_oplocks]
  sambaPostexec:
    description:
      - Postexec script.
    type: str
    aliases: [samba_postexec]
  sambaPreexec:
    description:
      - Preexec script.
    type: str
    aliases: [samba_preexec]
  sambaPublic:
    default: false
    description:
      - Allow anonymous read-only access with a guest user.
    type: bool
    aliases: [samba_public]
  sambaSecurityMode:
    default: '0777'
    description:
      - Security mode.
    type: str
    aliases: [samba_security_mode]
  sambaStrictLocking:
    default: 'Auto'
    description:
      - Strict locking.
    type: str
    aliases: [samba_strict_locking]
  sambaVFSObjects:
    description:
      - VFS objects.
    type: str
    aliases: [samba_vfs_objects]
  sambaValidUsers:
    description:
      - Valid users or groups.
    type: str
    aliases: [samba_valid_users]
  sambaWriteList:
    description:
      - Restrict write access to these users/groups.
    type: str
    aliases: [samba_write_list]
  sambaWriteable:
    default: true
    description:
      - Samba write access.
    type: bool
    aliases: [samba_writeable]
  nfs_hosts:
    default: []
    description:
      - Only allow access for this host, IP address or network.
    type: list
    elements: str
  nfsCustomSettings:
    default: []
    description:
      - Option name in exports file.
    type: list
    elements: str
    aliases: [nfs_custom_settings]
z
- name: Create a share named home on the server ucs.example.com with the path /home
  community.general.udm_share:
    name: home
    path: /home
    host: ucs.example.com
    sambaName: Home
#)AnsibleModule)umc_module_for_addumc_module_for_editldap_searchbase_dnc                     t        t        di dt        dd      dt        dd      dt        dd      d	t        dd      d
t        d
      dt        dd      dt        d      dt        dd      dt        dd      dt        dd      dt        dd      dt        ddg      dt        ddgd      dt        ddgd      dt        ddgd      dt        dd gd!      d"t        d#d$d%gg &      d't        dd(gd)      d*t        dd+gd,      d-t        dd.gd/      d0t        dd1gd/      d2t        dd3gd/      d4t        dd5gd/      d6t        dd7gd/      d8t        dd9g      d:t        dd;gd/      d<t        dd=g      d>t        dd?g      d@t        ddAgd/      dBt        d#ddCgg &      dDt        d#ddEgg &      dFt        ddGgd      dHt        ddIgd/      dJt        ddKgd/      dLt        ddMg      dNt        ddOgd      dPt        ddQgd      dRt        ddSgd/      dTt        ddUg      dVt        ddWgd      dXt        ddYgd      dZt        dd[g      d\t        dd]g      d^t        dd_gd/      d`t        ddagd,      dbt        ddcgdd      det        ddfg      dgt        ddhg      dit        ddjg      dkt        ddlgd      dmt        d#dg n      dot        d#ddpgg &      dqt        drdrdsgdt      ddqdrg dufgv      } | j                  d   }| j                  dq   }d/}d }t        t	        dwj                  |      dxgy            }t        t        |            }dzj                  | j                  d   t                     }d{j                  ||      }|drk(  r	 |st        d||      }nt        d||      }d}j                  || j                  d         | j                  d~<   |j                         D ]U  }	| j                  |	   du rd| j                  |	<   n | j                  |	   d/u rd| j                  |	<   | j                  |	   ||	<   W |j                         }|r*|j                         D ]  }	|j                  |	      sd} nd}| j                  s%|s|j                          n|r|j!                          |dsk(  r-|r+	 t        d||      }| j                  s|j'                          d}| j)                  ||||       y # t"        $ r-}
| j%                  dj                  |||
             Y d }
~
yd }
~
ww xY w# t"        $ r-}
| j%                  dj                  |||
             Y d }
~
d }
~
ww xY w)NnameTstr)requiredtypeouowner0)r   defaultgrouppath)r   directorymode00755hostroot_squashboolsubtree_checkingsync	writeablesambaBlockSizesamba_block_size)r   aliasessambaBlockingLockssamba_blocking_locks)r   r!   r   sambaBrowseablesamba_browsablesambaCreateModesamba_create_mode0744sambaCscPolicysamba_csc_policymanualsambaCustomSettingslistdictsamba_custom_settings)r   elementsr!   r   sambaDirectoryModesamba_directory_mode0755sambaDirectorySecurityModesamba_directory_security_mode0777sambaDosFilemodesamba_dos_filemodeFsambaFakeOplockssamba_fake_oplockssambaForceCreateModesamba_force_create_modesambaForceDirectoryModesamba_force_directory_modesambaForceDirectorySecurityMode#samba_force_directory_security_modesambaForceGroupsamba_force_groupsambaForceSecurityModesamba_force_security_modesambaForceUsersamba_force_usersambaHideFilessamba_hide_filessambaHideUnreadablesamba_hide_unreadablesambaHostsAllowsamba_hosts_allowsambaHostsDenysamba_hosts_denysambaInheritAclssamba_inherit_aclssambaInheritOwnersamba_inherit_ownersambaInheritPermissionssamba_inherit_permissionssambaInvalidUserssamba_invalid_userssambaLevel2Oplockssamba_level_2_oplockssambaLockingsamba_lockingsambaMSDFSRootsamba_msdfs_root	sambaName
samba_namesambaNtAclSupportsamba_nt_acl_supportsambaOplockssamba_oplockssambaPostexecsamba_postexecsambaPreexecsamba_preexecsambaPublicsamba_publicsambaSecurityModesamba_security_modesambaStrictLockingsamba_strict_lockingAutosambaVFSObjectssamba_vfs_objectssambaValidUserssamba_valid_userssambaWriteListsamba_write_listsambaWriteablesamba_writeable	nfs_hosts)r   r0   r   nfsCustomSettingsnfs_custom_settingsstatepresentabsent)r   choicesr   )r   r   r]   )argument_specsupports_check_moderequired_ifz((&(objectClass=univentionShare)(cn={0}))cn)attrzcn=shares,ou={0},{1}z
cn={0},{1}zshares/sharez	{0} ({1})printablename1z-Creating/editing share {0} in {1} failed: {2})msgz%Removing share {0} in {1} failed: {2})changedr   diff	container )r   r.   paramsr-   r
   formatr   lenr   r   r	   keysr   
hasChanged
check_modecreatemodify	Exception	fail_jsonremove	exit_json)moduler   ry   r   r   objexistsr   dnkerrs              o/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/udm_share.pymainr   b  s!    L
t "L
 T L

 E"$L
 E"$L
 6"L
 E'.0L
 5!L
 &%)+L
 "v*.0L
" 5$&#L
& #')'L
*  U);(<>+L
.  $-C,D,0 2/L
4 !f*;)<)-/5L
: !e*=)>)/1;L
@  U);(<(02AL
F !%&.4.E-F-/!1GL
N  $-C,D,2 4OL
T (,5T4U4:(<UL
Z "v+?*@*/1[L
` "v+?*@*/1aL
f "&6/H.I.3"5gL
l %)f2N1O16%8mL
r -1f:_9`9>-@sL
x !e*=)>@yL
| $(V1L0M05$7}L
B  U);(<>CL
F  U);(<>GL
J !%&.E-F-2!4KL
P !f*/*=)>)+-QL
X  V).);(<(*,YL
` "v+?*@*.0aL
f #,A+B+02gL
l %)f2M1N16%8mL
r #,A+BDsL
v  $-D,E,0 2wL
| 6'6&7&*,}L
B  V);(<(-/CL
H $0>3IL
L #,B+C+/1ML
R 6'6&7&*,SL
X E(8'9;YL
\ 5'6&79]L
` &&4%5%*,aL
f #,A+B+13gL
l  $-C,D,2 4mL
r !e*=)>@sL
v !e*=)>@wL
z  U);(<>{L
~  V):(;(,.L
D $)#%'EL
J #,1,A+B+-/KL
R y )84!#SL
Z !i!>?
_RFf == DMM'"EGD
{299$?V C
 #c(^F&--fmmD.A79MI			T9	-B	!	(C)."=-8-?-?fmmTZF[-\FMM/*XXZ *==#t+'*FMM!$]]1%.'*FMM!$q)A* 88:D 'A~~a("&' $$JJLJJL V	%nb9C$$

G 	  1  	CJJ   	  	;BB   	s7   )C%U 8U *V 	V#V  V	V>#V99V>__main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   Iansible_collections.community.general.plugins.module_utils.univention_umcr   r	   r
   r   r   __name__r       r   <module>r      sR    A @}@
 
 4 Zz zF r   