Showing with 1,626 additions and 582 deletions.
  1. +1 −0 .fixtures.yml
  2. +1 −0 .travis.yml
  3. +16 −0 CHANGELOG.md
  4. +10 −10 Gemfile
  5. +27 −1 README.markdown
  6. +7 −18 Rakefile
  7. +7 −0 lib/facter/env_temp_variable.rb
  8. +17 −3 lib/facter/mco_config.rb
  9. +3 −0 lib/facter/puppet_agent_pid.rb
  10. +28 −0 lib/facter/settings.rb
  11. +14 −0 lib/puppet/parser/functions/uri_host_from_string.rb
  12. +11 −0 lib/puppet/parser/functions/windows_native_path.rb
  13. +2 −0 manifests/config.pp
  14. +25 −11 manifests/init.pp
  15. +1 −0 manifests/install.pp
  16. +76 −0 manifests/osfamily/debian.pp
  17. +40 −5 manifests/osfamily/redhat.pp
  18. +66 −0 manifests/osfamily/suse.pp
  19. +4 −0 manifests/osfamily/windows.pp
  20. +33 −9 manifests/params.pp
  21. +20 −133 manifests/prepare.pp
  22. +55 −0 manifests/prepare/mco_client_config.pp
  23. +55 −0 manifests/prepare/mco_server_config.pp
  24. +39 −0 manifests/prepare/puppet_config.pp
  25. +45 −0 manifests/prepare/ssl.pp
  26. +1 −0 manifests/service.pp
  27. +50 −0 manifests/windows/install.pp
  28. +43 −3 metadata.json
  29. +59 −61 spec/acceptance/class_spec.rb
  30. +1 −1 spec/acceptance/files/{activemq.xml → activemq.xml.erb}
  31. +3 −2 spec/acceptance/files/{client.cfg → client.cfg.erb}
  32. +2 −1 spec/acceptance/files/{server.cfg → server.cfg.erb}
  33. +11 −2 spec/acceptance/nodesets/{centos-511-x64.yml → centos-5-x64.yml}
  34. +22 −0 spec/acceptance/nodesets/centos-6-x64.yml
  35. +0 −13 spec/acceptance/nodesets/centos-66-x64.yml
  36. +0 −13 spec/acceptance/nodesets/centos-7-x64.yml
  37. +22 −0 spec/acceptance/nodesets/debian-6-x64.yml
  38. +0 −13 spec/acceptance/nodesets/debian-609-x64.yml
  39. +22 −0 spec/acceptance/nodesets/debian-7-x64.yml
  40. +0 −13 spec/acceptance/nodesets/debian-76-x64.yml
  41. +2 −2 spec/acceptance/nodesets/default.yml
  42. +0 −13 spec/acceptance/nodesets/fedora-20-x64.yml
  43. +11 −2 spec/acceptance/nodesets/ubuntu-1204-x64.yml
  44. +11 −2 spec/acceptance/nodesets/ubuntu-1404-x64.yml
  45. +83 −0 spec/classes/puppet_agent_osfamily_debian_spec.rb
  46. +47 −8 spec/classes/puppet_agent_osfamily_redhat_spec.rb
  47. +116 −0 spec/classes/puppet_agent_osfamily_suse_spec.rb
  48. +185 −148 spec/classes/puppet_agent_prepare_spec.rb
  49. +1 −6 spec/classes/puppet_agent_spec.rb
  50. +166 −0 spec/classes/puppet_agent_windows_install_spec.rb
  51. +34 −0 spec/spec_helper.rb
  52. +102 −89 spec/spec_helper_acceptance.rb
  53. +17 −0 spec/unit/facter/settings_spec.rb
  54. +12 −0 templates/install_puppet.bat.erb
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ fixtures:
repositories:
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
inifile: "https://github.com/puppetlabs/puppetlabs-inifile.git"
apt: "https://github.com/puppetlabs/puppetlabs-apt.git"
symlinks:
puppet_agent: "#{source_dir}"
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
language: ruby
sudo: false
bundler_args: --without system_tests
before_install: rm Gemfile.lock || true
script: bundle exec rake test
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.2.0] - 2015-07-21

### Summary

Added support for most systems with both Puppet 3.8 and Puppet-Agent packages released by Puppet Labs.

### Features
- Support for Debian 6/7, Ubuntu 12.04/14.04, SLES 12, and Windows 2003 through 2012R2.

### Bugfixes
- Fix puppet_agent module doesn't touch puppet.conf settings outside an INI section (PUP-4886)
- Made internal classes private, using stdlib's assert_private helper
- Migrate SSL cert directories individually to account for individual settings (PUP-4690)
- Migrated mcollective configuration should prefer the new plugin location (PUP-4658)
- Fixed updating mcollective configuration files with multiple libdir or plugin.yaml definitions (PUP-4746)

