Reputation: 21
For some reason when I pass parameters through the options section it doesn't like my powershell arguments. I hate to bother you guys, but do you have any ideas what might be the problem? Thanks in advance!
Essentially all I am trying to do with powershell is this -
Start-Process -FilePath "T:\QualysCloudAgent.exe" -argumentlist "CustomerId={etc..etc..etc..} ActivationId={etc..etc..etc..}"
when 'windows'
windows_package 'QualysCloudAgent' do
source 'T:\QualysCloudAgent.exe'
options '-argumentlist "CustomerId={etc...etc...etc..} ActivationId={etc...etc..etc...}"'
installer_type :custom
action :install
end
end
Upvotes: 0
Views: 228
Reputation: 21408
You're not running powershell.exe
- unless QualysCloudAgent.exe
accepts an -ArgumentList
parameter then your executable likely doesn't understand the argument. Just pass your options to the resource like so:
options %Q(CustomerId={etc...etc...etc..} ActivationId={etc...etc..etc...})
You may also want to consider using a guard
as well, to make sure idempotency is maintained during convergence (e.g. don't install if it's already installed). For example, in your resource, you might do something like this in your block above, since you have the :custom
installer_type
set:
not_if %Q(# PowerShell code to check if the program is installed)
guard_interpreter :powershell_script
Setting the guard_interpreter
on a resource tells Chef to evaluate a not_if
or only_if
string under a resource as that language. See the linked page for the different runtimes Chef supports in this context.
Side note: %Q()
is a shortcut in Ruby for double-quoted string literals, with an added bonus - you don't have to escape double quotes anymore (although you will have to quote unopened closing parentheses, such as %Q(My name is Bender\()
, but %Q(My name is (Bender))
does not need to be), which is usually a huge help in building external command arguments, especially in Chef. This section of the Ruby wikibook explains more about the alternative notations for different literals which you may find useful/graceful in other situations as well.
Upvotes: 1