Hello,
dsc_resource allows to use DSC resources available on system but how do I use dsc_resource to configure LCM itself. Example of DSC script is below
[DscLocalConfigurationManager()]
Configuration LCMSettings {
Node localhost
{
Settings
{
RefreshMode = “Disabled”
configurationmode = "ApplyOnly"
}
}
}
One option to configure the LCM might be to use powershell_script
, like this:
powershell_script 'Configure the LCM' do
code <<-EOH
Configuration ConfigLCM
{
Node "localhost"
{
LocalConfigurationManager
{
ConfigurationMode = "ApplyOnly"
RebootNodeIfNeeded = $false
}
}
}
ConfigLCM -OutputPath "#{Chef::Config[:file_cache_path]}\\DSC_LCM"
Set-DscLocalConfigurationManager -Path "#{Chef::Config[:file_cache_path]}\\DSC_LCM"
EOH
not_if '(Get-DscLocalConfigurationManager | select -ExpandProperty "ConfigurationMode") -eq "ApplyOnly"'
end
Reference: https://learn.chef.io/manage-a-web-app/windows/configure-the-lcm/
I understand that, I just wanted to use cleaner dsc_resource resource instead.