win_share – Manage Windows shares

Synopsis

  • Add, modify or remove Windows share and set share permissions.

Requirements

The below requirements are needed on the host that executes this module.

  • As this module used newer cmdlets like New-SmbShare this can only run on Windows 8 / Windows 2012 or newer.

  • This is due to the reliance on the WMI provider MSFT_SmbShare https://msdn.microsoft.com/en-us/library/hh830471 which was only added with these Windows releases.

Parameters

Parameter Choices/Defaults Comments
caching_mode
string
    Choices:
  • BranchCache
  • Documents
  • Manual ←
  • None
  • Programs
  • Unknown
Set the CachingMode for this share.
change
string
Specify user list that should get read and write access on share, separated by comma.
deny
string
Specify user list that should get no access, regardless of implied access on share, separated by comma.
description
string
Share description.
encrypt
boolean
added in 2.4
    Choices:
  • no ←
  • yes
Sets whether to encrypt the traffic to the share or not.
full
string
Specify user list that should get full access on share, separated by comma.
list
boolean
    Choices:
  • no ←
  • yes
Specify whether to allow or deny file listing, in case user has no permission on share. Also known as Access-Based Enumeration.
name
string / required
Share name.
path
path / required
Share directory.
read
string
Specify user list that should get read access on share, separated by comma.
state
string
    Choices:
  • absent
  • present ←
Specify whether to add present or remove absent the specified share.

Examples

# Playbook example
# Add share and set permissions
---
- name: Add secret share
  win_share:
    name: internal
    description: top secret share
    path: C:\shares\internal
    list: no
    full: Administrators,CEO
    read: HR-Global
    deny: HR-External

- name: Add public company share
  win_share:
    name: company
    description: top secret share
    path: C:\shares\company
    list: yes
    full: Administrators,CEO
    read: Global

- name: Remove previously added share
  win_share:
    name: internal
    state: absent

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
actions
list
success
A list of action cmdlets that were run by the module.

Sample:
['New-SmbShare -Name share -Path C:\\temp']


Status

Red Hat Support

More information about Red Hat’s support of this module is available from this Red Hat Knowledge Base article.

Authors

  • Hans-Joachim Kliemeck (@h0nIg)

  • David Baumann (@daBONDi)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.