Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(MODULES-3571) Allow setting install_path for MSI #130

Merged
merged 1 commit into from
Jul 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ An array of services to start, normally `puppet` and `mcollective`. If the array

Alternate source from which you wish to download the latest version of Puppet.

####`install_dir`

The directory the puppet agent should be installed to. This is only applicable for windows operating systems.
This only applies when upgrading the agent to a new version; it will not cause re-installation of the same version to a new location.


## Limitations

Mac OS X Open Source packages are currently not supported.
Expand Down
10 changes: 10 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
# None will be started if the array is empty.
# [source]
# The location to find packages.
# [install_dir]
# The directory the puppet agent should be installed to. This is only applicable for
# windows operating systems. This only applies when upgrading the agent to a new
# version; it will not cause re-installation of the same version to a new location.
#
class puppet_agent (
$arch = $::architecture,
Expand All @@ -34,10 +38,15 @@
$package_version = $::puppet_agent::params::package_version,
$service_names = $::puppet_agent::params::service_names,
$source = $::puppet_agent::params::_source,
$install_dir = $::puppet_agent::params::install_dir,
) inherits ::puppet_agent::params {

validate_re($arch, ['^x86$','^x64$','^i386$','^i86pc$','^amd64$','^x86_64$','^power$','^sun4[uv]$','PowerPC_POWER'])

if $::osfamily == 'windows' and $install_dir != undef {
validate_absolute_path($install_dir)
}

if $package_version == undef and versioncmp("${::clientversion}", '4.0.0') >= 0 {
info('puppet_agent performs no actions if a package_version is not specified on Puppet 4')
} elsif $package_version == undef and $is_pe {
Expand Down Expand Up @@ -116,6 +125,7 @@
class { '::puppet_agent::install':
package_file_name => $_package_file_name,
package_version => $_package_version,
install_dir => $install_dir,
}

contain '::puppet_agent::prepare'
Expand Down
3 changes: 3 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
class puppet_agent::install(
$package_file_name = undef,
$package_version = 'present',
$install_dir = undef,
) {
assert_private()

Expand Down Expand Up @@ -84,12 +85,14 @@
class { 'puppet_agent::windows::install':
package_file_name => $package_file_name,
source => $local_package_file_path,
install_dir => $install_dir,
require => File[$local_package_file_path],
}
} else {
class { 'puppet_agent::windows::install':
package_file_name => $package_file_name,
source => $::puppet_agent::source,
install_dir => $install_dir,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
}

$package_name = 'puppet-agent'
$install_dir = undef

case $::osfamily {
'RedHat', 'Debian', 'Suse', 'Solaris', 'Darwin', 'AIX': {
Expand Down
3 changes: 2 additions & 1 deletion manifests/windows/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#
class puppet_agent::windows::install(
$package_file_name,
$source = $::puppet_agent::source,
$source = $::puppet_agent::source,
$install_dir = undef,
) {
assert_private()

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 @@ -26,7 +26,7 @@ REM This may fail on agents without pxp-agent, but since this is not
REM run interactively and the next command sets ERRORLEVEL, it's OK.
net stop pxp-agent

start /wait msiexec.exe /qn /norestart /i "<%= @_msi_location %>" /l*vx "<%= @_logfile %>" PUPPET_MASTER_SERVER="<%= @_puppet_master %>" PUPPET_AGENT_ENVIRONMENT="%environment%"
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 -%>

if exist %pid_path% del %pid_path%

Expand Down