Skip to content

Instantly share code, notes, and snippets.

@btm
Created June 26, 2014 17:16
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 btm/f1b01ede282f67caec93 to your computer and use it in GitHub Desktop.
Save btm/f1b01ede282f67caec93 to your computer and use it in GitHub Desktop.
PS C:\ruby> chef-apply package.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* log[lolwut ruby] action write (skipped due to only_if)
PS C:\ruby> vim .\package.rb
PS C:\ruby> chef-apply package.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* log[lolwut ruby] action write
PS C:\ruby> chef-apply package.rb -l info
[2014-06-26T13:16:07-04:00] INFO: Run List is []
[2014-06-26T13:16:07-04:00] INFO: Run List expands to []
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* log[lolwut ruby] action write[2014-06-26T13:16:07-04:00] INFO: Processing log[lolwut ruby] action write ((chef-apply cookbook)::(chef-apply recipe) line 9)
[2014-06-26T13:16:07-04:00] INFO: Chef 11.12.8-2 is already installed
# Only do something if a package is/is not installed on windows, by product code
class MsiHelper
include Chef::ReservedNames::Win32::API::Installer
def installed?(product_code)
get_installed_version(product_code)
end
end
log "lolwut ruby" do
message "Chef 11.12.8-2 is already installed"
only_if { MsiHelper.new.installed?('{0CA254AC-3ACB-4830-9C2F-407F6232BB9C}') }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment