Skip to content

Commit

Permalink
Merge pull request #253 from jcoconnor/MODULES-5622-PA-REINSTALLMODE
Browse files Browse the repository at this point in the history
(MODULES-5622) Add REINSTALLMODE for win install
  • Loading branch information
glennsarti authored Nov 15, 2017
2 parents 2d749e6 + 4fb1f7a commit c5f2140
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ The directory the puppet agent should be installed to. This is only applicable f

##### `install_options`

An array of additional options to pass when installing puppet-agent. Each option in the array can either be a string or a hash. Each option will automatically be quoted when passed to the install command. With Windows packages, note that file paths in an install option must use backslashes. (Since install options are passed directly to the installation command, forward slashes won't be automatically converted like they are in `file` resources.) Note also that backslashes in double-quoted strings _must_ be escaped and backslashes in single-quoted strings _can_ be escaped.
An array of additional options to pass when installing puppet-agent. Each option in the array can either be a string or a hash. Each option will automatically be quoted when passed to the install command.

With Windows packages, note that file paths in an install option must use backslashes. (Since install options are passed directly to the installation command, forward slashes won't be automatically converted like they are in `file` resources.) Note also that backslashes in double-quoted strings _must_ be escaped and backslashes in single-quoted strings _can_ be escaped. The default value for Windows packages is `REINSTALLMODE="maus"`.

``` puppet
install_options => ['PUPPET_AGENT_ACCOUNT_DOMAIN=ExampleCorp','PUPPET_AGENT_ACCOUNT_USER=bob','PUPPET_AGENT_ACCOUNT_PASSWORD=password']
Expand Down
5 changes: 5 additions & 0 deletions manifests/windows/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
$_https_source = "https://downloads.puppetlabs.com/windows/${package_file_name}"
}

$_install_options = $install_options ? {
[] => ['REINSTALLMODE="amus"'],
default => $install_options
}

$_source = $source ? {
undef => $_https_source,
/^[a-zA-Z]:/ => windows_native_path($source),
Expand Down
11 changes: 11 additions & 0 deletions spec/classes/puppet_agent_windows_install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@
it {
is_expected.to contain_file('C:\tmp\install_puppet.bat').with_content(/msiexec.exe .+ OPTION1=value1 OPTION2=value2/)
}
it {
is_expected.not_to contain_file('C:\tmp\install_puppet.bat').with_content(/msiexec.exe .+ REINSTALLMODE="amus"/)
}
end
end

context 'Default INSTALLMODE Option' do
describe 'REINSTALLMODE=amus' do
it {
is_expected.to contain_file('C:\tmp\install_puppet.bat').with_content(/msiexec.exe .+ REINSTALLMODE="amus"/)
}
end
end

Expand Down
2 changes: 1 addition & 1 deletion templates/install_puppet.bat.erb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ IF EXIST "%PUPPETRES%" (
)
<% end %>

start /wait msiexec.exe /qn /norestart /i "<%= @_msi_location %>" /l*vx "<%= @_logfile %>" PUPPET_MASTER_SERVER="<%= @_puppet_master %>" PUPPET_AGENT_ENVIRONMENT="%environment%" <% unless @install_dir.to_s.empty? -%>INSTALLDIR="<%= @install_dir %>"<% end -%> <% unless @_agent_startup_mode.to_s.empty? -%>PUPPET_AGENT_STARTUP_MODE="<%= @_agent_startup_mode %>"<% end -%><% unless @install_options.to_s.empty? -%><% @install_options.each do |option| -%> <%= option%><% end -%><% end -%>
start /wait msiexec.exe /qn /norestart /i "<%= @_msi_location %>" /l*vx "<%= @_logfile %>" PUPPET_MASTER_SERVER="<%= @_puppet_master %>" PUPPET_AGENT_ENVIRONMENT="%environment%" <% unless @install_dir.to_s.empty? -%>INSTALLDIR="<%= @install_dir %>"<% end -%> <% unless @_agent_startup_mode.to_s.empty? -%>PUPPET_AGENT_STARTUP_MODE="<%= @_agent_startup_mode %>"<% end -%><% unless @_install_options.to_s.empty? -%><% @_install_options.each do |option| -%> <%= option%><% end -%><% end -%>

:End

Expand Down

0 comments on commit c5f2140

Please sign in to comment.