-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from chef-cookbooks/smurawski/merging_prs_57_6…
- Loading branch information
Showing
25 changed files
with
634 additions
and
593 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
## temporary directory related attributes ## | ||
default['lcm']['mof']['temp_dir'] = "#{Chef::Config[:file_cache_path]}\\lcm_mof" | ||
|
||
## lcm configuration related attributes ## | ||
default['lcm']['config']['enable']['config_mode'] = 'ApplyOnly' | ||
default['lcm']['config']['enable']['reboot_node'] = false | ||
default['lcm']['config']['enable']['refresh_mode'] = 'Push' | ||
default['lcm']['config']['disable']['refresh_mode'] = 'Disabled' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# | ||
# Author:: Aliasgar Batterywala (<[email protected]>) | ||
# Cookbook Name:: powershell | ||
# Recipe:: disable_lcm | ||
# | ||
# Copyright:: Copyright (c) 2015 Chef Software, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
include_recipe 'powershell::powershell5' | ||
include_recipe 'powershell::dsc' | ||
|
||
case node['platform'] | ||
when 'windows' | ||
|
||
directory 'Creating temporary directory to store LCM MOF files' do | ||
path node['lcm']['mof']['temp_dir'] | ||
rights :read, 'Everyone' | ||
action :create | ||
end | ||
|
||
powershell_script 'Disable LCM' do | ||
code <<-EOH | ||
Configuration DisableLCM | ||
{ | ||
Node "localhost" | ||
{ | ||
LocalConfigurationManager | ||
{ | ||
RefreshMode = "#{node['lcm']['config']['disable']['refresh_mode']}" | ||
} | ||
} | ||
} | ||
DisableLCM -OutputPath "#{node['lcm']['mof']['temp_dir']}" | ||
Set-DscLocalConfigurationManager -Path "#{node['lcm']['mof']['temp_dir']}" | ||
EOH | ||
not_if <<-EOH | ||
$LCM = (Get-DscLocalConfigurationManager) | ||
$LCM.RefreshMode -eq "#{node['lcm']['config']['disable']['refresh_mode']}" | ||
EOH | ||
end | ||
|
||
directory 'Deleting temporary directory which stored LCM MOF files' do | ||
path node['lcm']['mof']['temp_dir'] | ||
recursive true | ||
action :delete | ||
end | ||
else | ||
Chef::Log.warn('LCM configuration can only be executed on the Windows platform.') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# | ||
# Author:: Aliasgar Batterywala (<[email protected]>) | ||
# Cookbook Name:: powershell | ||
# Recipe:: enable_lcm | ||
# | ||
# Copyright:: Copyright (c) 2015 Chef Software, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
include_recipe 'powershell::enable_lcm' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# | ||
# Author:: Aliasgar Batterywala (<[email protected]>) | ||
# Cookbook Name:: powershell | ||
# Recipe:: enable_lcm | ||
# | ||
# Copyright:: Copyright (c) 2015 Chef Software, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
include_recipe 'powershell::dsc' | ||
|
||
case node['platform'] | ||
when 'windows' | ||
|
||
directory 'Creating temporary directory to store LCM MOF files' do | ||
path node['lcm']['mof']['temp_dir'] | ||
rights :read, 'Everyone' | ||
action :create | ||
guard_interpreter :powershell_script | ||
not_if <<-EOH | ||
$LCM = (Get-DscLocalConfigurationManager) | ||
$LCM.ConfigurationMode -eq "#{node['lcm']['config']['enable']['config_mode']}" -and | ||
$LCM.RefreshMode -eq "#{node['lcm']['config']['enable']['refresh_mode']}" | ||
EOH | ||
end | ||
|
||
directory 'Deleting temporary directory which stored LCM MOF files' do | ||
path node['lcm']['mof']['temp_dir'] | ||
recursive true | ||
action :nothing | ||
end | ||
|
||
powershell_script 'Configure and Enable LCM' do | ||
code <<-EOH | ||
Configuration EnableLCM | ||
{ | ||
Node "localhost" | ||
{ | ||
LocalConfigurationManager | ||
{ | ||
ConfigurationMode = "#{node['lcm']['config']['enable']['config_mode']}" | ||
RebootNodeIfNeeded = $#{node['lcm']['config']['enable']['reboot_node']} | ||
RefreshMode = "#{node['lcm']['config']['enable']['refresh_mode']}" | ||
} | ||
} | ||
} | ||
EnableLCM -OutputPath "#{node['lcm']['mof']['temp_dir']}" | ||
Set-DscLocalConfigurationManager -Path "#{node['lcm']['mof']['temp_dir']}" | ||
EOH | ||
not_if <<-EOH | ||
$LCM = (Get-DscLocalConfigurationManager) | ||
$LCM.ConfigurationMode -eq "#{node['lcm']['config']['enable']['config_mode']}" -and | ||
$LCM.RefreshMode -eq "#{node['lcm']['config']['enable']['refresh_mode']}" | ||
EOH | ||
notifies :delete, 'directory[Deleting temporary directory which stored LCM MOF files]', :immediately | ||
end | ||
|
||
else | ||
Chef::Log.warn('LCM configuration can only be executed on the Windows platform.') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.