Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@stack72
Created May 17, 2013 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stack72/5598480 to your computer and use it in GitHub Desktop.
Save stack72/5598480 to your computer and use it in GitHub Desktop.
We have the following in /modules/manage_windows_feature/manifests.init.pp
define manage_windows_feature($feature_name = $title) {
$powershell_cmd = "powershell.exe"
$exec_policy = "-executionpolicy remotesigned"
exec { "install-feature-${feature_name}" :
command => "$powershell_cmd ${exec_policy} -Command \"Import-Module ServerManager; Add-WindowsFeature ${feature_name}\"",
path => "C:\\Windows\\sysnative\\WindowsPowershell\\v1.0;${::path}",
onlyif => "${powershell_cmd} ${exec_policy} -Command \"Import-Module ServerManager; if((Get-WindowsFeature ${feature_name}).Installed) { exit 1 }\"",
logoutput => true,
}
}
This is used across a number of our modules and called from within a module (/modules/windowsfeatures_iis_application_development/manifests/init.pp) and it looks as follows:
class windowsfeatures_iis_application_development {
manage_windows_feature { 'Web-Asp-Net': }
manage_windows_feature { 'Web-Net-Ext': }
manage_windows_feature { 'Web-ISAPI-Ext': }
manage_windows_feature { 'Web-ISAPI-Filter': }
}
this manage_windows_feature is used across a number of classes. Therefore, where is the best place to keep it?
@liamjbennett
Copy link

Exactly where you've got it - in it's own module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment