mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #37529 from lorengordon/bp-36736
Backport: PR 36736 to 2016.3
This commit is contained in:
commit
a9f03eee6f
1 changed files with 14 additions and 2 deletions
|
@ -3,8 +3,9 @@
|
|||
Manage Windows features via the ServerManager powershell module
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
import ast
|
||||
import json
|
||||
import logging
|
||||
|
||||
# Import python libs
|
||||
try:
|
||||
|
@ -24,6 +25,17 @@ def __virtual__():
|
|||
'''
|
||||
Load only on windows with servermanager module
|
||||
'''
|
||||
def _module_present():
|
||||
'''
|
||||
Check for the presence of the ServerManager module.
|
||||
'''
|
||||
cmd = r"[Bool] (Get-Module -ListAvailable | Where-Object { $_.Name -eq 'ServerManager' })"
|
||||
cmd_ret = __salt__['cmd.run_all'](cmd, shell='powershell', python_shell=True)
|
||||
|
||||
if cmd_ret['retcode'] == 0:
|
||||
return ast.literal_eval(cmd_ret['stdout'])
|
||||
return False
|
||||
|
||||
if not salt.utils.is_windows():
|
||||
return False, 'Failed to load win_servermanager module: ' \
|
||||
'Only available on Windows systems.'
|
||||
|
@ -33,7 +45,7 @@ def __virtual__():
|
|||
'Requires Remote Server Administration Tools which ' \
|
||||
'is only available on Windows 2008 R2 and later.'
|
||||
|
||||
if not _check_server_manager():
|
||||
if not _module_present():
|
||||
return False, 'Failed to load win_servermanager module: ' \
|
||||
'ServerManager module not available. ' \
|
||||
'May need to install Remote Server Administration Tools.'
|
||||
|
|
Loading…
Add table
Reference in a new issue