Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exclude option to win_servermanager #33729

Merged
merged 3 commits into from
Jun 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion salt/modules/win_servermanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def list_installed():
return ret


def install(feature, recurse=False, source=None, restart=False):
def install(feature, recurse=False, source=None, restart=False, exclude=None):
'''
Install a feature

Expand All @@ -140,6 +140,13 @@ def install(feature, recurse=False, source=None, restart=False):
:param bool restart: Restarts the computer when installation is complete, if
required by the role/feature installed. Default is False

:param str exclude: The name of the feature to exclude when installing the
named feature.

..note:: As there is no exclude option for the ``Add-WindowsFeature``
command, the feature will be installed with other sub-features and
will then be removed.

:return: A dictionary containing the results of the install
:rtype: dict

Expand Down Expand Up @@ -173,6 +180,9 @@ def install(feature, recurse=False, source=None, restart=False):
.format(_cmd_quote(feature), mgmt_tools, sub, src, rst)
out = _pshell_json(cmd)

if exclude is not None:
remove(exclude, restart=restart)

if out['FeatureResult']:
return {'ExitCode': out['ExitCode'],
'DisplayName': out['FeatureResult'][0]['DisplayName'],
Expand Down
11 changes: 9 additions & 2 deletions salt/states/win_servermanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ def __virtual__():
return 'win_servermanager' if 'win_servermanager.install' in __salt__ else False


def installed(name, recurse=False, force=False, source=None, restart=False):
def installed(name,
recurse=False,
force=False,
source=None,
restart=False,
exclude=None):
'''
Install the windows feature

Expand All @@ -31,6 +36,8 @@ def installed(name, recurse=False, force=False, source=None, restart=False):
restart (Optional[bool]): Restarts the computer when installation is
complete, if required by the role/feature installed. Default is
False
exclude (Optional[str]): The name of the feature to exclude when
installing the named feature.

Note:
Some features require reboot after un/installation. If so, until the
Expand Down Expand Up @@ -78,7 +85,7 @@ def installed(name, recurse=False, force=False, source=None, restart=False):

# Install the features
status = __salt__['win_servermanager.install'](
name, recurse, source, restart)
name, recurse, source, restart, exclude)

ret['result'] = status['Success']
if not ret['result']:
Expand Down