This module is Alpha
Module for working with Windows PowerShell DSC (Desired State Configuration)
This module applies DSC Configurations in the form of PowerShell scripts or MOF (Managed Object Format) schema files.
Use the psget
module to manage PowerShell resources.
The idea is to leverage Salt to push DSC configuration scripts or MOF files to the Minion.
depends: |
|
---|
salt.modules.win_dsc.
apply_config
(path, source=None, salt_env='base')¶Run an compiled DSC configuration (a folder containing a .mof file). The
folder can be cached from the salt master using the source
option.
Parameters: |
|
---|---|
Returns: | True if successful, otherwise False |
Return type: |
CLI Example:
To apply a config that already exists on the the system
salt '*' dsc.apply_config C:\\DSC\\WebSiteConfiguration
To cache a configuration from the master and apply it:
salt '*' dsc.apply_config C:\\DSC\\WebSiteConfiguration salt://dsc/configs/WebSiteConfiguration
salt.modules.win_dsc.
compile_config
(path, source=None, config_name=None, config_data=None, config_data_source=None, script_parameters=None, salt_env='base')¶Compile a config from a PowerShell script (.ps1
)
Parameters: |
|
---|---|
Returns: | A dictionary containing the results of the compilation |
Return type: |
CLI Example:
To compile a config from a script that already exists on the system:
salt '*' dsc.compile_config C:\\DSC\\WebsiteConfig.ps1
To cache a config script to the system from the master and compile it:
salt '*' dsc.compile_config C:\\DSC\\WebsiteConfig.ps1 salt://dsc/configs/WebsiteConfig.ps1
salt.modules.win_dsc.
get_config
()¶Get the current DSC Configuration
Returns: | A dictionary representing the DSC Configuration on the machine |
---|---|
Return type: | dict |
Raises: | CommandExecutionError -- On failure |
CLI Example:
salt '*' dsc.get_config
salt.modules.win_dsc.
get_config_status
()¶Get the status of the current DSC Configuration
Returns: |
|
---|---|
Return type: | dict |
CLI Example:
salt '*' dsc.get_config_status
salt.modules.win_dsc.
get_lcm_config
()¶Get the current Local Configuration Manager settings
Returns: |
|
---|---|
Return type: | dict |
CLI Example:
salt '*' dsc.get_lcm_config
salt.modules.win_dsc.
remove_config
(reset=False)¶Remove the current DSC Configuration. Removes current, pending, and previous dsc configurations.
New in version 2017.7.5.
Parameters: | reset (bool) -- Attempts to reset the DSC configuration by removing the following
from
Default is False Warning
|
---|---|
Returns: | True if successful |
Return type: | bool |
Raises: | CommandExecutionError -- On failure |
CLI Example:
salt '*' dsc.remove_config True
salt.modules.win_dsc.
restore_config
()¶Reapplies the previous configuration.
New in version 2017.7.5.
Note
The current configuration will be come the previous configuration. If run a second time back-to-back it is like toggling between two configs.
Returns: | True if successfully restored |
---|---|
Return type: | bool |
Raises: | CommandExecutionError -- On failure |
CLI Example:
salt '*' dsc.restore_config
salt.modules.win_dsc.
run_config
(path, source=None, config_name=None, config_data=None, config_data_source=None, script_parameters=None, salt_env='base')¶Compile a DSC Configuration in the form of a PowerShell script (.ps1) and
apply it. The PowerShell script can be cached from the master using the
source
option. If there is more than one config within the PowerShell
script, the desired configuration can be applied by passing the name in the
config
option.
This command would be the equivalent of running dsc.compile_config
followed by dsc.apply_config
.
Parameters: |
|
---|---|
Returns: | True if successfully compiled and applied, otherwise False |
Return type: |
CLI Example:
To compile a config from a script that already exists on the system:
salt '*' dsc.run_config C:\\DSC\\WebsiteConfig.ps1
To cache a config script to the system from the master and compile it:
salt '*' dsc.run_config C:\\DSC\\WebsiteConfig.ps1 salt://dsc/configs/WebsiteConfig.ps1
salt.modules.win_dsc.
set_lcm_config
(config_mode=None, config_mode_freq=None, refresh_freq=None, reboot_if_needed=None, action_after_reboot=None, refresh_mode=None, certificate_id=None, configuration_id=None, allow_module_overwrite=None, debug_mode=False, status_retention_days=None)¶For detailed descriptions of the parameters see: https://msdn.microsoft.com/en-us/PowerShell/DSC/metaConfig
are:
refresh_mode (str): How the LCM gets configurations. Valid values are:
- Disabled
- Push
- Pull
are:
debug_mode (str): Sets the debug level. Valid values are:
- None
- ForceModuleImport
- All
Note
Either config_mode_freq
or refresh_freq
needs to be a
multiple of the other. See documentation on MSDN for more details.
Returns: | True if successful, otherwise False |
---|---|
Return type: | bool |
CLI Example:
salt '*' dsc.set_lcm_config ApplyOnly