## [0.1.0] - 2015-06-02
### Added
- Initial release of puppetlabs-puppet_agent, supporting Redhat and Centos 5/6/7.
20 changes: 10 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
source "https://rubygems.org"
source 'https://rubygems.org'

group :test do
gem "rake"
gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.8.1'
gem "rspec", '< 3.2.0'
gem "rspec-puppet"
gem "puppetlabs_spec_helper"
gem "metadata-json-lint"
gem "rspec-puppet-facts"
gem 'rake', '~> 10.4'
gem 'puppet', ENV['PUPPET_VERSION'] || '~> 3.8'
gem 'rspec', '< 3.2.0' # https://github.com/rspec/rspec-core/issues/1864
gem 'rspec-puppet', '~> 2.2'
gem 'puppetlabs_spec_helper', '~> 0.10'
gem 'metadata-json-lint', '~> 0.0'
gem 'rspec-puppet-facts', '~> 0.10'
end

group :system_tests do
gem "beaker", '~> 2.11.0'
gem "beaker-rspec"
gem 'beaker', '~> 2.16'
gem 'beaker-rspec', '~> 5.1'
end
28 changes: 27 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* [Private classes](#private-classes)
* [Parameters](#parameters)
6. [Limitations - OS compatibility, etc.](#limitations)
* [Known issues](#known-issues)
7. [Development - Guide for contributing to the module](#development)

## Overview
Expand Down Expand Up @@ -65,6 +66,10 @@ include ::puppet_agent

####Class: puppet_agent

#####`arch`

The architecture version you wish to install. Defaults to `$::architecture`. This parameter is [ignored](#known-issues) in Windows Server 2003.

#####`package_name`

The package to upgrade to, i.e., `puppet-agent`. Currently, the default and only accepted value is `puppet-agent`.
Expand All @@ -73,10 +78,31 @@ The package to upgrade to, i.e., `puppet-agent`. Currently, the default and only

An array of services to start, normally `puppet` and `mcollective`. If the array is empty, no services are started.

#####`source`

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

## Limitations

Supports only RPM-based distros: Redhat and Centos 5/6/7.
This module supports:

* RHEL 5, 6, 7
* Centos 5, 6, 7
* Debian 6, 7
* Ubuntu 12.04, 14.04
* Windows Server 2003 or later

###Known issues

* In masterless environments, modules installed manually on individual agents cannot be found after upgrading to Puppet 4.x. You should reinstall these modules on the agents with `puppet module install`.

In addition, there are several known issues with Windows:

* To upgrade the agent by executing `puppet agent -t` interactively in a console, you must close the console and wait for the upgrade to finish before attempting to use the `puppet` command again.
* MSI installation failures do not produce any error. If the install fails, puppet_agent continues to be applied to the agent.
If this happens, you'll need to examine the MSI log file to determine the failure's cause. You can find the location of the log file in the debug output from either a puppet apply or an agent run; the log file name follows the pattern `puppet-<timestamp>-installer.log`.
* On Windows Server 2003, only x86 is supported, and the `arch` parameter is ignored. If you try to force an upgrade to x64, Puppet installs the x86 version with no error message.

##Development

Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve.
Expand Down
25 changes: 7 additions & 18 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,16 @@ begin
rescue LoadError
end

Rake::Task[:lint].clear

PuppetLint.configuration.relative = true
PuppetLint.configuration.send("disable_80chars")
PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}"
PuppetLint.configuration.fail_on_warnings = true

# Forsake support for Puppet 2.6.2 for the benefit of cleaner code.
# http://puppet-lint.com/checks/class_parameter_defaults/
PuppetLint.configuration.send('disable_class_parameter_defaults')
# http://puppet-lint.com/checks/class_inherits_from_params_class/
PuppetLint.configuration.send('relative')
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_documentation')
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
PuppetLint.configuration.send('disable_only_variable_string')
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]

exclude_paths = [
"bundle/**/*",
"pkg/**/*",
"vendor/**/*",
"spec/**/*",
]
PuppetLint.configuration.ignore_paths = exclude_paths
PuppetSyntax.exclude_paths = exclude_paths
PuppetSyntax.exclude_paths = ["spec/**/*.pp", "pkg/**/*.pp"]

desc "Run acceptance tests"
RSpec::Core::RakeTask.new(:acceptance) do |t|
Expand Down
7 changes: 7 additions & 0 deletions lib/facter/env_temp_variable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'tmpdir'

Facter.add(:env_temp_variable) do
setcode {
(ENV['TEMP'] || Dir.tmpdir).gsub(/\\\s/, " ").gsub(/\//, '\\')
}
end
20 changes: 17 additions & 3 deletions lib/facter/mco_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
Facter.add("mco_#{node}_config") do
setcode do
config = nil
["/etc/puppetlabs/mcollective/#{node}.cfg", "/etc/mcollective/#{node}.cfg"].each do |cfg|
if Facter.fact(:kernel).value =~ /windows/i
config_dir = File.expand_path(File.join(Puppet.settings['confdir'],'../../mcollective/etc'))
locations = ["#{config_dir}/#{node}.cfg"]
else
locations = ["/etc/puppetlabs/mcollective/#{node}.cfg", "/etc/mcollective/#{node}.cfg"]
end
locations.each do |cfg|
if File.exists? cfg
config = cfg
end
Expand All @@ -16,13 +22,21 @@
settings = nil
config = Facter.fact("mco_#{node}_config".to_sym)
if config and config.value
settings = Hash[File.readlines(config.value).select {|v|
settings = {}

File.readlines(config.value).select {|v|
v.lstrip =~ /[^#].+=.+/
}.map {|x|
x.split('=', 2).map {|s| s.strip}
}.select {|k, v|
k == 'libdir' || k == 'plugin.yaml'
}]
}.each {|k, v|
if settings[k]
settings[k] += ':' + v
else
settings[k] = v
end
}
end
settings
end
Expand Down
3 changes: 3 additions & 0 deletions lib/facter/puppet_agent_pid.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Facter.add(:puppet_agent_pid) do
setcode { Process.pid }
end
28 changes: 28 additions & 0 deletions lib/facter/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,31 @@
Puppet.settings['config']
end
end

Facter.add('puppet_sslpaths') do
setcode do
result = {}
settings = ['privatedir', 'privatekeydir', 'publickeydir', 'certdir', 'requestdir', 'hostcrl']
settings.each do |setting|
path = Puppet.settings[setting]
exists = File.exist? path
result[setting] = {
'path' => path,
'path_exists' => exists,
}
end
result
end
end

Facter.add('puppet_confdir') do
setcode do
Puppet.settings['confdir']
end
end

Facter.add('mco_confdir') do
setcode do
File.expand_path(File.join(Puppet.settings['confdir'],'../../mcollective/etc'))
end
end
14 changes: 14 additions & 0 deletions lib/puppet/parser/functions/uri_host_from_string.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'uri'

module Puppet::Parser::Functions
newfunction(:uri_host_from_string, :arity => 1, :type => :rvalue, :doc => <<-EOS
Return a uri host from a string
EOS
) do |args|

uri = URI(args[0])

return uri.host
end
end

11 changes: 11 additions & 0 deletions lib/puppet/parser/functions/windows_native_path.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Puppet::Parser::Functions
newfunction(:windows_native_path, :arity => 1, :type => :rvalue, :doc => <<-EOS
Return a windows native path
EOS
) do |args|

path = args[0]

return path.gsub(/\/\s/, ' ').gsub(/\//, "\\")
end
end
2 changes: 2 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
# This class is called from puppet_agent for service config.
#
class puppet_agent::config {
assert_private()

}
36 changes: 25 additions & 11 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,39 @@
# None will be started if the array is empty.
#
class puppet_agent (
$package_name = $::puppet_agent::params::package_name,
$arch = $::architecture,
$is_pe = $::puppet_agent::params::_is_pe,
$package_name = $::puppet_agent::params::package_name,
$service_names = $::puppet_agent::params::service_names,
$source = $::puppet_agent::params::_source,
) inherits ::puppet_agent::params {

if versioncmp("$::clientversion", '3.8.0') < 0 {
validate_re($arch, ['^x86$','^x64$','^i386$','^amd64$','^x86_64$','^power$'])

if versioncmp("${::clientversion}", '3.8.0') < 0 {
fail('upgrading requires Puppet 3.8')
}
elsif versioncmp("$::clientversion", '4.0.0') >= 0 {
elsif versioncmp("${::clientversion}", '4.0.0') >= 0 {
info('puppet_agent performs no actions on Puppet 4+')
}
else {
class { '::puppet_agent::prepare': } ->
class { '::puppet_agent::install': } ->
class { '::puppet_agent::config': } ~>
class { '::puppet_agent::service': }
if $::architecture == 'x86' and $arch == 'x64' {
fail('Unable to install x64 on a x86 system')
}
if $::osfamily == 'windows' {
class { '::puppet_agent::prepare': } ->
class { '::puppet_agent::windows::install': }
}
else {
class { '::puppet_agent::prepare': } ->
class { '::puppet_agent::install': } ->
class { '::puppet_agent::config': } ~>
class { '::puppet_agent::service': }

contain '::puppet_agent::prepare'
contain '::puppet_agent::install'
contain '::puppet_agent::config'
contain '::puppet_agent::service'
contain '::puppet_agent::prepare'
contain '::puppet_agent::install'
contain '::puppet_agent::config'
contain '::puppet_agent::service'
}
}
}
1 change: 1 addition & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This class is called from puppet_agent for install.
#
class puppet_agent::install {
assert_private()

package { $::puppet_agent::package_name:
ensure => present,
Expand Down
Loading