Last active
June 27, 2017 17:22
-
-
Save nweddle/781aa9607432c8e031a5861a87212cec to your computer and use it in GitHub Desktop.
Enabling Custom PowerShell DSC Modules with Chef
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
# Define Attributes | |
# Move to ./attributes/default.rb | |
node.default['test']['module_name'] = 'xStorage' | |
node.default['test']['image_path'] = 'C:\Users\nathan' | |
node.default['test']['image_name'] = 'alpine-virt-3.5.1-x86_64.iso' | |
node.default['test']['drive_letter'] = 'S' | |
# Enable the PSGallery Repository, so that we can then install our DSC module | |
powershell_script 'Enable PSGallery Repository' do | |
code 'Set-PSRepository -Name PSGallery -InstallationPolicy Trusted' | |
not_if '(Get-PSRepository -Name PSGallery).Trusted' | |
end | |
# Install our custom DSC module, and skip if already installed | |
powershell_script "Install #{node['test']['module_name']} DSC Module" do | |
code "Install-Module -Name #{node['test']['module_name']}" | |
not_if "(Get-InstalledModule -Name #{node['test']['module_name']}).Installed" | |
end | |
# Execute the xMountImage DSC resource from the xStorage DSC module | |
dsc_resource 'Mount ISO' do | |
resource :xMountImage | |
property :ImagePath, "#{node['test']['image_path']}\\#{node['test']['image_name']}" | |
property :DriveLetter, (node['test']['drive_letter']).to_s | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment