diff --git a/README.markdown b/README.markdown index 6eda35836..4a19b3e66 100644 --- a/README.markdown +++ b/README.markdown @@ -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. diff --git a/manifests/init.pp b/manifests/init.pp index 939480f7d..41e548cb5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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, @@ -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 { @@ -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' diff --git a/manifests/install.pp b/manifests/install.pp index 8e6c281f9..8b56da035 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -13,6 +13,7 @@ class puppet_agent::install( $package_file_name = undef, $package_version = 'present', + $install_dir = undef, ) { assert_private() @@ -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, } } } diff --git a/manifests/params.pp b/manifests/params.pp index af7622fd4..c21c569e5 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -22,6 +22,7 @@ } $package_name = 'puppet-agent' + $install_dir = undef case $::osfamily { 'RedHat', 'Debian', 'Suse', 'Solaris', 'Darwin', 'AIX': { diff --git a/manifests/windows/install.pp b/manifests/windows/install.pp index 00c8eb699..acf573bda 100644 --- a/manifests/windows/install.pp +++ b/manifests/windows/install.pp @@ -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() diff --git a/templates/install_puppet.bat.erb b/templates/install_puppet.bat.erb index 464f41a8f..73d0ea4f6 100644 --- a/templates/install_puppet.bat.erb +++ b/templates/install_puppet.bat.erb @@ -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%