repo
string | commit
string | message
string | diff
string |
---|---|---|---|
ghoneycutt/puppet-module-puppet
|
99af107cf89237382c06f5cb641b5564f75f5bac
|
Speed up TravisCI testing by removing redundant tests
|
diff --git a/Rakefile b/Rakefile
index 399896d..fc6faf4 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,35 +1,29 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'github_changelog_generator/task'
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
config.user = 'ghoneycutt'
config.project = 'puppet-module-puppet'
config.issues = false
config.token = ENV['GITHUB_CHANGELOG_TOKEN']
end
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_140chars')
PuppetLint.configuration.relative = true
PuppetLint.configuration.ignore_paths = ['spec/**/*.pp', 'pkg/**/*.pp']
desc 'Validate manifests, templates, and ruby files'
task :validate do
- Dir['manifests/**/*.pp'].each do |manifest|
- sh "puppet parser validate --noop #{manifest}"
- end
Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file|
sh "ruby -c #{ruby_file}" unless ruby_file =~ %r{spec/fixtures}
end
- Dir['templates/**/*.erb'].each do |template|
- sh "erb -P -x -T '-' #{template} | ruby -c"
- end
end
desc 'Run tests for CI'
task :test do
[:lint, :validate, :spec].each do |test|
Rake::Task[test].invoke
end
end
|
ghoneycutt/puppet-module-puppet
|
ae7918f12127fea0aa670e38dbf69dfa3749b59b
|
Stop rubocop checking
|
diff --git a/.rubocop.yml b/.rubocop.yml
deleted file mode 100644
index 15ee7c9..0000000
--- a/.rubocop.yml
+++ /dev/null
@@ -1,51 +0,0 @@
----
-AllCops:
- DisplayCopNames: true
- DisplayStyleGuide: true
- Exclude:
- - vendor/**/*
- - pkg/**/*
- - spec/fixtures/**/*
-
-# Cop's to ignore
-
-# With this enabled it suggests a change that will break the Gemfile
-Lint/AssignmentInCondition:
- Enabled: false
-
-Metrics/LineLength:
- Enabled: false
-
-# This is a good idea, but does not line up the rest of the lines making it
-# harder to read
-Style/IndentHash:
- Enabled: false
-
-Style/Next:
- Enabled: false
-
-# If enabled, this cop makes it harder to understand the logic
-Style/NonNilCheck:
- Enabled: false
-
-Style/TrailingCommaInLiteral:
- Enabled: false
-
-Style/TrailingCommaInArguments:
- Enabled: false
-
-# Cop's that require ruby >= 1.9
-Style/HashSyntax:
- Enabled: false
-
-Style/BracesAroundHashParameters:
- Enabled: false
-
-Bundler/DuplicatedGem:
- Enabled: false
-
-Style/NegatedIf:
- Enabled: false
-
-Style/BlockLength:
- Enabled: false
diff --git a/.travis.yml b/.travis.yml
index 5768a43..7d44936 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,31 +1,30 @@
---
language: ruby
rvm:
- 2.1.9
env:
matrix:
- - PUPPET_GEM_VERSION="~> 4.7.0" CHECK=test
- - PUPPET_GEM_VERSION="~> 4.8.0" CHECK=test
- - PUPPET_GEM_VERSION="~> 4.9.0" CHECK=test
- - PUPPET_GEM_VERSION="~> 4.10.0" CHECK=test
- - PUPPET_GEM_VERSION="~> 4" CHECK=test
- - PUPPET_GEM_VERSION="~> 4" CHECK=rubocop
+ - PUPPET_GEM_VERSION="~> 4.7.0"
+ - PUPPET_GEM_VERSION="~> 4.8.0"
+ - PUPPET_GEM_VERSION="~> 4.9.0"
+ - PUPPET_GEM_VERSION="~> 4.10.0"
+ - PUPPET_GEM_VERSION="~> 4"
sudo: false
before_install:
- bundle -v
- gem update --system
- gem update bundler
- gem --version
- bundle -v
-script: 'SPEC_OPTS="--format documentation" bundle exec rake $CHECK'
+script: 'SPEC_OPTS="--format documentation" bundle exec rake test'
matrix:
fast_finish: true
notifications:
email: false
diff --git a/Gemfile b/Gemfile
index 013c7f2..ec1afbd 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,39 +1,38 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
gem 'activesupport', '~> 4.0', :require => false if RUBY_VERSION < '2.2'
gem 'facter', '>= 2.0', :require => false
gem 'hiera', '~> 3.0', :require => false
gem 'metadata-json-lint', :require => false
gem 'puppet-lint', '~> 2.0', :require => false
gem 'puppet-lint-absolute_classname-check', :require => false
gem 'puppet-lint-alias-check', :require => false
gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false
gem 'puppet-lint-empty_string-check', :require => false
gem 'puppet-lint-file_ensure-check', :require => false
gem 'puppet-lint-file_source_rights-check', :require => false
gem 'puppet-lint-leading_zero-check', :require => false
gem 'puppet-lint-resource_reference_syntax', :require => false
gem 'puppet-lint-spaceship_operator_without_tag-check', :require => false
gem 'puppet-lint-trailing_comma-check', :require => false
gem 'puppet-lint-undef_in_function-check', :require => false
gem 'puppet-lint-unquoted_string-check', :require => false
gem 'puppet-lint-variable_contains_upcase', :require => false
gem 'puppet-lint-version_comparison-check', :require => false
gem 'puppetlabs_spec_helper', '>= 1.2.0', :require => false
gem 'rspec-puppet', :require => false
gem 'rspec-puppet-facts', :require => false
-gem 'rubocop', :require => false
# Rack is a dependency of github_changelog_generator
gem 'github_changelog_generator', require: false
if RUBY_VERSION <= '2.2.2'
gem 'rack', '~> 1.0', :require => false
else
gem 'rack', :require => false
end
diff --git a/Rakefile b/Rakefile
index 4f4e855..399896d 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,38 +1,35 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
-require 'rubocop/rake_task'
require 'github_changelog_generator/task'
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
config.user = 'ghoneycutt'
config.project = 'puppet-module-puppet'
config.issues = false
config.token = ENV['GITHUB_CHANGELOG_TOKEN']
end
-RuboCop::RakeTask.new
-
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_140chars')
PuppetLint.configuration.relative = true
PuppetLint.configuration.ignore_paths = ['spec/**/*.pp', 'pkg/**/*.pp']
desc 'Validate manifests, templates, and ruby files'
task :validate do
Dir['manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}"
end
Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file|
sh "ruby -c #{ruby_file}" unless ruby_file =~ %r{spec/fixtures}
end
Dir['templates/**/*.erb'].each do |template|
sh "erb -P -x -T '-' #{template} | ruby -c"
end
end
desc 'Run tests for CI'
task :test do
[:lint, :validate, :spec].each do |test|
Rake::Task[test].invoke
end
end
|
ghoneycutt/puppet-module-puppet
|
11276734b7613b53dd559f5999cbc8321e60f70f
|
Explicitly support Puppet versions 4.9 and 4.10
|
diff --git a/.travis.yml b/.travis.yml
index 9b11944..5768a43 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,29 +1,31 @@
---
language: ruby
rvm:
- 2.1.9
env:
matrix:
- PUPPET_GEM_VERSION="~> 4.7.0" CHECK=test
- PUPPET_GEM_VERSION="~> 4.8.0" CHECK=test
+ - PUPPET_GEM_VERSION="~> 4.9.0" CHECK=test
+ - PUPPET_GEM_VERSION="~> 4.10.0" CHECK=test
- PUPPET_GEM_VERSION="~> 4" CHECK=test
- PUPPET_GEM_VERSION="~> 4" CHECK=rubocop
sudo: false
before_install:
- bundle -v
- gem update --system
- gem update bundler
- gem --version
- bundle -v
script: 'SPEC_OPTS="--format documentation" bundle exec rake $CHECK'
matrix:
fast_finish: true
notifications:
email: false
|
ghoneycutt/puppet-module-puppet
|
7ad720b1e7f9bd1eac3396b3f259a9033a6d9f38
|
Remove ruby 2.3.1 as it will not be supported in Puppet v4
|
diff --git a/.travis.yml b/.travis.yml
index c108f58..9b11944 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,30 +1,29 @@
---
language: ruby
rvm:
- 2.1.9
- - 2.3.1
env:
matrix:
- PUPPET_GEM_VERSION="~> 4.7.0" CHECK=test
- PUPPET_GEM_VERSION="~> 4.8.0" CHECK=test
- PUPPET_GEM_VERSION="~> 4" CHECK=test
- PUPPET_GEM_VERSION="~> 4" CHECK=rubocop
sudo: false
before_install:
- bundle -v
- gem update --system
- gem update bundler
- gem --version
- bundle -v
script: 'SPEC_OPTS="--format documentation" bundle exec rake $CHECK'
matrix:
fast_finish: true
notifications:
email: false
diff --git a/README.md b/README.md
index ca8aa32..ca62036 100644
--- a/README.md
+++ b/README.md
@@ -1,195 +1,195 @@
# puppet-module-puppet
#### Table of Contents
1. [Module Description](#module-description)
1. [Dependencies](#dependencies)
1. [Compatibility](#compatibility)
1. [Class Descriptions](#class-descriptions)
* [puppet](#class-puppet)
* [puppet::server](#class-puppet-server)
# Module description
[](https://travis-ci.org/ghoneycutt/puppet-module-puppet)
This module handles the various parts of puppet including the agent and
puppetserver. It is highly opionated and does not seek to manage the
agent and server in all ways that they can be configured and
implemented.
* The agent runs in noop by default. This is the safest way and ensures
that changes are known by having to specify that you want to run in
enforcing mode.
* The agent does not run as a service. There is no good reason for
running the service. Instead cron should be used to better manage how
and when the agent runs.
* By default the agent will run every thirty minutes from cron and the
minutes will be randomized using fqdn_rand() so they are consistent
per host. If you would like a different schedule, this is easily
disabled by setting `run_every_thirty` to `false`, in which case,
it is suggested that the schedule by specified in your profile.
* The trusted_node_data option in puppet.conf is set to true.
This module is targeted at Puppet v4. If you need support for Puppet v3,
please see the puppetv3 branch of this module. Which supports the agent,
master (with apache/passenger), Puppet Dashboard and puppet-lint.
To use the agent, use `include ::puppet`. If the system is also a
puppetserver, use `include ::puppet::server`, which will also manage the
agent.
It uses puppetlabs/inifile to manage the entries in puppet.conf.
# Dependencies
For version ranges, please see metadata.json.
* [puppetlabs/inifile](https://github.com/puppetlabs/puppetlabs-inifile)
* [puppetlabs/stdlib](https://github.com/puppetlabs/puppetlabs-stdlib)
# Compatibility
-Puppet v4 with Ruby versions 2.1.9 and 2.3.1 with the following
-platforms. Please consult the CI testing matrix in .travis.yml for more
-info. If you are looking for Puppet v3, please see the [puppetv3
+Puppet v4 with Ruby versions 2.1.9 with the following platforms. Please
+consult the CI testing matrix in .travis.yml for more info. If you are
+looking for Puppet v3, please see the [puppetv3
branch](https://github.com/ghoneycutt/puppet-module-puppet/tree/puppetv3).
* EL 6
===
# Class Descriptions
## Class `puppet`
### Description
Manages the puppet agent.
A note on types, `Variant[Enum['true', 'false'], Boolean]` means that
boolean `true` and `false` are supported as well as stringified `'true'`
and `'false'`.
### Parameters
---
#### certname (type: String)
The certificate name for the client.
- *Default*: $::fqdn
---
#### run_every_thirty (type: Variant[Enum['true', 'false'], Boolean])
Determines if a cron job to run the puppet agent every thirty minutes
should be present.
- *Default*: true
---
#### run_in_noop (type: Variant[Enum['true', 'false'], Boolean])
Determines if the puppet agent should run in noop mode. This is done by
appending '--noop' to the `cron_command` parameter.
- *Default*: true
---
#### cron_command (type: String)
Command that will be run from cron for the puppet agent.
- *Default*: '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache
--no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
---
#### run_at_boot (type: Variant[Enum['true', 'false'], Boolean])
Determine if a cron job should present that will run the puppet agent at
boot time.
- *Default*: true
---
#### config_path (type: String)
The absolute path to the puppet config file.
- *Default*: /etc/puppetlabs/puppet/puppet.conf
---
#### server (type: String)
The name of the puppet server.
- *Default*: 'puppet'
---
#### ca_server (type: String)
The name of the puppet CA server.
- *Default*: 'puppet'
---
#### env (type: String)
Value of environment option in puppet.conf which defaults to the
environment of the current puppet run. By setting this parameter, you
can specify an environment on the command line (`puppet agent -t
--environment foo`) and it will not trigger a change to the puppet.conf.
- *Default*: $environment
---
#### graph (type: Variant[Enum['true', 'false'], Boolean])
Value of the graph option in puppet.conf.
- *Default*: false
---
#### agent_sysconfig_path (type: String)
The absolute path to the puppet agent sysconfig file.
- *Default*: '/etc/sysconfig/puppet'
## Class `puppet::server`
Manages the puppetserver.
---
#### ca (type: Variant[Enum['true', 'false'], Boolean])
Determines if the system is a puppet CA (certificate authority). There
should be only one CA per cluster of puppet masters.
- *Default*: false
---
#### autosign_entries (type: Variant[Array[String, 1], Undef])
Optional array of entries that will be autosigned.
- *Default*: undef
---
#### sysconfig_path (type: String)
The absolute path to the puppetserver sysconfig file.
- *Default*: '/etc/sysconfig/puppetserver'
---
#### memory_size (type: String /^\d+(m|g)$/)
The amount of memory allocated to the puppetserver. This is passed to
the Xms and Xmx arguments for java. It must be a whole number followed
by the unit 'm' for MB or 'g' for GB.
- *Default*: '2g'
---
#### enc (type: Optional[String])
The absolute path to an ENC. If this is set, it will be the value for the
external_nodes option in puppet.conf and the node_terminus option will
be set to 'exec'.
- *Default*: undef
---
#### dns_alt_names (type: Optional[String])
Value of the dns_alt_names option in puppet.conf.
- *Default*: undef
|
ghoneycutt/puppet-module-puppet
|
439dc5babcde05d08ca7d4e67c41938da0ce102a
|
Remove deprecated options archive_file_server and archive_files
|
diff --git a/README.md b/README.md
index 4dc3f45..ca8aa32 100644
--- a/README.md
+++ b/README.md
@@ -1,207 +1,195 @@
# puppet-module-puppet
#### Table of Contents
1. [Module Description](#module-description)
1. [Dependencies](#dependencies)
1. [Compatibility](#compatibility)
1. [Class Descriptions](#class-descriptions)
* [puppet](#class-puppet)
* [puppet::server](#class-puppet-server)
# Module description
[](https://travis-ci.org/ghoneycutt/puppet-module-puppet)
This module handles the various parts of puppet including the agent and
puppetserver. It is highly opionated and does not seek to manage the
agent and server in all ways that they can be configured and
implemented.
* The agent runs in noop by default. This is the safest way and ensures
that changes are known by having to specify that you want to run in
enforcing mode.
* The agent does not run as a service. There is no good reason for
running the service. Instead cron should be used to better manage how
and when the agent runs.
* By default the agent will run every thirty minutes from cron and the
minutes will be randomized using fqdn_rand() so they are consistent
per host. If you would like a different schedule, this is easily
disabled by setting `run_every_thirty` to `false`, in which case,
it is suggested that the schedule by specified in your profile.
* The trusted_node_data option in puppet.conf is set to true.
This module is targeted at Puppet v4. If you need support for Puppet v3,
please see the puppetv3 branch of this module. Which supports the agent,
master (with apache/passenger), Puppet Dashboard and puppet-lint.
To use the agent, use `include ::puppet`. If the system is also a
puppetserver, use `include ::puppet::server`, which will also manage the
agent.
It uses puppetlabs/inifile to manage the entries in puppet.conf.
# Dependencies
For version ranges, please see metadata.json.
* [puppetlabs/inifile](https://github.com/puppetlabs/puppetlabs-inifile)
* [puppetlabs/stdlib](https://github.com/puppetlabs/puppetlabs-stdlib)
# Compatibility
Puppet v4 with Ruby versions 2.1.9 and 2.3.1 with the following
platforms. Please consult the CI testing matrix in .travis.yml for more
info. If you are looking for Puppet v3, please see the [puppetv3
branch](https://github.com/ghoneycutt/puppet-module-puppet/tree/puppetv3).
* EL 6
===
# Class Descriptions
## Class `puppet`
### Description
Manages the puppet agent.
A note on types, `Variant[Enum['true', 'false'], Boolean]` means that
boolean `true` and `false` are supported as well as stringified `'true'`
and `'false'`.
### Parameters
---
#### certname (type: String)
The certificate name for the client.
- *Default*: $::fqdn
---
#### run_every_thirty (type: Variant[Enum['true', 'false'], Boolean])
Determines if a cron job to run the puppet agent every thirty minutes
should be present.
- *Default*: true
---
#### run_in_noop (type: Variant[Enum['true', 'false'], Boolean])
Determines if the puppet agent should run in noop mode. This is done by
appending '--noop' to the `cron_command` parameter.
- *Default*: true
---
#### cron_command (type: String)
Command that will be run from cron for the puppet agent.
- *Default*: '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache
--no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
---
#### run_at_boot (type: Variant[Enum['true', 'false'], Boolean])
Determine if a cron job should present that will run the puppet agent at
boot time.
- *Default*: true
---
#### config_path (type: String)
The absolute path to the puppet config file.
- *Default*: /etc/puppetlabs/puppet/puppet.conf
---
#### server (type: String)
The name of the puppet server.
- *Default*: 'puppet'
---
#### ca_server (type: String)
The name of the puppet CA server.
- *Default*: 'puppet'
---
#### env (type: String)
Value of environment option in puppet.conf which defaults to the
environment of the current puppet run. By setting this parameter, you
can specify an environment on the command line (`puppet agent -t
--environment foo`) and it will not trigger a change to the puppet.conf.
- *Default*: $environment
---
#### graph (type: Variant[Enum['true', 'false'], Boolean])
Value of the graph option in puppet.conf.
- *Default*: false
----
-#### archive_files (type: Variant[Enum['true', 'false'], Boolean])
-Value of the archive_files option in puppet.conf.
-
-- *Default*: false
-
----
-#### archive_file_server (type: String)
-Value of the archive_file_server option in puppet.conf.
-
-- *Default*: 'puppet'
-
---
#### agent_sysconfig_path (type: String)
The absolute path to the puppet agent sysconfig file.
- *Default*: '/etc/sysconfig/puppet'
## Class `puppet::server`
Manages the puppetserver.
---
#### ca (type: Variant[Enum['true', 'false'], Boolean])
Determines if the system is a puppet CA (certificate authority). There
should be only one CA per cluster of puppet masters.
- *Default*: false
---
#### autosign_entries (type: Variant[Array[String, 1], Undef])
Optional array of entries that will be autosigned.
- *Default*: undef
---
#### sysconfig_path (type: String)
The absolute path to the puppetserver sysconfig file.
- *Default*: '/etc/sysconfig/puppetserver'
---
#### memory_size (type: String /^\d+(m|g)$/)
The amount of memory allocated to the puppetserver. This is passed to
the Xms and Xmx arguments for java. It must be a whole number followed
by the unit 'm' for MB or 'g' for GB.
- *Default*: '2g'
---
#### enc (type: Optional[String])
The absolute path to an ENC. If this is set, it will be the value for the
external_nodes option in puppet.conf and the node_terminus option will
be set to 'exec'.
- *Default*: undef
---
#### dns_alt_names (type: Optional[String])
Value of the dns_alt_names option in puppet.conf.
- *Default*: undef
diff --git a/manifests/init.pp b/manifests/init.pp
index 6d011ec..592bcc2 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,125 +1,121 @@
# == Class: puppet
#
# Manages puppet agent
#
class puppet (
String $certname = $::fqdn,
Variant[Enum['true', 'false'], Boolean] $run_every_thirty = true, #lint:ignore:quoted_booleans
Variant[Enum['true', 'false'], Boolean] $run_in_noop = true, #lint:ignore:quoted_booleans
String $cron_command = '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay',
Variant[Enum['true', 'false'], Boolean] $run_at_boot = true, #lint:ignore:quoted_booleans
String $config_path = '/etc/puppetlabs/puppet/puppet.conf',
String $server = 'puppet',
String $ca_server = 'puppet',
String $env = $environment,
Variant[Enum['true', 'false'], Boolean] $graph = false, #lint:ignore:quoted_booleans
- Variant[Enum['true', 'false'], Boolean] $archive_files = false, #lint:ignore:quoted_booleans
- String $archive_file_server = 'puppet',
String $agent_sysconfig_path = '/etc/sysconfig/puppet',
) {
if $config_path != undef {
validate_absolute_path($config_path)
}
if $agent_sysconfig_path != undef {
validate_absolute_path($agent_sysconfig_path)
}
if is_string($run_every_thirty) == true {
$run_every_thirty_bool = str2bool($run_every_thirty)
} else {
$run_every_thirty_bool = $run_every_thirty
}
if is_string($run_in_noop) == true {
$run_in_noop_bool = str2bool($run_in_noop)
} else {
$run_in_noop_bool = $run_in_noop
}
if is_string($run_at_boot) == true {
$run_at_boot_bool = str2bool($run_at_boot)
} else {
$run_at_boot_bool = $run_at_boot
}
if $run_every_thirty_bool == true {
$cron_run_one = fqdn_rand(30)
$cron_run_two = fqdn_rand(30) + 30
$cron_minute = [ $cron_run_one, $cron_run_two]
$cron_ensure = 'present'
} else {
$cron_ensure = 'absent'
$cron_minute = undef
}
if $run_in_noop_bool == true {
$cron_command_real = "${cron_command} --noop"
} else {
$cron_command_real = $cron_command
}
cron { 'puppet_agent_every_thirty':
ensure => $cron_ensure,
command => $cron_command_real,
user => 'root',
hour => '*',
minute => $cron_minute,
}
if $run_at_boot_bool == true {
$at_boot_ensure = 'present'
} else {
$at_boot_ensure = 'absent'
}
cron { 'puppet_agent_once_at_boot':
ensure => $at_boot_ensure,
command => $cron_command_real,
user => 'root',
special => 'reboot',
}
$ini_defaults = {
ensure => 'present',
path => $::puppet::config_path,
section => 'main',
require => File['puppet_config'],
}
$ini_settings = {
'server' => { setting => 'server', value => $server,},
'ca_server' => { setting => 'ca_server', value => $ca_server,},
'certname' => { setting => 'certname', value => $certname,},
'environment' => { setting => 'environment', value => $env,},
'trusted_node_data' => { setting => 'trusted_node_data', value => true,},
'graph' => { setting => 'graph', value => $graph,},
- 'archive_files' => { setting => 'archive_files', value => $archive_files,},
- 'archive_file_server' => { setting => 'archive_file_server', value => $archive_file_server,},
}
create_resources('ini_setting', $ini_settings, $ini_defaults)
file { 'puppet_config':
ensure => 'file',
path => $config_path,
owner => 'root',
group => 'root',
mode => '0644',
}
file { 'puppet_agent_sysconfig':
ensure => 'file',
path => $agent_sysconfig_path,
content => template('puppet/agent_sysconfig.erb'),
owner => 'root',
group => 'root',
mode => '0644',
}
service { 'puppet_agent_daemon':
ensure => 'stopped',
name => 'puppet',
enable => false,
}
}
diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb
index 56acddb..7039d78 100644
--- a/spec/classes/init_spec.rb
+++ b/spec/classes/init_spec.rb
@@ -1,299 +1,297 @@
require 'spec_helper'
describe 'puppet' do
# fqdn_rand() entries will always return this
minute = [2, 32]
# Filter out duplicate platforms
platforms = on_supported_os.select { |k, _v| !k.to_s.match(/^(RedHat|Scientific|OracleLinux)/i) }
platforms.each do |os, facts|
context "on #{os} with default values for parameters" do
let(:facts) do
facts
end
it { is_expected.to compile.with_all_deps }
it { should contain_class('puppet') }
it { should_not contain_file('puppetserver_sysconfig') }
it { should_not contain_service('puppetserver') }
it { should_not contain_class('puppet::server') }
it do
should contain_cron('puppet_agent_every_thirty').with({
:ensure => 'present',
:command => '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay --noop',
:user => 'root',
:hour => '*',
#:minute => [16,46],
:minute => minute,
})
end
it do
should contain_cron('puppet_agent_once_at_boot').with({
:ensure => 'present',
:command => '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay --noop',
:user => 'root',
:special => 'reboot',
})
end
ini_settings = {
'server' => 'puppet',
'ca_server' => 'puppet',
'certname' => 'puppet.example.com',
'environment' => 'rp_env',
'trusted_node_data' => true,
'graph' => false,
- 'archive_files' => false,
- 'archive_file_server' => 'puppet',
}
ini_settings.each do |setting, value|
it do
should contain_ini_setting(setting).with({
:ensure => 'present',
:setting => setting,
:value => value,
:path => '/etc/puppetlabs/puppet/puppet.conf',
:section => 'main',
:require => 'File[puppet_config]',
})
end
end
it do
should contain_file('puppet_config').with({
:ensure => 'file',
:path => '/etc/puppetlabs/puppet/puppet.conf',
:owner => 'root',
:group => 'root',
:mode => '0644',
})
end
puppet_agent_sysconfig = File.read(fixtures('puppet_agent_sysconfig'))
it do
should contain_file('puppet_agent_sysconfig').with({
:ensure => 'file',
:path => '/etc/sysconfig/puppet',
:content => puppet_agent_sysconfig,
:owner => 'root',
:group => 'root',
:mode => '0644',
})
end
it do
should contain_service('puppet_agent_daemon').with({
:ensure => 'stopped',
:name => 'puppet',
:enable => false,
})
end
end
end
describe 'with run_every_thirty' do
[true, 'true', false, 'false'].each do |value|
[true, 'true', false, 'false'].each do |noop_value|
context "set to #{value} (as #{value.class}) and run_in_noop set to #{noop_value} (as #{noop_value.class})" do
let(:params) do
{
:run_every_thirty => value,
:run_in_noop => noop_value,
}
end
if [true, 'true'].include?(value)
cron_ensure = 'present'
cron_minute = minute
else
cron_ensure = 'absent'
cron_minute = nil
end
cron_command = if [true, 'true'].include?(noop_value)
'/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay --noop'
else
'/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
end
it do
should contain_cron('puppet_agent_every_thirty').with({
:ensure => cron_ensure,
:command => cron_command,
:user => 'root',
:hour => '*',
:minute => cron_minute,
})
end
end
end
end
end
describe 'with cron_command specified' do
context 'and run_in_noop set to true' do
let(:params) do
{
:run_in_noop => true,
:cron_command => '/some/command'
}
end
it { should contain_cron('puppet_agent_every_thirty').with_command('/some/command --noop') }
it { should contain_cron('puppet_agent_once_at_boot').with_command('/some/command --noop') }
end
context 'and run_in_noop set to false' do
let(:params) do
{
:run_in_noop => false,
:cron_command => '/some/command'
}
end
it { should contain_cron('puppet_agent_every_thirty').with_command('/some/command') }
it { should contain_cron('puppet_agent_once_at_boot').with_command('/some/command') }
end
end
describe 'with run_at_boot' do
[true, 'true', false, 'false'].each do |value|
context "set to #{value} (as #{value.class})" do
let(:params) { { :run_at_boot => value } }
foo = if [true, 'true'].include?(value)
'present'
else
'absent'
end
it { should contain_cron('puppet_agent_once_at_boot').with_ensure(foo) }
end
end
end
describe 'with config_path specified' do
let(:params) { { :config_path => '/path/to/puppet.conf' } }
it { should contain_file('puppet_config').with_path('/path/to/puppet.conf') }
- ini_settings = %w(server ca_server certname environment trusted_node_data graph archive_files archive_file_server)
+ ini_settings = %w(server ca_server certname environment trusted_node_data graph)
ini_settings.each do |setting|
it { should contain_ini_setting(setting).with_path('/path/to/puppet.conf') }
end
end
describe 'with puppet.conf ini setting' do
- %w(server ca_server certname graph archive_files archive_file_server).each do |setting|
+ %w(server ca_server certname graph).each do |setting|
context "#{setting} set to a valid entry" do
# 'true' is used because it is acceptable to all of the above
# parameters. Some of the settings are strings and some are boolean and
# stringified booleans.
let(:params) { { setting => 'true' } }
it do
should contain_ini_setting(setting).with({
:ensure => 'present',
:setting => setting,
:value => 'true',
:path => '/etc/puppetlabs/puppet/puppet.conf',
:section => 'main',
:require => 'File[puppet_config]',
})
end
end
end
end
describe 'with env specified' do
let(:params) { { :env => 'myenv' } }
it do
should contain_ini_setting('environment').with({
:ensure => 'present',
:setting => 'environment',
:value => 'myenv',
:path => '/etc/puppetlabs/puppet/puppet.conf',
:section => 'main',
:require => 'File[puppet_config]',
})
end
end
describe 'without env specified' do
it do
should contain_ini_setting('environment').with({
:ensure => 'present',
:setting => 'environment',
:value => 'rp_env',
:path => '/etc/puppetlabs/puppet/puppet.conf',
:section => 'main',
:require => 'File[puppet_config]',
})
end
end
describe 'with server specified' do
let(:params) { { :server => 'foo' } }
it do
should contain_ini_setting('server').with({
:ensure => 'present',
:setting => 'server',
:value => 'foo',
:path => '/etc/puppetlabs/puppet/puppet.conf',
:section => 'main',
:require => 'File[puppet_config]',
})
end
end
describe 'parameter type and content validations' do
validations = {
'absolute paths' => {
:name => %w(config_path agent_sysconfig_path),
:valid => ['/absolute/path'],
:invalid => ['not/an/absolute/path'],
:message => 'is not an absolute path',
},
'booleans' => {
- :name => %w(run_every_thirty run_in_noop run_at_boot graph archive_files),
+ :name => %w(run_every_thirty run_in_noop run_at_boot graph),
:valid => [true, 'true', false, 'false'],
:invalid => ['string', %w(array), { 'ha' => 'sh' }, 3, 2.42],
:message => 'Error while evaluating a Resource Statement',
},
'strings' => {
- :name => %w(certname cron_command server ca_server archive_file_server env),
+ :name => %w(certname cron_command server ca_server env),
:valid => ['string'],
:invalid => [true, %w(array), { 'ha' => 'sh' }, 3, 2.42],
:message => 'Error while evaluating a Resource Statement',
},
}
validations.sort.each do |type, var|
var[:name].each do |var_name|
var[:params] = {} if var[:params].nil?
var[:valid].each do |valid|
context "when #{var_name} (#{type}) is set to valid #{valid} (as #{valid.class})" do
let(:params) { [var[:params], { :"#{var_name}" => valid, }].reduce(:merge) }
it { should compile }
end
end
var[:invalid].each do |invalid|
context "when #{var_name} (#{type}) is set to invalid #{invalid} (as #{invalid.class})" do
let(:params) { [var[:params], { :"#{var_name}" => invalid, }].reduce(:merge) }
it 'should fail' do
expect { should contain_class(subject) }.to raise_error(Puppet::Error, /#{var[:message]}/)
end
end
end
end # var[:name].each
end # validations.sort.each
end # describe 'parameter type content validations'
end
|
ghoneycutt/puppet-module-puppet
|
71016b8f3d118206c5a344351b47428c152a1ab4
|
Remove deprecated pe requirement from metadata
|
diff --git a/metadata.json b/metadata.json
index e630078..c7b711e 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,51 +1,47 @@
{
"name": "ghoneycutt-puppet",
"version": "3.1.0",
"author": "ghoneycutt",
"summary": "Manages Puppet agent and puppetserver",
"description": "Manages Puppet agent and puppetserver.",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
- {
- "name": "pe",
- "version_requirement": ">= 4.7.0 < 5.0.0"
- },
{
"name": "puppet",
"version_requirement": ">= 4.7.0 < 5.0.0"
}
],
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"6"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"6"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"6"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"6"
]
}
],
"dependencies": [
{"name":"puppetlabs/inifile","version_requirement":">= 1.6.0 < 2.0.0"},
{"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 6.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
9eb6779baf55d7dfc3f0976eb464e30e1c2e93bd
|
Release v3.1.0 - Add parameter env
|
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 02c8098..15185f4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,308 +1,316 @@
# Change Log
+## [v3.1.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v3.1.0)
+
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v3.0.2...v3.1.0)
+
+**Merged pull requests:**
+
+- Add parameter env [\#130](https://github.com/ghoneycutt/puppet-module-puppet/pull/130) ([ghoneycutt](https://github.com/ghoneycutt))
+
## [v3.0.2](https://github.com/ghoneycutt/puppet-module-puppet/tree/v3.0.2) (2017-01-11)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v3.0.1...v3.0.2)
**Merged pull requests:**
- Puppetserver sysconfig [\#128](https://github.com/ghoneycutt/puppet-module-puppet/pull/128) ([ghoneycutt](https://github.com/ghoneycutt))
- Fix gem dependencies for testing [\#127](https://github.com/ghoneycutt/puppet-module-puppet/pull/127) ([ghoneycutt](https://github.com/ghoneycutt))
## [v3.0.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v3.0.1) (2016-11-02)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v3.0.0...v3.0.1)
**Merged pull requests:**
- Add rubocop testing and conform to its style recommendations [\#124](https://github.com/ghoneycutt/puppet-module-puppet/pull/124) ([ghoneycutt](https://github.com/ghoneycutt))
- Add rake task for github\_changelog\_generator [\#123](https://github.com/ghoneycutt/puppet-module-puppet/pull/123) ([ghoneycutt](https://github.com/ghoneycutt))
- Support puppet v4.8.0 [\#122](https://github.com/ghoneycutt/puppet-module-puppet/pull/122) ([ghoneycutt](https://github.com/ghoneycutt))
## [v3.0.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v3.0.0) (2016-11-02)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.19.0...v3.0.0)
**Merged pull requests:**
- Release v3.0.0 - Transition to Puppet v4 [\#121](https://github.com/ghoneycutt/puppet-module-puppet/pull/121) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.19.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.19.0) (2016-07-13)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.18.1...v2.19.0)
**Merged pull requests:**
- Puppetv4 agent [\#119](https://github.com/ghoneycutt/puppet-module-puppet/pull/119) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.18.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.18.1) (2016-07-12)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.18.0...v2.18.1)
**Merged pull requests:**
- Fix testing [\#120](https://github.com/ghoneycutt/puppet-module-puppet/pull/120) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.18.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.18.0) (2016-04-29)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.17.1...v2.18.0)
**Merged pull requests:**
- Dont recursively cleanup master maintenance [\#118](https://github.com/ghoneycutt/puppet-module-puppet/pull/118) ([ghoneycutt](https://github.com/ghoneycutt))
- Allow configuration of the number of max requests handled per puppet ⦠[\#114](https://github.com/ghoneycutt/puppet-module-puppet/pull/114) ([dfairhurst](https://github.com/dfairhurst))
## [v2.17.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.17.1) (2016-04-28)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.17.0...v2.17.1)
**Merged pull requests:**
- Modernize [\#117](https://github.com/ghoneycutt/puppet-module-puppet/pull/117) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.17.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.17.0) (2015-11-25)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.16.0...v2.17.0)
**Merged pull requests:**
- parameterize ssldir in puppet agent's config [\#113](https://github.com/ghoneycutt/puppet-module-puppet/pull/113) ([Phil-Friderici](https://github.com/Phil-Friderici))
- Fixup metadata [\#112](https://github.com/ghoneycutt/puppet-module-puppet/pull/112) ([ghoneycutt](https://github.com/ghoneycutt))
- Changed outdated type-function to is\_\<type\> [\#111](https://github.com/ghoneycutt/puppet-module-puppet/pull/111) ([Phil-Friderici](https://github.com/Phil-Friderici))
## [v2.16.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.16.0) (2015-08-18)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.15.0...v2.16.0)
**Merged pull requests:**
- make hardcoded commands really flexible [\#102](https://github.com/ghoneycutt/puppet-module-puppet/pull/102) ([Phil-Friderici](https://github.com/Phil-Friderici))
## [v2.15.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.15.0) (2015-02-20)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/2.14.4...v2.15.0)
**Merged pull requests:**
- Disable master maintenance cronjobs [\#99](https://github.com/ghoneycutt/puppet-module-puppet/pull/99) ([ghoneycutt](https://github.com/ghoneycutt))
## [2.14.4](https://github.com/ghoneycutt/puppet-module-puppet/tree/2.14.4) (2015-02-20)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.14.3...2.14.4)
**Merged pull requests:**
- Support Ruby v2.1.0 [\#98](https://github.com/ghoneycutt/puppet-module-puppet/pull/98) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.14.3](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.14.3) (2015-02-13)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.14.2...v2.14.3)
**Merged pull requests:**
- Improve spec tests for maintenance class [\#96](https://github.com/ghoneycutt/puppet-module-puppet/pull/96) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.14.2](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.14.2) (2014-12-20)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.14.1...v2.14.2)
**Merged pull requests:**
- Travis-ci use containers for faster builds [\#94](https://github.com/ghoneycutt/puppet-module-puppet/pull/94) ([ghoneycutt](https://github.com/ghoneycutt))
- Support run\_interval larger than 30 [\#93](https://github.com/ghoneycutt/puppet-module-puppet/pull/93) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.14.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.14.1) (2014-12-10)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.14.0...v2.14.1)
**Merged pull requests:**
- Follow symlink for reportdir [\#91](https://github.com/ghoneycutt/puppet-module-puppet/pull/91) ([emahags](https://github.com/emahags))
## [v2.14.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.14.0) (2014-11-25)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.13.1...v2.14.0)
**Merged pull requests:**
- Style - Fix indentation of attribute arrows [\#90](https://github.com/ghoneycutt/puppet-module-puppet/pull/90) ([ghoneycutt](https://github.com/ghoneycutt))
- Manage mysql options [\#89](https://github.com/ghoneycutt/puppet-module-puppet/pull/89) ([ghoneycutt](https://github.com/ghoneycutt))
- Fix linebreaks puppetconf [\#86](https://github.com/ghoneycutt/puppet-module-puppet/pull/86) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.13.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.13.1) (2014-10-15)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.13.0...v2.13.1)
**Merged pull requests:**
- Disable SSLv3 as it is insecure [\#84](https://github.com/ghoneycutt/puppet-module-puppet/pull/84) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.13.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.13.0) (2014-10-09)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.12.0...v2.13.0)
**Merged pull requests:**
- Add parameters for http\_proxy and http\_proxy\_port [\#80](https://github.com/ghoneycutt/puppet-module-puppet/pull/80) ([kytomaki](https://github.com/kytomaki))
## [v2.12.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.12.0) (2014-10-06)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.11.3...v2.12.0)
**Merged pull requests:**
- Add support for etckeeper [\#83](https://github.com/ghoneycutt/puppet-module-puppet/pull/83) ([ghoneycutt](https://github.com/ghoneycutt))
- Add masterport to agent config [\#82](https://github.com/ghoneycutt/puppet-module-puppet/pull/82) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.11.3](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.11.3) (2014-10-01)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.11.2...v2.11.3)
**Merged pull requests:**
- V370 [\#77](https://github.com/ghoneycutt/puppet-module-puppet/pull/77) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.11.2](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.11.2) (2014-09-05)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.11.1...v2.11.2)
**Merged pull requests:**
- Metadata [\#76](https://github.com/ghoneycutt/puppet-module-puppet/pull/76) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.11.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.11.1) (2014-06-10)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.11.0...v2.11.1)
**Merged pull requests:**
- Add dependency of ghoneycutt/common to metadata [\#69](https://github.com/ghoneycutt/puppet-module-puppet/pull/69) ([ghoneycutt](https://github.com/ghoneycutt))
- replaced dead links for dashboard [\#68](https://github.com/ghoneycutt/puppet-module-puppet/pull/68) ([aviau](https://github.com/aviau))
## [v2.11.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.11.0) (2014-06-03)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.10.0...v2.11.0)
**Merged pull requests:**
- Stringify facts [\#65](https://github.com/ghoneycutt/puppet-module-puppet/pull/65) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.10.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.10.0) (2014-06-01)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.9.3...v2.10.0)
**Merged pull requests:**
- Add environment fact [\#64](https://github.com/ghoneycutt/puppet-module-puppet/pull/64) ([emahags](https://github.com/emahags))
- Specify version of apache to use in fixtures [\#61](https://github.com/ghoneycutt/puppet-module-puppet/pull/61) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.9.3](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.9.3) (2014-01-31)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.9.2...v2.9.3)
**Merged pull requests:**
- Support Puppet v3.4 and Ruby v2.0.0 [\#57](https://github.com/ghoneycutt/puppet-module-puppet/pull/57) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.9.2](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.9.2) (2014-01-23)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.9.1...v2.9.2)
**Merged pull requests:**
- Remove Travis work around for ruby v1.8.7 [\#56](https://github.com/ghoneycutt/puppet-module-puppet/pull/56) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.9.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.9.1) (2014-01-21)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.9.0...v2.9.1)
**Merged pull requests:**
- Refactor to allow booleans in parameters. [\#55](https://github.com/ghoneycutt/puppet-module-puppet/pull/55) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.9.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.9.0) (2014-01-10)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.8.0...v2.9.0)
**Merged pull requests:**
- Add ability to to clean up the reports directory [\#54](https://github.com/ghoneycutt/puppet-module-puppet/pull/54) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.8.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.8.0) (2014-01-03)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.7.0...v2.8.0)
**Merged pull requests:**
- Set run method to disable [\#53](https://github.com/ghoneycutt/puppet-module-puppet/pull/53) ([ghoneycutt](https://github.com/ghoneycutt))
- Support rspec-puppet v1.0.0 [\#51](https://github.com/ghoneycutt/puppet-module-puppet/pull/51) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.7.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.7.0) (2013-12-06)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.6.1...v2.7.0)
**Merged pull requests:**
- Support Suse 11 [\#49](https://github.com/ghoneycutt/puppet-module-puppet/pull/49) ([ghoneycutt](https://github.com/ghoneycutt))
- Improve spec testing [\#48](https://github.com/ghoneycutt/puppet-module-puppet/pull/48) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.6.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.6.1) (2013-11-11)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.5.3...v2.6.1)
**Merged pull requests:**
- Release v2.6.0 - Debian Support [\#39](https://github.com/ghoneycutt/puppet-module-puppet/pull/39) ([ghoneycutt](https://github.com/ghoneycutt))
- Only define Cron\['puppet\_agent\_once\_at\_boot'\] if $run\_method == 'cron' [\#37](https://github.com/ghoneycutt/puppet-module-puppet/pull/37) ([tekenny](https://github.com/tekenny))
## [v2.5.3](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.5.3) (2013-11-10)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.5.2...v2.5.3)
**Merged pull requests:**
- Fix bug with running puppet::master on Debian [\#38](https://github.com/ghoneycutt/puppet-module-puppet/pull/38) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.5.2](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.5.2) (2013-11-08)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.5.1...v2.5.2)
## [v2.5.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.5.1) (2013-11-08)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.5.0...v2.5.1)
**Merged pull requests:**
- Update mysql [\#36](https://github.com/ghoneycutt/puppet-module-puppet/pull/36) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.5.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.5.0) (2013-11-08)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.4.0...v2.5.0)
**Merged pull requests:**
- Add Support for Solaris to puppet::agent [\#35](https://github.com/ghoneycutt/puppet-module-puppet/pull/35) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.4.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.4.0) (2013-11-08)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.3.0...v2.4.0)
**Merged pull requests:**
- Cleanup dashboard reports [\#32](https://github.com/ghoneycutt/puppet-module-puppet/pull/32) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.3.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.3.0) (2013-11-08)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.2.0...v2.3.0)
**Merged pull requests:**
- Symlink merge [\#34](https://github.com/ghoneycutt/puppet-module-puppet/pull/34) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.2.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.2.0) (2013-11-08)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.1.3...v2.2.0)
**Merged pull requests:**
- Refactor spec tests [\#31](https://github.com/ghoneycutt/puppet-module-puppet/pull/31) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.1.3](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.1.3) (2013-09-29)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.1.2...v2.1.3)
## [v2.1.2](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.1.2) (2013-09-27)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.1.1...v2.1.2)
**Merged pull requests:**
- Update travis to test syntax validation and lint. [\#24](https://github.com/ghoneycutt/puppet-module-puppet/pull/24) ([ghoneycutt](https://github.com/ghoneycutt))
- Secure dashboard [\#22](https://github.com/ghoneycutt/puppet-module-puppet/pull/22) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.1.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.1.1) (2013-09-22)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.1.0...v2.1.1)
**Merged pull requests:**
- Note needed sudoers entry in README for cron jobs [\#21](https://github.com/ghoneycutt/puppet-module-puppet/pull/21) ([ghoneycutt](https://github.com/ghoneycutt))
- Fix dump\_dashboard\_database and redirect output [\#19](https://github.com/ghoneycutt/puppet-module-puppet/pull/19) ([kentjohansson](https://github.com/kentjohansson))
- Show status of Travis-ci in README [\#16](https://github.com/ghoneycutt/puppet-module-puppet/pull/16) ([ghoneycutt](https://github.com/ghoneycutt))
- Differentiate between Dashboard server and not. [\#15](https://github.com/ghoneycutt/puppet-module-puppet/pull/15) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.1.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.1.0) (2013-06-14)
**Merged pull requests:**
- Add option to use htpasswd for Dashboard. [\#14](https://github.com/ghoneycutt/puppet-module-puppet/pull/14) ([ghoneycutt](https://github.com/ghoneycutt))
- Spec tests [\#13](https://github.com/ghoneycutt/puppet-module-puppet/pull/13) ([kividiot](https://github.com/kividiot))
- Update of documentation [\#12](https://github.com/ghoneycutt/puppet-module-puppet/pull/12) ([kividiot](https://github.com/kividiot))
- Add documentation [\#8](https://github.com/ghoneycutt/puppet-module-puppet/pull/8) ([ghoneycutt](https://github.com/ghoneycutt))
- Ensure puppetmaster service is not started at boot time [\#7](https://github.com/ghoneycutt/puppet-module-puppet/pull/7) ([ghoneycutt](https://github.com/ghoneycutt))
- Removed stopping of puppetmaster [\#6](https://github.com/ghoneycutt/puppet-module-puppet/pull/6) ([MWinther](https://github.com/MWinther))
- Basic documentation [\#5](https://github.com/ghoneycutt/puppet-module-puppet/pull/5) ([MWinther](https://github.com/MWinther))
- Rebirth [\#2](https://github.com/ghoneycutt/puppet-module-puppet/pull/2) ([ghoneycutt](https://github.com/ghoneycutt))
-\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\ No newline at end of file
+\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
diff --git a/metadata.json b/metadata.json
index e2ab673..e630078 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,51 +1,51 @@
{
"name": "ghoneycutt-puppet",
- "version": "3.0.2",
+ "version": "3.1.0",
"author": "ghoneycutt",
"summary": "Manages Puppet agent and puppetserver",
"description": "Manages Puppet agent and puppetserver.",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": ">= 4.7.0 < 5.0.0"
},
{
"name": "puppet",
"version_requirement": ">= 4.7.0 < 5.0.0"
}
],
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"6"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"6"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"6"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"6"
]
}
],
"dependencies": [
{"name":"puppetlabs/inifile","version_requirement":">= 1.6.0 < 2.0.0"},
{"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 6.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
727fb93773934cc355674ef29e6c71a8bf177d97
|
Appease rubocop
|
diff --git a/.rubocop.yml b/.rubocop.yml
index b8aeaa5..15ee7c9 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -1,45 +1,51 @@
---
AllCops:
DisplayCopNames: true
DisplayStyleGuide: true
Exclude:
- vendor/**/*
- pkg/**/*
- spec/fixtures/**/*
# Cop's to ignore
# With this enabled it suggests a change that will break the Gemfile
Lint/AssignmentInCondition:
Enabled: false
Metrics/LineLength:
Enabled: false
# This is a good idea, but does not line up the rest of the lines making it
# harder to read
Style/IndentHash:
Enabled: false
Style/Next:
Enabled: false
# If enabled, this cop makes it harder to understand the logic
Style/NonNilCheck:
Enabled: false
Style/TrailingCommaInLiteral:
Enabled: false
Style/TrailingCommaInArguments:
Enabled: false
# Cop's that require ruby >= 1.9
Style/HashSyntax:
Enabled: false
Style/BracesAroundHashParameters:
Enabled: false
Bundler/DuplicatedGem:
Enabled: false
+
+Style/NegatedIf:
+ Enabled: false
+
+Style/BlockLength:
+ Enabled: false
diff --git a/Gemfile b/Gemfile
index 7cad213..013c7f2 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,36 +1,39 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
gem 'activesupport', '~> 4.0', :require => false if RUBY_VERSION < '2.2'
gem 'facter', '>= 2.0', :require => false
gem 'hiera', '~> 3.0', :require => false
gem 'metadata-json-lint', :require => false
gem 'puppet-lint', '~> 2.0', :require => false
gem 'puppet-lint-absolute_classname-check', :require => false
gem 'puppet-lint-alias-check', :require => false
gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false
gem 'puppet-lint-empty_string-check', :require => false
gem 'puppet-lint-file_ensure-check', :require => false
gem 'puppet-lint-file_source_rights-check', :require => false
gem 'puppet-lint-leading_zero-check', :require => false
gem 'puppet-lint-resource_reference_syntax', :require => false
gem 'puppet-lint-spaceship_operator_without_tag-check', :require => false
gem 'puppet-lint-trailing_comma-check', :require => false
gem 'puppet-lint-undef_in_function-check', :require => false
gem 'puppet-lint-unquoted_string-check', :require => false
gem 'puppet-lint-variable_contains_upcase', :require => false
gem 'puppet-lint-version_comparison-check', :require => false
gem 'puppetlabs_spec_helper', '>= 1.2.0', :require => false
gem 'rspec-puppet', :require => false
gem 'rspec-puppet-facts', :require => false
gem 'rubocop', :require => false
# Rack is a dependency of github_changelog_generator
gem 'github_changelog_generator', require: false
-gem 'rack', '~> 1.0', :require => false if RUBY_VERSION <= '2.2.2'
-gem 'rack', :require => false if RUBY_VERSION > '2.2.2'
+if RUBY_VERSION <= '2.2.2'
+ gem 'rack', '~> 1.0', :require => false
+else
+ gem 'rack', :require => false
+end
|
ghoneycutt/puppet-module-puppet
|
dbf80589bf70d7652e1f8c5cdced894848faee5b
|
Add parameter env for configuring environment option in puppet.conf
|
diff --git a/README.md b/README.md
index 64bf742..4dc3f45 100644
--- a/README.md
+++ b/README.md
@@ -1,198 +1,207 @@
# puppet-module-puppet
#### Table of Contents
1. [Module Description](#module-description)
1. [Dependencies](#dependencies)
1. [Compatibility](#compatibility)
1. [Class Descriptions](#class-descriptions)
* [puppet](#class-puppet)
* [puppet::server](#class-puppet-server)
# Module description
[](https://travis-ci.org/ghoneycutt/puppet-module-puppet)
This module handles the various parts of puppet including the agent and
puppetserver. It is highly opionated and does not seek to manage the
agent and server in all ways that they can be configured and
implemented.
* The agent runs in noop by default. This is the safest way and ensures
that changes are known by having to specify that you want to run in
enforcing mode.
* The agent does not run as a service. There is no good reason for
running the service. Instead cron should be used to better manage how
and when the agent runs.
* By default the agent will run every thirty minutes from cron and the
minutes will be randomized using fqdn_rand() so they are consistent
per host. If you would like a different schedule, this is easily
disabled by setting `run_every_thirty` to `false`, in which case,
it is suggested that the schedule by specified in your profile.
* The trusted_node_data option in puppet.conf is set to true.
This module is targeted at Puppet v4. If you need support for Puppet v3,
please see the puppetv3 branch of this module. Which supports the agent,
master (with apache/passenger), Puppet Dashboard and puppet-lint.
To use the agent, use `include ::puppet`. If the system is also a
puppetserver, use `include ::puppet::server`, which will also manage the
agent.
It uses puppetlabs/inifile to manage the entries in puppet.conf.
# Dependencies
For version ranges, please see metadata.json.
* [puppetlabs/inifile](https://github.com/puppetlabs/puppetlabs-inifile)
* [puppetlabs/stdlib](https://github.com/puppetlabs/puppetlabs-stdlib)
# Compatibility
Puppet v4 with Ruby versions 2.1.9 and 2.3.1 with the following
platforms. Please consult the CI testing matrix in .travis.yml for more
info. If you are looking for Puppet v3, please see the [puppetv3
branch](https://github.com/ghoneycutt/puppet-module-puppet/tree/puppetv3).
* EL 6
===
# Class Descriptions
## Class `puppet`
### Description
Manages the puppet agent.
A note on types, `Variant[Enum['true', 'false'], Boolean]` means that
boolean `true` and `false` are supported as well as stringified `'true'`
and `'false'`.
### Parameters
---
#### certname (type: String)
The certificate name for the client.
- *Default*: $::fqdn
---
#### run_every_thirty (type: Variant[Enum['true', 'false'], Boolean])
Determines if a cron job to run the puppet agent every thirty minutes
should be present.
- *Default*: true
---
#### run_in_noop (type: Variant[Enum['true', 'false'], Boolean])
Determines if the puppet agent should run in noop mode. This is done by
appending '--noop' to the `cron_command` parameter.
- *Default*: true
---
#### cron_command (type: String)
Command that will be run from cron for the puppet agent.
- *Default*: '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache
--no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
---
#### run_at_boot (type: Variant[Enum['true', 'false'], Boolean])
Determine if a cron job should present that will run the puppet agent at
boot time.
- *Default*: true
---
#### config_path (type: String)
The absolute path to the puppet config file.
- *Default*: /etc/puppetlabs/puppet/puppet.conf
---
#### server (type: String)
The name of the puppet server.
- *Default*: 'puppet'
---
#### ca_server (type: String)
The name of the puppet CA server.
- *Default*: 'puppet'
+---
+#### env (type: String)
+Value of environment option in puppet.conf which defaults to the
+environment of the current puppet run. By setting this parameter, you
+can specify an environment on the command line (`puppet agent -t
+--environment foo`) and it will not trigger a change to the puppet.conf.
+
+- *Default*: $environment
+
---
#### graph (type: Variant[Enum['true', 'false'], Boolean])
Value of the graph option in puppet.conf.
- *Default*: false
---
#### archive_files (type: Variant[Enum['true', 'false'], Boolean])
Value of the archive_files option in puppet.conf.
- *Default*: false
---
#### archive_file_server (type: String)
Value of the archive_file_server option in puppet.conf.
- *Default*: 'puppet'
---
#### agent_sysconfig_path (type: String)
The absolute path to the puppet agent sysconfig file.
- *Default*: '/etc/sysconfig/puppet'
## Class `puppet::server`
Manages the puppetserver.
---
#### ca (type: Variant[Enum['true', 'false'], Boolean])
Determines if the system is a puppet CA (certificate authority). There
should be only one CA per cluster of puppet masters.
- *Default*: false
---
#### autosign_entries (type: Variant[Array[String, 1], Undef])
Optional array of entries that will be autosigned.
- *Default*: undef
---
#### sysconfig_path (type: String)
The absolute path to the puppetserver sysconfig file.
- *Default*: '/etc/sysconfig/puppetserver'
---
#### memory_size (type: String /^\d+(m|g)$/)
The amount of memory allocated to the puppetserver. This is passed to
the Xms and Xmx arguments for java. It must be a whole number followed
by the unit 'm' for MB or 'g' for GB.
- *Default*: '2g'
---
#### enc (type: Optional[String])
The absolute path to an ENC. If this is set, it will be the value for the
external_nodes option in puppet.conf and the node_terminus option will
be set to 'exec'.
- *Default*: undef
---
#### dns_alt_names (type: Optional[String])
Value of the dns_alt_names option in puppet.conf.
- *Default*: undef
diff --git a/manifests/init.pp b/manifests/init.pp
index 62e4607..6d011ec 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,124 +1,125 @@
# == Class: puppet
#
# Manages puppet agent
#
class puppet (
String $certname = $::fqdn,
Variant[Enum['true', 'false'], Boolean] $run_every_thirty = true, #lint:ignore:quoted_booleans
Variant[Enum['true', 'false'], Boolean] $run_in_noop = true, #lint:ignore:quoted_booleans
String $cron_command = '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay',
Variant[Enum['true', 'false'], Boolean] $run_at_boot = true, #lint:ignore:quoted_booleans
String $config_path = '/etc/puppetlabs/puppet/puppet.conf',
String $server = 'puppet',
String $ca_server = 'puppet',
+ String $env = $environment,
Variant[Enum['true', 'false'], Boolean] $graph = false, #lint:ignore:quoted_booleans
Variant[Enum['true', 'false'], Boolean] $archive_files = false, #lint:ignore:quoted_booleans
String $archive_file_server = 'puppet',
String $agent_sysconfig_path = '/etc/sysconfig/puppet',
) {
if $config_path != undef {
validate_absolute_path($config_path)
}
if $agent_sysconfig_path != undef {
validate_absolute_path($agent_sysconfig_path)
}
if is_string($run_every_thirty) == true {
$run_every_thirty_bool = str2bool($run_every_thirty)
} else {
$run_every_thirty_bool = $run_every_thirty
}
if is_string($run_in_noop) == true {
$run_in_noop_bool = str2bool($run_in_noop)
} else {
$run_in_noop_bool = $run_in_noop
}
if is_string($run_at_boot) == true {
$run_at_boot_bool = str2bool($run_at_boot)
} else {
$run_at_boot_bool = $run_at_boot
}
if $run_every_thirty_bool == true {
$cron_run_one = fqdn_rand(30)
$cron_run_two = fqdn_rand(30) + 30
$cron_minute = [ $cron_run_one, $cron_run_two]
$cron_ensure = 'present'
} else {
$cron_ensure = 'absent'
$cron_minute = undef
}
if $run_in_noop_bool == true {
$cron_command_real = "${cron_command} --noop"
} else {
$cron_command_real = $cron_command
}
cron { 'puppet_agent_every_thirty':
ensure => $cron_ensure,
command => $cron_command_real,
user => 'root',
hour => '*',
minute => $cron_minute,
}
if $run_at_boot_bool == true {
$at_boot_ensure = 'present'
} else {
$at_boot_ensure = 'absent'
}
cron { 'puppet_agent_once_at_boot':
ensure => $at_boot_ensure,
command => $cron_command_real,
user => 'root',
special => 'reboot',
}
$ini_defaults = {
ensure => 'present',
path => $::puppet::config_path,
section => 'main',
require => File['puppet_config'],
}
$ini_settings = {
'server' => { setting => 'server', value => $server,},
'ca_server' => { setting => 'ca_server', value => $ca_server,},
'certname' => { setting => 'certname', value => $certname,},
- 'environment' => { setting => 'environment', value => $environment,},
+ 'environment' => { setting => 'environment', value => $env,},
'trusted_node_data' => { setting => 'trusted_node_data', value => true,},
'graph' => { setting => 'graph', value => $graph,},
'archive_files' => { setting => 'archive_files', value => $archive_files,},
'archive_file_server' => { setting => 'archive_file_server', value => $archive_file_server,},
}
create_resources('ini_setting', $ini_settings, $ini_defaults)
file { 'puppet_config':
ensure => 'file',
path => $config_path,
owner => 'root',
group => 'root',
mode => '0644',
}
file { 'puppet_agent_sysconfig':
ensure => 'file',
path => $agent_sysconfig_path,
content => template('puppet/agent_sysconfig.erb'),
owner => 'root',
group => 'root',
mode => '0644',
}
service { 'puppet_agent_daemon':
ensure => 'stopped',
name => 'puppet',
enable => false,
}
}
diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb
index 242d391..56acddb 100644
--- a/spec/classes/init_spec.rb
+++ b/spec/classes/init_spec.rb
@@ -1,271 +1,299 @@
require 'spec_helper'
describe 'puppet' do
# fqdn_rand() entries will always return this
minute = [2, 32]
# Filter out duplicate platforms
platforms = on_supported_os.select { |k, _v| !k.to_s.match(/^(RedHat|Scientific|OracleLinux)/i) }
platforms.each do |os, facts|
context "on #{os} with default values for parameters" do
let(:facts) do
facts
end
it { is_expected.to compile.with_all_deps }
it { should contain_class('puppet') }
it { should_not contain_file('puppetserver_sysconfig') }
it { should_not contain_service('puppetserver') }
it { should_not contain_class('puppet::server') }
it do
should contain_cron('puppet_agent_every_thirty').with({
:ensure => 'present',
:command => '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay --noop',
:user => 'root',
:hour => '*',
#:minute => [16,46],
:minute => minute,
})
end
it do
should contain_cron('puppet_agent_once_at_boot').with({
:ensure => 'present',
:command => '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay --noop',
:user => 'root',
:special => 'reboot',
})
end
ini_settings = {
'server' => 'puppet',
'ca_server' => 'puppet',
'certname' => 'puppet.example.com',
'environment' => 'rp_env',
'trusted_node_data' => true,
'graph' => false,
'archive_files' => false,
'archive_file_server' => 'puppet',
}
ini_settings.each do |setting, value|
it do
should contain_ini_setting(setting).with({
:ensure => 'present',
:setting => setting,
:value => value,
:path => '/etc/puppetlabs/puppet/puppet.conf',
:section => 'main',
:require => 'File[puppet_config]',
})
end
end
it do
should contain_file('puppet_config').with({
:ensure => 'file',
:path => '/etc/puppetlabs/puppet/puppet.conf',
:owner => 'root',
:group => 'root',
:mode => '0644',
})
end
puppet_agent_sysconfig = File.read(fixtures('puppet_agent_sysconfig'))
it do
should contain_file('puppet_agent_sysconfig').with({
:ensure => 'file',
:path => '/etc/sysconfig/puppet',
:content => puppet_agent_sysconfig,
:owner => 'root',
:group => 'root',
:mode => '0644',
})
end
it do
should contain_service('puppet_agent_daemon').with({
:ensure => 'stopped',
:name => 'puppet',
:enable => false,
})
end
end
end
describe 'with run_every_thirty' do
[true, 'true', false, 'false'].each do |value|
[true, 'true', false, 'false'].each do |noop_value|
context "set to #{value} (as #{value.class}) and run_in_noop set to #{noop_value} (as #{noop_value.class})" do
let(:params) do
{
:run_every_thirty => value,
:run_in_noop => noop_value,
}
end
if [true, 'true'].include?(value)
cron_ensure = 'present'
cron_minute = minute
else
cron_ensure = 'absent'
cron_minute = nil
end
cron_command = if [true, 'true'].include?(noop_value)
'/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay --noop'
else
'/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
end
it do
should contain_cron('puppet_agent_every_thirty').with({
:ensure => cron_ensure,
:command => cron_command,
:user => 'root',
:hour => '*',
:minute => cron_minute,
})
end
end
end
end
end
describe 'with cron_command specified' do
context 'and run_in_noop set to true' do
let(:params) do
{
:run_in_noop => true,
:cron_command => '/some/command'
}
end
it { should contain_cron('puppet_agent_every_thirty').with_command('/some/command --noop') }
it { should contain_cron('puppet_agent_once_at_boot').with_command('/some/command --noop') }
end
context 'and run_in_noop set to false' do
let(:params) do
{
:run_in_noop => false,
:cron_command => '/some/command'
}
end
it { should contain_cron('puppet_agent_every_thirty').with_command('/some/command') }
it { should contain_cron('puppet_agent_once_at_boot').with_command('/some/command') }
end
end
describe 'with run_at_boot' do
[true, 'true', false, 'false'].each do |value|
context "set to #{value} (as #{value.class})" do
let(:params) { { :run_at_boot => value } }
foo = if [true, 'true'].include?(value)
'present'
else
'absent'
end
it { should contain_cron('puppet_agent_once_at_boot').with_ensure(foo) }
end
end
end
describe 'with config_path specified' do
let(:params) { { :config_path => '/path/to/puppet.conf' } }
it { should contain_file('puppet_config').with_path('/path/to/puppet.conf') }
ini_settings = %w(server ca_server certname environment trusted_node_data graph archive_files archive_file_server)
ini_settings.each do |setting|
it { should contain_ini_setting(setting).with_path('/path/to/puppet.conf') }
end
end
describe 'with puppet.conf ini setting' do
%w(server ca_server certname graph archive_files archive_file_server).each do |setting|
context "#{setting} set to a valid entry" do
# 'true' is used because it is acceptable to all of the above
# parameters. Some of the settings are strings and some are boolean and
# stringified booleans.
let(:params) { { setting => 'true' } }
it do
should contain_ini_setting(setting).with({
:ensure => 'present',
:setting => setting,
:value => 'true',
:path => '/etc/puppetlabs/puppet/puppet.conf',
:section => 'main',
:require => 'File[puppet_config]',
})
end
end
end
end
+ describe 'with env specified' do
+ let(:params) { { :env => 'myenv' } }
+
+ it do
+ should contain_ini_setting('environment').with({
+ :ensure => 'present',
+ :setting => 'environment',
+ :value => 'myenv',
+ :path => '/etc/puppetlabs/puppet/puppet.conf',
+ :section => 'main',
+ :require => 'File[puppet_config]',
+ })
+ end
+ end
+
+ describe 'without env specified' do
+ it do
+ should contain_ini_setting('environment').with({
+ :ensure => 'present',
+ :setting => 'environment',
+ :value => 'rp_env',
+ :path => '/etc/puppetlabs/puppet/puppet.conf',
+ :section => 'main',
+ :require => 'File[puppet_config]',
+ })
+ end
+ end
+
describe 'with server specified' do
let(:params) { { :server => 'foo' } }
it do
should contain_ini_setting('server').with({
:ensure => 'present',
:setting => 'server',
:value => 'foo',
:path => '/etc/puppetlabs/puppet/puppet.conf',
:section => 'main',
:require => 'File[puppet_config]',
})
end
end
describe 'parameter type and content validations' do
validations = {
'absolute paths' => {
:name => %w(config_path agent_sysconfig_path),
:valid => ['/absolute/path'],
:invalid => ['not/an/absolute/path'],
:message => 'is not an absolute path',
},
'booleans' => {
:name => %w(run_every_thirty run_in_noop run_at_boot graph archive_files),
:valid => [true, 'true', false, 'false'],
:invalid => ['string', %w(array), { 'ha' => 'sh' }, 3, 2.42],
:message => 'Error while evaluating a Resource Statement',
},
'strings' => {
- :name => %w(certname cron_command server ca_server archive_file_server),
+ :name => %w(certname cron_command server ca_server archive_file_server env),
:valid => ['string'],
:invalid => [true, %w(array), { 'ha' => 'sh' }, 3, 2.42],
:message => 'Error while evaluating a Resource Statement',
},
}
validations.sort.each do |type, var|
var[:name].each do |var_name|
var[:params] = {} if var[:params].nil?
var[:valid].each do |valid|
context "when #{var_name} (#{type}) is set to valid #{valid} (as #{valid.class})" do
let(:params) { [var[:params], { :"#{var_name}" => valid, }].reduce(:merge) }
it { should compile }
end
end
var[:invalid].each do |invalid|
context "when #{var_name} (#{type}) is set to invalid #{invalid} (as #{invalid.class})" do
let(:params) { [var[:params], { :"#{var_name}" => invalid, }].reduce(:merge) }
it 'should fail' do
expect { should contain_class(subject) }.to raise_error(Puppet::Error, /#{var[:message]}/)
end
end
end
end # var[:name].each
end # validations.sort.each
end # describe 'parameter type content validations'
end
|
ghoneycutt/puppet-module-puppet
|
a83fe158bf54e4d319d79a1598c42b55d1da75e8
|
Bump license for 2017
|
diff --git a/LICENSE b/LICENSE
index bb5ebbd..d1211db 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,13 +1,13 @@
-Copyright (C) 2010-2016 Garrett Honeycutt <[email protected]>
+Copyright (C) 2010-2017 Garrett Honeycutt <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
ghoneycutt/puppet-module-puppet
|
ac1ec9da96bf2d6158ba57e42f010eb3a02218e8
|
Release v3.0.2 - Update puppetserver sysconfig
|
diff --git a/metadata.json b/metadata.json
index d6b1c70..e2ab673 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,51 +1,51 @@
{
"name": "ghoneycutt-puppet",
- "version": "3.0.1",
+ "version": "3.0.2",
"author": "ghoneycutt",
"summary": "Manages Puppet agent and puppetserver",
"description": "Manages Puppet agent and puppetserver.",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": ">= 4.7.0 < 5.0.0"
},
{
"name": "puppet",
"version_requirement": ">= 4.7.0 < 5.0.0"
}
],
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"6"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"6"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"6"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"6"
]
}
],
"dependencies": [
{"name":"puppetlabs/inifile","version_requirement":">= 1.6.0 < 2.0.0"},
{"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 6.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
b3248068d65ff20e803552df1bfdec0664ac0e17
|
Fix gems to support Ruby 2.1
|
diff --git a/Gemfile b/Gemfile
index 0c8a974..7cad213 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,35 +1,36 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
+gem 'activesupport', '~> 4.0', :require => false if RUBY_VERSION < '2.2'
gem 'facter', '>= 2.0', :require => false
gem 'hiera', '~> 3.0', :require => false
gem 'metadata-json-lint', :require => false
gem 'puppet-lint', '~> 2.0', :require => false
gem 'puppet-lint-absolute_classname-check', :require => false
gem 'puppet-lint-alias-check', :require => false
gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false
gem 'puppet-lint-empty_string-check', :require => false
gem 'puppet-lint-file_ensure-check', :require => false
gem 'puppet-lint-file_source_rights-check', :require => false
gem 'puppet-lint-leading_zero-check', :require => false
gem 'puppet-lint-resource_reference_syntax', :require => false
gem 'puppet-lint-spaceship_operator_without_tag-check', :require => false
gem 'puppet-lint-trailing_comma-check', :require => false
gem 'puppet-lint-undef_in_function-check', :require => false
gem 'puppet-lint-unquoted_string-check', :require => false
gem 'puppet-lint-variable_contains_upcase', :require => false
gem 'puppet-lint-version_comparison-check', :require => false
gem 'puppetlabs_spec_helper', '>= 1.2.0', :require => false
gem 'rspec-puppet', :require => false
gem 'rspec-puppet-facts', :require => false
gem 'rubocop', :require => false
-# Rack if a dependency of github_changelog_generator
+# Rack is a dependency of github_changelog_generator
gem 'github_changelog_generator', require: false
gem 'rack', '~> 1.0', :require => false if RUBY_VERSION <= '2.2.2'
gem 'rack', :require => false if RUBY_VERSION > '2.2.2'
|
ghoneycutt/puppet-module-puppet
|
66a5d55a2d9ef115300981667bf6a35a66fdfc32
|
Ensure TravisCI is using an updated bundler
|
diff --git a/.travis.yml b/.travis.yml
index ffb954f..c108f58 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,23 +1,30 @@
---
language: ruby
rvm:
- 2.1.9
- 2.3.1
env:
matrix:
- PUPPET_GEM_VERSION="~> 4.7.0" CHECK=test
- PUPPET_GEM_VERSION="~> 4.8.0" CHECK=test
- PUPPET_GEM_VERSION="~> 4" CHECK=test
- PUPPET_GEM_VERSION="~> 4" CHECK=rubocop
sudo: false
+before_install:
+ - bundle -v
+ - gem update --system
+ - gem update bundler
+ - gem --version
+ - bundle -v
+
script: 'SPEC_OPTS="--format documentation" bundle exec rake $CHECK'
matrix:
fast_finish: true
notifications:
email: false
|
ghoneycutt/puppet-module-puppet
|
c5790616813afafe41313d9e2ed106c705754790
|
Alphabetize gem orderings and fix rubocop
|
diff --git a/.rubocop.yml b/.rubocop.yml
index a1b2204..b8aeaa5 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -1,42 +1,45 @@
---
AllCops:
DisplayCopNames: true
DisplayStyleGuide: true
Exclude:
- vendor/**/*
- pkg/**/*
- spec/fixtures/**/*
# Cop's to ignore
# With this enabled it suggests a change that will break the Gemfile
Lint/AssignmentInCondition:
Enabled: false
Metrics/LineLength:
Enabled: false
# This is a good idea, but does not line up the rest of the lines making it
# harder to read
Style/IndentHash:
Enabled: false
Style/Next:
Enabled: false
# If enabled, this cop makes it harder to understand the logic
Style/NonNilCheck:
Enabled: false
Style/TrailingCommaInLiteral:
Enabled: false
Style/TrailingCommaInArguments:
Enabled: false
# Cop's that require ruby >= 1.9
Style/HashSyntax:
Enabled: false
Style/BracesAroundHashParameters:
Enabled: false
+
+Bundler/DuplicatedGem:
+ Enabled: false
diff --git a/Gemfile b/Gemfile
index 9df5471..0c8a974 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,35 +1,35 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
-gem 'metadata-json-lint', :require => false
-gem 'rspec-puppet', :require => false
-gem 'rspec-puppet-facts', :require => false
-gem 'rubocop', :require => false
-gem 'puppetlabs_spec_helper', '>= 1.2.0', :require => false
gem 'facter', '>= 2.0', :require => false
gem 'hiera', '~> 3.0', :require => false
+gem 'metadata-json-lint', :require => false
gem 'puppet-lint', '~> 2.0', :require => false
gem 'puppet-lint-absolute_classname-check', :require => false
gem 'puppet-lint-alias-check', :require => false
gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false
gem 'puppet-lint-empty_string-check', :require => false
gem 'puppet-lint-file_ensure-check', :require => false
gem 'puppet-lint-file_source_rights-check', :require => false
gem 'puppet-lint-leading_zero-check', :require => false
gem 'puppet-lint-resource_reference_syntax', :require => false
gem 'puppet-lint-spaceship_operator_without_tag-check', :require => false
gem 'puppet-lint-trailing_comma-check', :require => false
gem 'puppet-lint-undef_in_function-check', :require => false
gem 'puppet-lint-unquoted_string-check', :require => false
gem 'puppet-lint-variable_contains_upcase', :require => false
gem 'puppet-lint-version_comparison-check', :require => false
+gem 'puppetlabs_spec_helper', '>= 1.2.0', :require => false
+gem 'rspec-puppet', :require => false
+gem 'rspec-puppet-facts', :require => false
+gem 'rubocop', :require => false
# Rack if a dependency of github_changelog_generator
gem 'github_changelog_generator', require: false
gem 'rack', '~> 1.0', :require => false if RUBY_VERSION <= '2.2.2'
gem 'rack', :require => false if RUBY_VERSION > '2.2.2'
|
ghoneycutt/puppet-module-puppet
|
3ab56db54af93c249f4381dc345770c4466b3643
|
Remove duplicate entry for rubocop
|
diff --git a/Gemfile b/Gemfile
index ed39cde..9df5471 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,36 +1,35 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
gem 'metadata-json-lint', :require => false
gem 'rspec-puppet', :require => false
gem 'rspec-puppet-facts', :require => false
gem 'rubocop', :require => false
gem 'puppetlabs_spec_helper', '>= 1.2.0', :require => false
gem 'facter', '>= 2.0', :require => false
gem 'hiera', '~> 3.0', :require => false
-gem 'rubocop', :require => false
gem 'puppet-lint', '~> 2.0', :require => false
gem 'puppet-lint-absolute_classname-check', :require => false
gem 'puppet-lint-alias-check', :require => false
gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false
gem 'puppet-lint-empty_string-check', :require => false
gem 'puppet-lint-file_ensure-check', :require => false
gem 'puppet-lint-file_source_rights-check', :require => false
gem 'puppet-lint-leading_zero-check', :require => false
gem 'puppet-lint-resource_reference_syntax', :require => false
gem 'puppet-lint-spaceship_operator_without_tag-check', :require => false
gem 'puppet-lint-trailing_comma-check', :require => false
gem 'puppet-lint-undef_in_function-check', :require => false
gem 'puppet-lint-unquoted_string-check', :require => false
gem 'puppet-lint-variable_contains_upcase', :require => false
gem 'puppet-lint-version_comparison-check', :require => false
# Rack if a dependency of github_changelog_generator
gem 'github_changelog_generator', require: false
gem 'rack', '~> 1.0', :require => false if RUBY_VERSION <= '2.2.2'
gem 'rack', :require => false if RUBY_VERSION > '2.2.2'
|
ghoneycutt/puppet-module-puppet
|
0692736db3cf6cd42172891716598497840bd31f
|
Add CHANGELOG for v3.0.1
|
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e94bcf7..af17072 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,284 +1,300 @@
# Change Log
+## [v3.0.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v3.0.1) (2016-11-02)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v3.0.0...v3.0.1)
+
+**Merged pull requests:**
+
+- Add rubocop testing and conform to its style recommendations [\#124](https://github.com/ghoneycutt/puppet-module-puppet/pull/124) ([ghoneycutt](https://github.com/ghoneycutt))
+- Add rake task for github\_changelog\_generator [\#123](https://github.com/ghoneycutt/puppet-module-puppet/pull/123) ([ghoneycutt](https://github.com/ghoneycutt))
+- Support puppet v4.8.0 [\#122](https://github.com/ghoneycutt/puppet-module-puppet/pull/122) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v3.0.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v3.0.0) (2016-11-02)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.19.0...v3.0.0)
+
+**Merged pull requests:**
+
+- Release v3.0.0 - Transition to Puppet v4 [\#121](https://github.com/ghoneycutt/puppet-module-puppet/pull/121) ([ghoneycutt](https://github.com/ghoneycutt))
+
## [v2.19.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.19.0) (2016-07-13)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.18.1...v2.19.0)
**Merged pull requests:**
- Puppetv4 agent [\#119](https://github.com/ghoneycutt/puppet-module-puppet/pull/119) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.18.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.18.1) (2016-07-12)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.18.0...v2.18.1)
**Merged pull requests:**
- Fix testing [\#120](https://github.com/ghoneycutt/puppet-module-puppet/pull/120) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.18.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.18.0) (2016-04-29)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.17.1...v2.18.0)
**Merged pull requests:**
- Dont recursively cleanup master maintenance [\#118](https://github.com/ghoneycutt/puppet-module-puppet/pull/118) ([ghoneycutt](https://github.com/ghoneycutt))
- Allow configuration of the number of max requests handled per puppet ⦠[\#114](https://github.com/ghoneycutt/puppet-module-puppet/pull/114) ([dfairhurst](https://github.com/dfairhurst))
## [v2.17.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.17.1) (2016-04-28)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.17.0...v2.17.1)
**Merged pull requests:**
- Modernize [\#117](https://github.com/ghoneycutt/puppet-module-puppet/pull/117) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.17.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.17.0) (2015-11-25)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.16.0...v2.17.0)
**Merged pull requests:**
- parameterize ssldir in puppet agent's config [\#113](https://github.com/ghoneycutt/puppet-module-puppet/pull/113) ([Phil-Friderici](https://github.com/Phil-Friderici))
- Fixup metadata [\#112](https://github.com/ghoneycutt/puppet-module-puppet/pull/112) ([ghoneycutt](https://github.com/ghoneycutt))
- Changed outdated type-function to is\_\<type\> [\#111](https://github.com/ghoneycutt/puppet-module-puppet/pull/111) ([Phil-Friderici](https://github.com/Phil-Friderici))
## [v2.16.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.16.0) (2015-08-18)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.15.0...v2.16.0)
**Merged pull requests:**
- make hardcoded commands really flexible [\#102](https://github.com/ghoneycutt/puppet-module-puppet/pull/102) ([Phil-Friderici](https://github.com/Phil-Friderici))
## [v2.15.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.15.0) (2015-02-20)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/2.14.4...v2.15.0)
**Merged pull requests:**
- Disable master maintenance cronjobs [\#99](https://github.com/ghoneycutt/puppet-module-puppet/pull/99) ([ghoneycutt](https://github.com/ghoneycutt))
## [2.14.4](https://github.com/ghoneycutt/puppet-module-puppet/tree/2.14.4) (2015-02-20)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.14.3...2.14.4)
**Merged pull requests:**
- Support Ruby v2.1.0 [\#98](https://github.com/ghoneycutt/puppet-module-puppet/pull/98) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.14.3](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.14.3) (2015-02-13)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.14.2...v2.14.3)
**Merged pull requests:**
- Improve spec tests for maintenance class [\#96](https://github.com/ghoneycutt/puppet-module-puppet/pull/96) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.14.2](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.14.2) (2014-12-20)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.14.1...v2.14.2)
**Merged pull requests:**
- Travis-ci use containers for faster builds [\#94](https://github.com/ghoneycutt/puppet-module-puppet/pull/94) ([ghoneycutt](https://github.com/ghoneycutt))
- Support run\_interval larger than 30 [\#93](https://github.com/ghoneycutt/puppet-module-puppet/pull/93) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.14.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.14.1) (2014-12-10)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.14.0...v2.14.1)
**Merged pull requests:**
- Follow symlink for reportdir [\#91](https://github.com/ghoneycutt/puppet-module-puppet/pull/91) ([emahags](https://github.com/emahags))
## [v2.14.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.14.0) (2014-11-25)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.13.1...v2.14.0)
**Merged pull requests:**
- Style - Fix indentation of attribute arrows [\#90](https://github.com/ghoneycutt/puppet-module-puppet/pull/90) ([ghoneycutt](https://github.com/ghoneycutt))
- Manage mysql options [\#89](https://github.com/ghoneycutt/puppet-module-puppet/pull/89) ([ghoneycutt](https://github.com/ghoneycutt))
- Fix linebreaks puppetconf [\#86](https://github.com/ghoneycutt/puppet-module-puppet/pull/86) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.13.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.13.1) (2014-10-15)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.13.0...v2.13.1)
**Merged pull requests:**
- Disable SSLv3 as it is insecure [\#84](https://github.com/ghoneycutt/puppet-module-puppet/pull/84) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.13.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.13.0) (2014-10-09)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.12.0...v2.13.0)
**Merged pull requests:**
- Add parameters for http\_proxy and http\_proxy\_port [\#80](https://github.com/ghoneycutt/puppet-module-puppet/pull/80) ([kytomaki](https://github.com/kytomaki))
## [v2.12.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.12.0) (2014-10-06)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.11.3...v2.12.0)
**Merged pull requests:**
- Add support for etckeeper [\#83](https://github.com/ghoneycutt/puppet-module-puppet/pull/83) ([ghoneycutt](https://github.com/ghoneycutt))
- Add masterport to agent config [\#82](https://github.com/ghoneycutt/puppet-module-puppet/pull/82) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.11.3](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.11.3) (2014-10-01)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.11.2...v2.11.3)
**Merged pull requests:**
- V370 [\#77](https://github.com/ghoneycutt/puppet-module-puppet/pull/77) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.11.2](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.11.2) (2014-09-05)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.11.1...v2.11.2)
**Merged pull requests:**
- Metadata [\#76](https://github.com/ghoneycutt/puppet-module-puppet/pull/76) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.11.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.11.1) (2014-06-10)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.11.0...v2.11.1)
**Merged pull requests:**
- Add dependency of ghoneycutt/common to metadata [\#69](https://github.com/ghoneycutt/puppet-module-puppet/pull/69) ([ghoneycutt](https://github.com/ghoneycutt))
- replaced dead links for dashboard [\#68](https://github.com/ghoneycutt/puppet-module-puppet/pull/68) ([aviau](https://github.com/aviau))
## [v2.11.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.11.0) (2014-06-03)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.10.0...v2.11.0)
**Merged pull requests:**
- Stringify facts [\#65](https://github.com/ghoneycutt/puppet-module-puppet/pull/65) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.10.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.10.0) (2014-06-01)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.9.3...v2.10.0)
**Merged pull requests:**
- Add environment fact [\#64](https://github.com/ghoneycutt/puppet-module-puppet/pull/64) ([emahags](https://github.com/emahags))
- Specify version of apache to use in fixtures [\#61](https://github.com/ghoneycutt/puppet-module-puppet/pull/61) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.9.3](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.9.3) (2014-01-31)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.9.2...v2.9.3)
**Merged pull requests:**
- Support Puppet v3.4 and Ruby v2.0.0 [\#57](https://github.com/ghoneycutt/puppet-module-puppet/pull/57) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.9.2](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.9.2) (2014-01-23)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.9.1...v2.9.2)
**Merged pull requests:**
- Remove Travis work around for ruby v1.8.7 [\#56](https://github.com/ghoneycutt/puppet-module-puppet/pull/56) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.9.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.9.1) (2014-01-21)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.9.0...v2.9.1)
**Merged pull requests:**
- Refactor to allow booleans in parameters. [\#55](https://github.com/ghoneycutt/puppet-module-puppet/pull/55) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.9.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.9.0) (2014-01-10)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.8.0...v2.9.0)
**Merged pull requests:**
- Add ability to to clean up the reports directory [\#54](https://github.com/ghoneycutt/puppet-module-puppet/pull/54) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.8.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.8.0) (2014-01-03)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.7.0...v2.8.0)
**Merged pull requests:**
- Set run method to disable [\#53](https://github.com/ghoneycutt/puppet-module-puppet/pull/53) ([ghoneycutt](https://github.com/ghoneycutt))
- Support rspec-puppet v1.0.0 [\#51](https://github.com/ghoneycutt/puppet-module-puppet/pull/51) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.7.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.7.0) (2013-12-06)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.6.1...v2.7.0)
**Merged pull requests:**
- Support Suse 11 [\#49](https://github.com/ghoneycutt/puppet-module-puppet/pull/49) ([ghoneycutt](https://github.com/ghoneycutt))
- Improve spec testing [\#48](https://github.com/ghoneycutt/puppet-module-puppet/pull/48) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.6.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.6.1) (2013-11-11)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.5.3...v2.6.1)
**Merged pull requests:**
- Release v2.6.0 - Debian Support [\#39](https://github.com/ghoneycutt/puppet-module-puppet/pull/39) ([ghoneycutt](https://github.com/ghoneycutt))
- Only define Cron\['puppet\_agent\_once\_at\_boot'\] if $run\_method == 'cron' [\#37](https://github.com/ghoneycutt/puppet-module-puppet/pull/37) ([tekenny](https://github.com/tekenny))
## [v2.5.3](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.5.3) (2013-11-10)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.5.2...v2.5.3)
**Merged pull requests:**
- Fix bug with running puppet::master on Debian [\#38](https://github.com/ghoneycutt/puppet-module-puppet/pull/38) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.5.2](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.5.2) (2013-11-08)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.5.1...v2.5.2)
## [v2.5.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.5.1) (2013-11-08)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.5.0...v2.5.1)
**Merged pull requests:**
- Update mysql [\#36](https://github.com/ghoneycutt/puppet-module-puppet/pull/36) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.5.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.5.0) (2013-11-08)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.4.0...v2.5.0)
**Merged pull requests:**
- Add Support for Solaris to puppet::agent [\#35](https://github.com/ghoneycutt/puppet-module-puppet/pull/35) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.4.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.4.0) (2013-11-08)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.3.0...v2.4.0)
**Merged pull requests:**
- Cleanup dashboard reports [\#32](https://github.com/ghoneycutt/puppet-module-puppet/pull/32) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.3.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.3.0) (2013-11-08)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.2.0...v2.3.0)
**Merged pull requests:**
- Symlink merge [\#34](https://github.com/ghoneycutt/puppet-module-puppet/pull/34) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.2.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.2.0) (2013-11-08)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.1.3...v2.2.0)
**Merged pull requests:**
- Refactor spec tests [\#31](https://github.com/ghoneycutt/puppet-module-puppet/pull/31) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.1.3](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.1.3) (2013-09-29)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.1.2...v2.1.3)
## [v2.1.2](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.1.2) (2013-09-27)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.1.1...v2.1.2)
**Merged pull requests:**
- Update travis to test syntax validation and lint. [\#24](https://github.com/ghoneycutt/puppet-module-puppet/pull/24) ([ghoneycutt](https://github.com/ghoneycutt))
- Secure dashboard [\#22](https://github.com/ghoneycutt/puppet-module-puppet/pull/22) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.1.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.1.1) (2013-09-22)
[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.1.0...v2.1.1)
**Merged pull requests:**
- Note needed sudoers entry in README for cron jobs [\#21](https://github.com/ghoneycutt/puppet-module-puppet/pull/21) ([ghoneycutt](https://github.com/ghoneycutt))
- Fix dump\_dashboard\_database and redirect output [\#19](https://github.com/ghoneycutt/puppet-module-puppet/pull/19) ([kentjohansson](https://github.com/kentjohansson))
- Show status of Travis-ci in README [\#16](https://github.com/ghoneycutt/puppet-module-puppet/pull/16) ([ghoneycutt](https://github.com/ghoneycutt))
- Differentiate between Dashboard server and not. [\#15](https://github.com/ghoneycutt/puppet-module-puppet/pull/15) ([ghoneycutt](https://github.com/ghoneycutt))
## [v2.1.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.1.0) (2013-06-14)
**Merged pull requests:**
- Add option to use htpasswd for Dashboard. [\#14](https://github.com/ghoneycutt/puppet-module-puppet/pull/14) ([ghoneycutt](https://github.com/ghoneycutt))
- Spec tests [\#13](https://github.com/ghoneycutt/puppet-module-puppet/pull/13) ([kividiot](https://github.com/kividiot))
- Update of documentation [\#12](https://github.com/ghoneycutt/puppet-module-puppet/pull/12) ([kividiot](https://github.com/kividiot))
- Add documentation [\#8](https://github.com/ghoneycutt/puppet-module-puppet/pull/8) ([ghoneycutt](https://github.com/ghoneycutt))
- Ensure puppetmaster service is not started at boot time [\#7](https://github.com/ghoneycutt/puppet-module-puppet/pull/7) ([ghoneycutt](https://github.com/ghoneycutt))
- Removed stopping of puppetmaster [\#6](https://github.com/ghoneycutt/puppet-module-puppet/pull/6) ([MWinther](https://github.com/MWinther))
- Basic documentation [\#5](https://github.com/ghoneycutt/puppet-module-puppet/pull/5) ([MWinther](https://github.com/MWinther))
- Rebirth [\#2](https://github.com/ghoneycutt/puppet-module-puppet/pull/2) ([ghoneycutt](https://github.com/ghoneycutt))
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\ No newline at end of file
|
ghoneycutt/puppet-module-puppet
|
0fc62abd1d6ef893aea12c8a2f5aaf0793bf0f80
|
Release v3.0.1 - Add testing and release tooling
|
diff --git a/metadata.json b/metadata.json
index 33b38a8..d6b1c70 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,51 +1,51 @@
{
"name": "ghoneycutt-puppet",
- "version": "3.0.0",
+ "version": "3.0.1",
"author": "ghoneycutt",
"summary": "Manages Puppet agent and puppetserver",
"description": "Manages Puppet agent and puppetserver.",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": ">= 4.7.0 < 5.0.0"
},
{
"name": "puppet",
"version_requirement": ">= 4.7.0 < 5.0.0"
}
],
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"6"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"6"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"6"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"6"
]
}
],
"dependencies": [
{"name":"puppetlabs/inifile","version_requirement":">= 1.6.0 < 2.0.0"},
{"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 6.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
296da4864affd87e7ac309f762a74d6d59cf9fb8
|
Add rubocop testing and conform to its style recommendations
|
diff --git a/.travis.yml b/.travis.yml
index 38a3a54..ffb954f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,22 +1,23 @@
---
language: ruby
rvm:
- 2.1.9
- 2.3.1
env:
matrix:
- - PUPPET_GEM_VERSION="~> 4.7.0"
- - PUPPET_GEM_VERSION="~> 4.8.0"
- - PUPPET_GEM_VERSION="~> 4"
+ - PUPPET_GEM_VERSION="~> 4.7.0" CHECK=test
+ - PUPPET_GEM_VERSION="~> 4.8.0" CHECK=test
+ - PUPPET_GEM_VERSION="~> 4" CHECK=test
+ - PUPPET_GEM_VERSION="~> 4" CHECK=rubocop
sudo: false
-script: 'SPEC_OPTS="--format documentation" bundle exec rake validate lint spec'
+script: 'SPEC_OPTS="--format documentation" bundle exec rake $CHECK'
matrix:
fast_finish: true
notifications:
email: false
diff --git a/Gemfile b/Gemfile
index 9df5471..ed39cde 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,35 +1,36 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
gem 'metadata-json-lint', :require => false
gem 'rspec-puppet', :require => false
gem 'rspec-puppet-facts', :require => false
gem 'rubocop', :require => false
gem 'puppetlabs_spec_helper', '>= 1.2.0', :require => false
gem 'facter', '>= 2.0', :require => false
gem 'hiera', '~> 3.0', :require => false
+gem 'rubocop', :require => false
gem 'puppet-lint', '~> 2.0', :require => false
gem 'puppet-lint-absolute_classname-check', :require => false
gem 'puppet-lint-alias-check', :require => false
gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false
gem 'puppet-lint-empty_string-check', :require => false
gem 'puppet-lint-file_ensure-check', :require => false
gem 'puppet-lint-file_source_rights-check', :require => false
gem 'puppet-lint-leading_zero-check', :require => false
gem 'puppet-lint-resource_reference_syntax', :require => false
gem 'puppet-lint-spaceship_operator_without_tag-check', :require => false
gem 'puppet-lint-trailing_comma-check', :require => false
gem 'puppet-lint-undef_in_function-check', :require => false
gem 'puppet-lint-unquoted_string-check', :require => false
gem 'puppet-lint-variable_contains_upcase', :require => false
gem 'puppet-lint-version_comparison-check', :require => false
# Rack if a dependency of github_changelog_generator
gem 'github_changelog_generator', require: false
gem 'rack', '~> 1.0', :require => false if RUBY_VERSION <= '2.2.2'
gem 'rack', :require => false if RUBY_VERSION > '2.2.2'
diff --git a/Rakefile b/Rakefile
index 86f084f..4f4e855 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,31 +1,38 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'rubocop/rake_task'
require 'github_changelog_generator/task'
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
config.user = 'ghoneycutt'
config.project = 'puppet-module-puppet'
config.issues = false
config.token = ENV['GITHUB_CHANGELOG_TOKEN']
end
RuboCop::RakeTask.new
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_140chars')
PuppetLint.configuration.relative = true
PuppetLint.configuration.ignore_paths = ['spec/**/*.pp', 'pkg/**/*.pp']
desc 'Validate manifests, templates, and ruby files'
task :validate do
Dir['manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}"
end
Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file|
sh "ruby -c #{ruby_file}" unless ruby_file =~ %r{spec/fixtures}
end
Dir['templates/**/*.erb'].each do |template|
sh "erb -P -x -T '-' #{template} | ruby -c"
end
end
+
+desc 'Run tests for CI'
+task :test do
+ [:lint, :validate, :spec].each do |test|
+ Rake::Task[test].invoke
+ end
+end
diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb
index 9eece6e..242d391 100644
--- a/spec/classes/init_spec.rb
+++ b/spec/classes/init_spec.rb
@@ -1,271 +1,271 @@
require 'spec_helper'
describe 'puppet' do
# fqdn_rand() entries will always return this
minute = [2, 32]
# Filter out duplicate platforms
platforms = on_supported_os.select { |k, _v| !k.to_s.match(/^(RedHat|Scientific|OracleLinux)/i) }
platforms.each do |os, facts|
context "on #{os} with default values for parameters" do
let(:facts) do
facts
end
it { is_expected.to compile.with_all_deps }
it { should contain_class('puppet') }
it { should_not contain_file('puppetserver_sysconfig') }
it { should_not contain_service('puppetserver') }
it { should_not contain_class('puppet::server') }
it do
should contain_cron('puppet_agent_every_thirty').with({
:ensure => 'present',
:command => '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay --noop',
:user => 'root',
:hour => '*',
#:minute => [16,46],
:minute => minute,
})
end
it do
should contain_cron('puppet_agent_once_at_boot').with({
:ensure => 'present',
:command => '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay --noop',
:user => 'root',
:special => 'reboot',
})
end
ini_settings = {
'server' => 'puppet',
'ca_server' => 'puppet',
'certname' => 'puppet.example.com',
'environment' => 'rp_env',
'trusted_node_data' => true,
'graph' => false,
'archive_files' => false,
'archive_file_server' => 'puppet',
}
ini_settings.each do |setting, value|
it do
should contain_ini_setting(setting).with({
:ensure => 'present',
:setting => setting,
:value => value,
:path => '/etc/puppetlabs/puppet/puppet.conf',
:section => 'main',
:require => 'File[puppet_config]',
})
end
end
it do
should contain_file('puppet_config').with({
:ensure => 'file',
:path => '/etc/puppetlabs/puppet/puppet.conf',
:owner => 'root',
:group => 'root',
:mode => '0644',
})
end
puppet_agent_sysconfig = File.read(fixtures('puppet_agent_sysconfig'))
it do
should contain_file('puppet_agent_sysconfig').with({
:ensure => 'file',
:path => '/etc/sysconfig/puppet',
:content => puppet_agent_sysconfig,
:owner => 'root',
:group => 'root',
:mode => '0644',
})
end
it do
should contain_service('puppet_agent_daemon').with({
:ensure => 'stopped',
:name => 'puppet',
:enable => false,
})
end
end
end
describe 'with run_every_thirty' do
[true, 'true', false, 'false'].each do |value|
[true, 'true', false, 'false'].each do |noop_value|
context "set to #{value} (as #{value.class}) and run_in_noop set to #{noop_value} (as #{noop_value.class})" do
let(:params) do
{
:run_every_thirty => value,
:run_in_noop => noop_value,
}
end
if [true, 'true'].include?(value)
cron_ensure = 'present'
cron_minute = minute
else
cron_ensure = 'absent'
cron_minute = nil
end
- if [true, 'true'].include?(noop_value)
- cron_command = '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay --noop'
- else
- cron_command = '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
- end
+ cron_command = if [true, 'true'].include?(noop_value)
+ '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay --noop'
+ else
+ '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
+ end
it do
should contain_cron('puppet_agent_every_thirty').with({
:ensure => cron_ensure,
:command => cron_command,
:user => 'root',
:hour => '*',
:minute => cron_minute,
})
end
end
end
end
end
describe 'with cron_command specified' do
context 'and run_in_noop set to true' do
let(:params) do
{
:run_in_noop => true,
:cron_command => '/some/command'
}
end
it { should contain_cron('puppet_agent_every_thirty').with_command('/some/command --noop') }
it { should contain_cron('puppet_agent_once_at_boot').with_command('/some/command --noop') }
end
context 'and run_in_noop set to false' do
let(:params) do
{
:run_in_noop => false,
:cron_command => '/some/command'
}
end
it { should contain_cron('puppet_agent_every_thirty').with_command('/some/command') }
it { should contain_cron('puppet_agent_once_at_boot').with_command('/some/command') }
end
end
describe 'with run_at_boot' do
[true, 'true', false, 'false'].each do |value|
context "set to #{value} (as #{value.class})" do
let(:params) { { :run_at_boot => value } }
- if [true, 'true'].include?(value)
- foo = 'present'
- else
- foo = 'absent'
- end
+ foo = if [true, 'true'].include?(value)
+ 'present'
+ else
+ 'absent'
+ end
it { should contain_cron('puppet_agent_once_at_boot').with_ensure(foo) }
end
end
end
describe 'with config_path specified' do
let(:params) { { :config_path => '/path/to/puppet.conf' } }
it { should contain_file('puppet_config').with_path('/path/to/puppet.conf') }
ini_settings = %w(server ca_server certname environment trusted_node_data graph archive_files archive_file_server)
ini_settings.each do |setting|
it { should contain_ini_setting(setting).with_path('/path/to/puppet.conf') }
end
end
describe 'with puppet.conf ini setting' do
%w(server ca_server certname graph archive_files archive_file_server).each do |setting|
context "#{setting} set to a valid entry" do
# 'true' is used because it is acceptable to all of the above
# parameters. Some of the settings are strings and some are boolean and
# stringified booleans.
let(:params) { { setting => 'true' } }
it do
should contain_ini_setting(setting).with({
:ensure => 'present',
:setting => setting,
:value => 'true',
:path => '/etc/puppetlabs/puppet/puppet.conf',
:section => 'main',
:require => 'File[puppet_config]',
})
end
end
end
end
describe 'with server specified' do
let(:params) { { :server => 'foo' } }
it do
should contain_ini_setting('server').with({
:ensure => 'present',
:setting => 'server',
:value => 'foo',
:path => '/etc/puppetlabs/puppet/puppet.conf',
:section => 'main',
:require => 'File[puppet_config]',
})
end
end
describe 'parameter type and content validations' do
validations = {
'absolute paths' => {
:name => %w(config_path agent_sysconfig_path),
:valid => ['/absolute/path'],
:invalid => ['not/an/absolute/path'],
:message => 'is not an absolute path',
},
'booleans' => {
:name => %w(run_every_thirty run_in_noop run_at_boot graph archive_files),
:valid => [true, 'true', false, 'false'],
:invalid => ['string', %w(array), { 'ha' => 'sh' }, 3, 2.42],
:message => 'Error while evaluating a Resource Statement',
},
'strings' => {
:name => %w(certname cron_command server ca_server archive_file_server),
:valid => ['string'],
:invalid => [true, %w(array), { 'ha' => 'sh' }, 3, 2.42],
:message => 'Error while evaluating a Resource Statement',
},
}
validations.sort.each do |type, var|
var[:name].each do |var_name|
var[:params] = {} if var[:params].nil?
var[:valid].each do |valid|
context "when #{var_name} (#{type}) is set to valid #{valid} (as #{valid.class})" do
let(:params) { [var[:params], { :"#{var_name}" => valid, }].reduce(:merge) }
it { should compile }
end
end
var[:invalid].each do |invalid|
context "when #{var_name} (#{type}) is set to invalid #{invalid} (as #{invalid.class})" do
let(:params) { [var[:params], { :"#{var_name}" => invalid, }].reduce(:merge) }
it 'should fail' do
expect { should contain_class(subject) }.to raise_error(Puppet::Error, /#{var[:message]}/)
end
end
end
end # var[:name].each
end # validations.sort.each
end # describe 'parameter type content validations'
end
diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb
index c83c4de..5f06b1e 100644
--- a/spec/classes/server_spec.rb
+++ b/spec/classes/server_spec.rb
@@ -1,223 +1,223 @@
require 'spec_helper'
describe 'puppet::server' do
# Filter out duplicate platforms
platforms = on_supported_os.select { |k, _v| !k.to_s.match(/^(RedHat|Scientific|OracleLinux)/i) }
platforms.each do |os, facts|
context "on #{os} with default values for parameters" do
let(:facts) do
facts
end
it { is_expected.to compile.with_all_deps }
it { should contain_class('puppet') }
it { should contain_class('puppet::server') }
non_conditional_ini_settings = {
'vardir' => '/opt/puppetlabs/server/data/puppetserver',
'logdir' => '/var/log/puppetlabs/puppetserver',
'rundir' => '/var/run/puppetlabs/puppetserver',
'pidfile' => '/var/run/puppetlabs/puppetserver/puppetserver.pid',
'codedir' => '/etc/puppetlabs/code',
'ca' => false,
}
non_conditional_ini_settings.each do |setting, value|
it do
should contain_ini_setting(setting).with({
:ensure => 'present',
:setting => setting,
:value => value,
:path => '/etc/puppetlabs/puppet/puppet.conf',
:section => 'master',
:require => 'File[puppet_config]',
:notify => 'Service[puppetserver]',
})
end
end
%w(node_terminus external_nodes dns_alt_names).each do |setting|
it { should_not contain_ini_setting(setting) }
end
empty_autosign_content = <<-END.gsub(/^\s+\|/, '')
|# This file is being maintained by Puppet.
|# DO NOT EDIT
END
it do
should contain_file('autosign_config').with({
:ensure => 'file',
:path => '/etc/puppetlabs/puppet/autosign.conf',
:content => empty_autosign_content,
:owner => 'root',
:group => 'root',
:mode => '0644',
:notify => 'Service[puppetserver]',
})
end
puppetserver_sysconfig = File.read(fixtures('puppetserver_sysconfig'))
it do
should contain_file('puppetserver_sysconfig').with({
:ensure => 'file',
:path => '/etc/sysconfig/puppetserver',
:content => puppetserver_sysconfig,
:owner => 'root',
:group => 'root',
:mode => '0644',
})
end
it do
should contain_service('puppetserver').with({
:ensure => 'running',
:enable => true,
:subscribe => [
'File[puppet_config]',
'File[puppetserver_sysconfig]',
],
})
end
end
end
describe 'with ca' do
[true, 'true', false, 'false'].each do |value|
context "set to #{value} (as #{value.class})" do
let(:params) { { :ca => value } }
it do
should contain_ini_setting('ca').with({
:ensure => 'present',
:setting => 'ca',
:value => value,
:path => '/etc/puppetlabs/puppet/puppet.conf',
:section => 'master',
:require => 'File[puppet_config]',
:notify => 'Service[puppetserver]',
})
end
end
end
end
describe 'with enc' do
context 'set to a valid path' do
let(:params) { { :enc => '/path/to/enc' } }
it do
should contain_ini_setting('external_nodes').with({
:ensure => 'present',
:setting => 'external_nodes',
:value => '/path/to/enc',
:path => '/etc/puppetlabs/puppet/puppet.conf',
:section => 'master',
:require => 'File[puppet_config]',
:notify => 'Service[puppetserver]',
})
end
it do
should contain_ini_setting('node_terminus').with({
:ensure => 'present',
:setting => 'node_terminus',
:value => 'exec',
:path => '/etc/puppetlabs/puppet/puppet.conf',
:section => 'master',
:require => 'File[puppet_config]',
:notify => 'Service[puppetserver]',
})
end
end
end
describe 'with dns_alt_names' do
context 'set to a valid path' do
let(:params) { { :dns_alt_names => 'foo,foo1,foo1.example.com,foo.example.com' } }
it do
should contain_ini_setting('dns_alt_names').with({
:ensure => 'present',
:setting => 'dns_alt_names',
:value => 'foo,foo1,foo1.example.com,foo.example.com',
:path => '/etc/puppetlabs/puppet/puppet.conf',
:section => 'master',
:require => 'File[puppet_config]',
:notify => 'Service[puppetserver]',
})
end
end
end
describe 'with autosign_entries' do
context 'set to a valid array of strings' do
let(:params) { { :autosign_entries => ['*.example.org', '*.dev.example.org'] } }
autosign_conf_content = <<-END.gsub(/^\s+\|/, '')
|# This file is being maintained by Puppet.
|# DO NOT EDIT
|*.example.org
|*.dev.example.org
END
it { should contain_file('autosign_config').with_content(autosign_conf_content) }
end
end
describe 'parameter type and content validations' do
validations = {
'absolute paths' => {
:name => %w(sysconfig_path enc),
:valid => ['/absolute/path'],
:invalid => ['not/an/absolute/path'],
:message => 'is not an absolute path',
},
'booleans' => {
:name => %w(ca),
:valid => [true, 'true', false, 'false'],
:invalid => ['string', %w(array), { 'ha' => 'sh' }, 3, 2.42],
:message => 'Error while evaluating a Resource Statement',
},
'strings' => {
:name => %w(dns_alt_names),
:valid => ['string'],
:invalid => [true, %w(array), { 'ha' => 'sh' }, 3, 2.42],
:message => 'Error while evaluating a Resource Statement',
},
'non-empty array of strings' => {
:name => %w(autosign_entries),
:valid => [['array with one string'], %w(array with many strings)],
- :invalid => [%w(), [1,'not_all','string'], true, 'string', { 'ha' => 'sh' }, 3, 2.42],
+ :invalid => [%w(), [1, 'not_all', 'string'], true, 'string', { 'ha' => 'sh' }, 3, 2.42],
:message => 'Error while evaluating a Resource Statement',
},
'memory size regex' => {
:name => %w(memory_size),
- :valid => ['1g', '1m', '1500m', '3g'],
+ :valid => %w(1g 1m 1500m 3g),
:invalid => ['1g1', 'm', '1k', '2t', 'g3', '1.2g'],
:message => 'must be an integer following by the unit',
},
}
validations.sort.each do |type, var|
var[:name].each do |var_name|
var[:params] = {} if var[:params].nil?
var[:valid].each do |valid|
context "when #{var_name} (#{type}) is set to valid #{valid} (as #{valid.class})" do
let(:params) { [var[:params], { :"#{var_name}" => valid, }].reduce(:merge) }
it { should compile }
end
end
var[:invalid].each do |invalid|
context "when #{var_name} (#{type}) is set to invalid #{invalid} (as #{invalid.class})" do
let(:params) { [var[:params], { :"#{var_name}" => invalid, }].reduce(:merge) }
it 'should fail' do
expect { should contain_class(subject) }.to raise_error(Puppet::Error, /#{var[:message]}/)
end
end
end
end # var[:name].each
end # validations.sort.each
end # describe 'parameter type content validations'
end
|
ghoneycutt/puppet-module-puppet
|
ae04fd4e721f79c2fee6d85b1915c379963494c7
|
Add rake task for github_changelog_generator
|
diff --git a/Gemfile b/Gemfile
index ef68bb0..9df5471 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,30 +1,35 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
gem 'metadata-json-lint', :require => false
gem 'rspec-puppet', :require => false
gem 'rspec-puppet-facts', :require => false
gem 'rubocop', :require => false
gem 'puppetlabs_spec_helper', '>= 1.2.0', :require => false
gem 'facter', '>= 2.0', :require => false
gem 'hiera', '~> 3.0', :require => false
gem 'puppet-lint', '~> 2.0', :require => false
gem 'puppet-lint-absolute_classname-check', :require => false
gem 'puppet-lint-alias-check', :require => false
gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false
gem 'puppet-lint-empty_string-check', :require => false
gem 'puppet-lint-file_ensure-check', :require => false
gem 'puppet-lint-file_source_rights-check', :require => false
gem 'puppet-lint-leading_zero-check', :require => false
gem 'puppet-lint-resource_reference_syntax', :require => false
gem 'puppet-lint-spaceship_operator_without_tag-check', :require => false
gem 'puppet-lint-trailing_comma-check', :require => false
gem 'puppet-lint-undef_in_function-check', :require => false
gem 'puppet-lint-unquoted_string-check', :require => false
gem 'puppet-lint-variable_contains_upcase', :require => false
gem 'puppet-lint-version_comparison-check', :require => false
+
+# Rack if a dependency of github_changelog_generator
+gem 'github_changelog_generator', require: false
+gem 'rack', '~> 1.0', :require => false if RUBY_VERSION <= '2.2.2'
+gem 'rack', :require => false if RUBY_VERSION > '2.2.2'
diff --git a/Rakefile b/Rakefile
index e2cf8b8..86f084f 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,23 +1,31 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'rubocop/rake_task'
+require 'github_changelog_generator/task'
+
+GitHubChangelogGenerator::RakeTask.new :changelog do |config|
+ config.user = 'ghoneycutt'
+ config.project = 'puppet-module-puppet'
+ config.issues = false
+ config.token = ENV['GITHUB_CHANGELOG_TOKEN']
+end
RuboCop::RakeTask.new
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_140chars')
PuppetLint.configuration.relative = true
PuppetLint.configuration.ignore_paths = ['spec/**/*.pp', 'pkg/**/*.pp']
desc 'Validate manifests, templates, and ruby files'
task :validate do
Dir['manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}"
end
Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file|
sh "ruby -c #{ruby_file}" unless ruby_file =~ %r{spec/fixtures}
end
Dir['templates/**/*.erb'].each do |template|
sh "erb -P -x -T '-' #{template} | ruby -c"
end
end
|
ghoneycutt/puppet-module-puppet
|
5ccd80f0f2034d1212adb0eea2abea0c73e3b0b5
|
Simplify CI test
|
diff --git a/.travis.yml b/.travis.yml
index 5c6dafd..38a3a54 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,22 +1,22 @@
---
language: ruby
rvm:
- 2.1.9
- 2.3.1
env:
matrix:
- PUPPET_GEM_VERSION="~> 4.7.0"
- PUPPET_GEM_VERSION="~> 4.8.0"
- PUPPET_GEM_VERSION="~> 4"
sudo: false
-script: 'bundle exec rake validate && bundle exec rake lint && SPEC_OPTS="--format documentation" bundle exec rake spec'
+script: 'SPEC_OPTS="--format documentation" bundle exec rake validate lint spec'
matrix:
fast_finish: true
notifications:
email: false
|
ghoneycutt/puppet-module-puppet
|
e3bcf439da1fc34c6f703eee825b4a8eee5e570a
|
Support Puppet v4.8.0
|
diff --git a/.travis.yml b/.travis.yml
index d12664e..5c6dafd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,21 +1,22 @@
---
language: ruby
rvm:
- 2.1.9
- 2.3.1
env:
matrix:
- PUPPET_GEM_VERSION="~> 4.7.0"
+ - PUPPET_GEM_VERSION="~> 4.8.0"
- PUPPET_GEM_VERSION="~> 4"
sudo: false
script: 'bundle exec rake validate && bundle exec rake lint && SPEC_OPTS="--format documentation" bundle exec rake spec'
matrix:
fast_finish: true
notifications:
email: false
|
ghoneycutt/puppet-module-puppet
|
d88b13f3d13bc9f844d65ce909c9add4ac9f87dc
|
Add CHANGELOG.md
|
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..e94bcf7
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,284 @@
+# Change Log
+
+## [v2.19.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.19.0) (2016-07-13)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.18.1...v2.19.0)
+
+**Merged pull requests:**
+
+- Puppetv4 agent [\#119](https://github.com/ghoneycutt/puppet-module-puppet/pull/119) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.18.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.18.1) (2016-07-12)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.18.0...v2.18.1)
+
+**Merged pull requests:**
+
+- Fix testing [\#120](https://github.com/ghoneycutt/puppet-module-puppet/pull/120) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.18.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.18.0) (2016-04-29)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.17.1...v2.18.0)
+
+**Merged pull requests:**
+
+- Dont recursively cleanup master maintenance [\#118](https://github.com/ghoneycutt/puppet-module-puppet/pull/118) ([ghoneycutt](https://github.com/ghoneycutt))
+- Allow configuration of the number of max requests handled per puppet ⦠[\#114](https://github.com/ghoneycutt/puppet-module-puppet/pull/114) ([dfairhurst](https://github.com/dfairhurst))
+
+## [v2.17.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.17.1) (2016-04-28)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.17.0...v2.17.1)
+
+**Merged pull requests:**
+
+- Modernize [\#117](https://github.com/ghoneycutt/puppet-module-puppet/pull/117) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.17.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.17.0) (2015-11-25)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.16.0...v2.17.0)
+
+**Merged pull requests:**
+
+- parameterize ssldir in puppet agent's config [\#113](https://github.com/ghoneycutt/puppet-module-puppet/pull/113) ([Phil-Friderici](https://github.com/Phil-Friderici))
+- Fixup metadata [\#112](https://github.com/ghoneycutt/puppet-module-puppet/pull/112) ([ghoneycutt](https://github.com/ghoneycutt))
+- Changed outdated type-function to is\_\<type\> [\#111](https://github.com/ghoneycutt/puppet-module-puppet/pull/111) ([Phil-Friderici](https://github.com/Phil-Friderici))
+
+## [v2.16.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.16.0) (2015-08-18)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.15.0...v2.16.0)
+
+**Merged pull requests:**
+
+- make hardcoded commands really flexible [\#102](https://github.com/ghoneycutt/puppet-module-puppet/pull/102) ([Phil-Friderici](https://github.com/Phil-Friderici))
+
+## [v2.15.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.15.0) (2015-02-20)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/2.14.4...v2.15.0)
+
+**Merged pull requests:**
+
+- Disable master maintenance cronjobs [\#99](https://github.com/ghoneycutt/puppet-module-puppet/pull/99) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [2.14.4](https://github.com/ghoneycutt/puppet-module-puppet/tree/2.14.4) (2015-02-20)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.14.3...2.14.4)
+
+**Merged pull requests:**
+
+- Support Ruby v2.1.0 [\#98](https://github.com/ghoneycutt/puppet-module-puppet/pull/98) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.14.3](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.14.3) (2015-02-13)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.14.2...v2.14.3)
+
+**Merged pull requests:**
+
+- Improve spec tests for maintenance class [\#96](https://github.com/ghoneycutt/puppet-module-puppet/pull/96) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.14.2](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.14.2) (2014-12-20)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.14.1...v2.14.2)
+
+**Merged pull requests:**
+
+- Travis-ci use containers for faster builds [\#94](https://github.com/ghoneycutt/puppet-module-puppet/pull/94) ([ghoneycutt](https://github.com/ghoneycutt))
+- Support run\_interval larger than 30 [\#93](https://github.com/ghoneycutt/puppet-module-puppet/pull/93) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.14.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.14.1) (2014-12-10)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.14.0...v2.14.1)
+
+**Merged pull requests:**
+
+- Follow symlink for reportdir [\#91](https://github.com/ghoneycutt/puppet-module-puppet/pull/91) ([emahags](https://github.com/emahags))
+
+## [v2.14.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.14.0) (2014-11-25)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.13.1...v2.14.0)
+
+**Merged pull requests:**
+
+- Style - Fix indentation of attribute arrows [\#90](https://github.com/ghoneycutt/puppet-module-puppet/pull/90) ([ghoneycutt](https://github.com/ghoneycutt))
+- Manage mysql options [\#89](https://github.com/ghoneycutt/puppet-module-puppet/pull/89) ([ghoneycutt](https://github.com/ghoneycutt))
+- Fix linebreaks puppetconf [\#86](https://github.com/ghoneycutt/puppet-module-puppet/pull/86) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.13.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.13.1) (2014-10-15)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.13.0...v2.13.1)
+
+**Merged pull requests:**
+
+- Disable SSLv3 as it is insecure [\#84](https://github.com/ghoneycutt/puppet-module-puppet/pull/84) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.13.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.13.0) (2014-10-09)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.12.0...v2.13.0)
+
+**Merged pull requests:**
+
+- Add parameters for http\_proxy and http\_proxy\_port [\#80](https://github.com/ghoneycutt/puppet-module-puppet/pull/80) ([kytomaki](https://github.com/kytomaki))
+
+## [v2.12.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.12.0) (2014-10-06)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.11.3...v2.12.0)
+
+**Merged pull requests:**
+
+- Add support for etckeeper [\#83](https://github.com/ghoneycutt/puppet-module-puppet/pull/83) ([ghoneycutt](https://github.com/ghoneycutt))
+- Add masterport to agent config [\#82](https://github.com/ghoneycutt/puppet-module-puppet/pull/82) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.11.3](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.11.3) (2014-10-01)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.11.2...v2.11.3)
+
+**Merged pull requests:**
+
+- V370 [\#77](https://github.com/ghoneycutt/puppet-module-puppet/pull/77) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.11.2](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.11.2) (2014-09-05)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.11.1...v2.11.2)
+
+**Merged pull requests:**
+
+- Metadata [\#76](https://github.com/ghoneycutt/puppet-module-puppet/pull/76) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.11.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.11.1) (2014-06-10)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.11.0...v2.11.1)
+
+**Merged pull requests:**
+
+- Add dependency of ghoneycutt/common to metadata [\#69](https://github.com/ghoneycutt/puppet-module-puppet/pull/69) ([ghoneycutt](https://github.com/ghoneycutt))
+- replaced dead links for dashboard [\#68](https://github.com/ghoneycutt/puppet-module-puppet/pull/68) ([aviau](https://github.com/aviau))
+
+## [v2.11.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.11.0) (2014-06-03)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.10.0...v2.11.0)
+
+**Merged pull requests:**
+
+- Stringify facts [\#65](https://github.com/ghoneycutt/puppet-module-puppet/pull/65) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.10.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.10.0) (2014-06-01)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.9.3...v2.10.0)
+
+**Merged pull requests:**
+
+- Add environment fact [\#64](https://github.com/ghoneycutt/puppet-module-puppet/pull/64) ([emahags](https://github.com/emahags))
+- Specify version of apache to use in fixtures [\#61](https://github.com/ghoneycutt/puppet-module-puppet/pull/61) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.9.3](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.9.3) (2014-01-31)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.9.2...v2.9.3)
+
+**Merged pull requests:**
+
+- Support Puppet v3.4 and Ruby v2.0.0 [\#57](https://github.com/ghoneycutt/puppet-module-puppet/pull/57) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.9.2](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.9.2) (2014-01-23)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.9.1...v2.9.2)
+
+**Merged pull requests:**
+
+- Remove Travis work around for ruby v1.8.7 [\#56](https://github.com/ghoneycutt/puppet-module-puppet/pull/56) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.9.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.9.1) (2014-01-21)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.9.0...v2.9.1)
+
+**Merged pull requests:**
+
+- Refactor to allow booleans in parameters. [\#55](https://github.com/ghoneycutt/puppet-module-puppet/pull/55) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.9.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.9.0) (2014-01-10)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.8.0...v2.9.0)
+
+**Merged pull requests:**
+
+- Add ability to to clean up the reports directory [\#54](https://github.com/ghoneycutt/puppet-module-puppet/pull/54) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.8.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.8.0) (2014-01-03)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.7.0...v2.8.0)
+
+**Merged pull requests:**
+
+- Set run method to disable [\#53](https://github.com/ghoneycutt/puppet-module-puppet/pull/53) ([ghoneycutt](https://github.com/ghoneycutt))
+- Support rspec-puppet v1.0.0 [\#51](https://github.com/ghoneycutt/puppet-module-puppet/pull/51) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.7.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.7.0) (2013-12-06)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.6.1...v2.7.0)
+
+**Merged pull requests:**
+
+- Support Suse 11 [\#49](https://github.com/ghoneycutt/puppet-module-puppet/pull/49) ([ghoneycutt](https://github.com/ghoneycutt))
+- Improve spec testing [\#48](https://github.com/ghoneycutt/puppet-module-puppet/pull/48) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.6.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.6.1) (2013-11-11)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.5.3...v2.6.1)
+
+**Merged pull requests:**
+
+- Release v2.6.0 - Debian Support [\#39](https://github.com/ghoneycutt/puppet-module-puppet/pull/39) ([ghoneycutt](https://github.com/ghoneycutt))
+- Only define Cron\['puppet\_agent\_once\_at\_boot'\] if $run\_method == 'cron' [\#37](https://github.com/ghoneycutt/puppet-module-puppet/pull/37) ([tekenny](https://github.com/tekenny))
+
+## [v2.5.3](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.5.3) (2013-11-10)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.5.2...v2.5.3)
+
+**Merged pull requests:**
+
+- Fix bug with running puppet::master on Debian [\#38](https://github.com/ghoneycutt/puppet-module-puppet/pull/38) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.5.2](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.5.2) (2013-11-08)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.5.1...v2.5.2)
+
+## [v2.5.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.5.1) (2013-11-08)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.5.0...v2.5.1)
+
+**Merged pull requests:**
+
+- Update mysql [\#36](https://github.com/ghoneycutt/puppet-module-puppet/pull/36) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.5.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.5.0) (2013-11-08)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.4.0...v2.5.0)
+
+**Merged pull requests:**
+
+- Add Support for Solaris to puppet::agent [\#35](https://github.com/ghoneycutt/puppet-module-puppet/pull/35) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.4.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.4.0) (2013-11-08)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.3.0...v2.4.0)
+
+**Merged pull requests:**
+
+- Cleanup dashboard reports [\#32](https://github.com/ghoneycutt/puppet-module-puppet/pull/32) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.3.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.3.0) (2013-11-08)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.2.0...v2.3.0)
+
+**Merged pull requests:**
+
+- Symlink merge [\#34](https://github.com/ghoneycutt/puppet-module-puppet/pull/34) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.2.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.2.0) (2013-11-08)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.1.3...v2.2.0)
+
+**Merged pull requests:**
+
+- Refactor spec tests [\#31](https://github.com/ghoneycutt/puppet-module-puppet/pull/31) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.1.3](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.1.3) (2013-09-29)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.1.2...v2.1.3)
+
+## [v2.1.2](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.1.2) (2013-09-27)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.1.1...v2.1.2)
+
+**Merged pull requests:**
+
+- Update travis to test syntax validation and lint. [\#24](https://github.com/ghoneycutt/puppet-module-puppet/pull/24) ([ghoneycutt](https://github.com/ghoneycutt))
+- Secure dashboard [\#22](https://github.com/ghoneycutt/puppet-module-puppet/pull/22) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.1.1](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.1.1) (2013-09-22)
+[Full Changelog](https://github.com/ghoneycutt/puppet-module-puppet/compare/v2.1.0...v2.1.1)
+
+**Merged pull requests:**
+
+- Note needed sudoers entry in README for cron jobs [\#21](https://github.com/ghoneycutt/puppet-module-puppet/pull/21) ([ghoneycutt](https://github.com/ghoneycutt))
+- Fix dump\_dashboard\_database and redirect output [\#19](https://github.com/ghoneycutt/puppet-module-puppet/pull/19) ([kentjohansson](https://github.com/kentjohansson))
+- Show status of Travis-ci in README [\#16](https://github.com/ghoneycutt/puppet-module-puppet/pull/16) ([ghoneycutt](https://github.com/ghoneycutt))
+- Differentiate between Dashboard server and not. [\#15](https://github.com/ghoneycutt/puppet-module-puppet/pull/15) ([ghoneycutt](https://github.com/ghoneycutt))
+
+## [v2.1.0](https://github.com/ghoneycutt/puppet-module-puppet/tree/v2.1.0) (2013-06-14)
+**Merged pull requests:**
+
+- Add option to use htpasswd for Dashboard. [\#14](https://github.com/ghoneycutt/puppet-module-puppet/pull/14) ([ghoneycutt](https://github.com/ghoneycutt))
+- Spec tests [\#13](https://github.com/ghoneycutt/puppet-module-puppet/pull/13) ([kividiot](https://github.com/kividiot))
+- Update of documentation [\#12](https://github.com/ghoneycutt/puppet-module-puppet/pull/12) ([kividiot](https://github.com/kividiot))
+- Add documentation [\#8](https://github.com/ghoneycutt/puppet-module-puppet/pull/8) ([ghoneycutt](https://github.com/ghoneycutt))
+- Ensure puppetmaster service is not started at boot time [\#7](https://github.com/ghoneycutt/puppet-module-puppet/pull/7) ([ghoneycutt](https://github.com/ghoneycutt))
+- Removed stopping of puppetmaster [\#6](https://github.com/ghoneycutt/puppet-module-puppet/pull/6) ([MWinther](https://github.com/MWinther))
+- Basic documentation [\#5](https://github.com/ghoneycutt/puppet-module-puppet/pull/5) ([MWinther](https://github.com/MWinther))
+- Rebirth [\#2](https://github.com/ghoneycutt/puppet-module-puppet/pull/2) ([ghoneycutt](https://github.com/ghoneycutt))
+
+
+
+\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\ No newline at end of file
|
ghoneycutt/puppet-module-puppet
|
c3f6d706d9279ed6f6ca405554f251e307b5b8b1
|
Release v3.0.0 - Transition to Puppet v4
|
diff --git a/.fixtures.yml b/.fixtures.yml
index 1226caf..80fa4f2 100644
--- a/.fixtures.yml
+++ b/.fixtures.yml
@@ -1,27 +1,10 @@
fixtures:
repositories:
- firewall:
- repo: 'https://github.com/puppetlabs/puppetlabs-firewall.git'
- ref: '1.7.1'
+ inifile:
+ repo: 'https://github.com/puppetlabs/puppetlabs-inifile.git'
+ ref: '1.6.0'
stdlib:
repo: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
ref: '4.6.0'
- mysql:
- repo: 'https://github.com/puppetlabs/puppetlabs-mysql.git'
- ref: '2.0.1-rc1'
- passenger:
- repo: 'https://github.com/puppetlabs/puppetlabs-passenger.git'
- ref: '0.4.1'
- apache:
- repo: 'https://github.com/puppetlabs/puppetlabs-apache.git'
- ref: '0.5.0-rc1'
- concat:
- repo: 'https://github.com/puppetlabs/puppetlabs-concat.git'
- ref: '1.2.5'
- common:
- repo: 'https://github.com/ghoneycutt/puppet-module-common.git'
- ref: 'v1.6.0'
- htpasswd:
- repo: 'https://github.com/leinaddm/puppet-htpasswd.git'
symlinks:
puppet: "#{source_dir}"
diff --git a/.rubocop.yml b/.rubocop.yml
new file mode 100644
index 0000000..a1b2204
--- /dev/null
+++ b/.rubocop.yml
@@ -0,0 +1,42 @@
+---
+AllCops:
+ DisplayCopNames: true
+ DisplayStyleGuide: true
+ Exclude:
+ - vendor/**/*
+ - pkg/**/*
+ - spec/fixtures/**/*
+
+# Cop's to ignore
+
+# With this enabled it suggests a change that will break the Gemfile
+Lint/AssignmentInCondition:
+ Enabled: false
+
+Metrics/LineLength:
+ Enabled: false
+
+# This is a good idea, but does not line up the rest of the lines making it
+# harder to read
+Style/IndentHash:
+ Enabled: false
+
+Style/Next:
+ Enabled: false
+
+# If enabled, this cop makes it harder to understand the logic
+Style/NonNilCheck:
+ Enabled: false
+
+Style/TrailingCommaInLiteral:
+ Enabled: false
+
+Style/TrailingCommaInArguments:
+ Enabled: false
+
+# Cop's that require ruby >= 1.9
+Style/HashSyntax:
+ Enabled: false
+
+Style/BracesAroundHashParameters:
+ Enabled: false
diff --git a/.travis.yml b/.travis.yml
index d7d70a2..d12664e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,41 +1,21 @@
---
language: ruby
rvm:
- - 1.8.7
- - 1.9.3
- - 2.0.0
- - 2.1.0
+ - 2.1.9
+ - 2.3.1
env:
matrix:
- - PUPPET_GEM_VERSION="~> 3.1.0"
- - PUPPET_GEM_VERSION="~> 3.2.0"
- - PUPPET_GEM_VERSION="~> 3.3.0"
- - PUPPET_GEM_VERSION="~> 3.4.0"
- - PUPPET_GEM_VERSION="~> 3.5.1"
- - PUPPET_GEM_VERSION="~> 3.6.0"
- - PUPPET_GEM_VERSION="~> 3.7.0"
- - PUPPET_GEM_VERSION="~> 3.8.0"
- - PUPPET_GEM_VERSION="~> 3"
+ - PUPPET_GEM_VERSION="~> 4.7.0"
+ - PUPPET_GEM_VERSION="~> 4"
sudo: false
script: 'bundle exec rake validate && bundle exec rake lint && SPEC_OPTS="--format documentation" bundle exec rake spec'
matrix:
fast_finish: true
- exclude:
- - rvm: 2.0.0
- env: PUPPET_GEM_VERSION="~> 3.1.0"
- - rvm: 2.1.0
- env: PUPPET_GEM_VERSION="~> 3.1.0"
- - rvm: 2.1.0
- env: PUPPET_GEM_VERSION="~> 3.2.0"
- - rvm: 2.1.0
- env: PUPPET_GEM_VERSION="~> 3.3.0"
- - rvm: 2.1.0
- env: PUPPET_GEM_VERSION="~> 3.4.0"
notifications:
email: false
diff --git a/Gemfile b/Gemfile
index eea8e8e..ef68bb0 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,33 +1,30 @@
-source 'https://rubygems.org'
+source ENV['GEM_SOURCE'] || 'https://rubygems.org'
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
-gem 'metadata-json-lint'
-gem 'puppetlabs_spec_helper', '>= 1.1.1'
-gem 'facter', '>= 1.7.0'
-gem 'puppet-lint', '>= 1.0', '< 3.0'
-gem 'puppet-lint-absolute_classname-check'
-gem 'puppet-lint-alias-check'
-gem 'puppet-lint-empty_string-check'
-gem 'puppet-lint-file_ensure-check'
-gem 'puppet-lint-file_source_rights-check'
-gem 'puppet-lint-leading_zero-check'
-gem 'puppet-lint-spaceship_operator_without_tag-check'
-gem 'puppet-lint-trailing_comma-check'
-gem 'puppet-lint-undef_in_function-check'
-gem 'puppet-lint-unquoted_string-check'
-gem 'puppet-lint-variable_contains_upcase'
-
-# rspec must be v2 for ruby 1.8.7
-if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
- gem 'rspec', '~> 2.0'
- gem 'rake', '~> 10.0'
-end
-
-if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '2.0'
- gem 'json', '~> 1.0'
-end
+gem 'metadata-json-lint', :require => false
+gem 'rspec-puppet', :require => false
+gem 'rspec-puppet-facts', :require => false
+gem 'rubocop', :require => false
+gem 'puppetlabs_spec_helper', '>= 1.2.0', :require => false
+gem 'facter', '>= 2.0', :require => false
+gem 'hiera', '~> 3.0', :require => false
+gem 'puppet-lint', '~> 2.0', :require => false
+gem 'puppet-lint-absolute_classname-check', :require => false
+gem 'puppet-lint-alias-check', :require => false
+gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false
+gem 'puppet-lint-empty_string-check', :require => false
+gem 'puppet-lint-file_ensure-check', :require => false
+gem 'puppet-lint-file_source_rights-check', :require => false
+gem 'puppet-lint-leading_zero-check', :require => false
+gem 'puppet-lint-resource_reference_syntax', :require => false
+gem 'puppet-lint-spaceship_operator_without_tag-check', :require => false
+gem 'puppet-lint-trailing_comma-check', :require => false
+gem 'puppet-lint-undef_in_function-check', :require => false
+gem 'puppet-lint-unquoted_string-check', :require => false
+gem 'puppet-lint-variable_contains_upcase', :require => false
+gem 'puppet-lint-version_comparison-check', :require => false
diff --git a/README.md b/README.md
index 577b0aa..64bf742 100644
--- a/README.md
+++ b/README.md
@@ -1,773 +1,198 @@
-# puppet-module-puppet #
-===
-
-[](https://travis-ci.org/ghoneycutt/puppet-module-puppet)
-
-This module handles the various parts of puppet on a given machine.
-
-Dependencies for this module are: apache, common, mysql and passenger
-
-This module is targeted at Puppet v3. It does support the agent on Puppet v4.
-To use the agent, simply `include ::puppet::agent`.
-
-## Components ##
-
-### Agent
----------
-- Manages the puppet agent on a client
-- Setup of configuration files
-- Setup of service or crontask to run the agent periodically
-- Ensure puppet agent is run at boottime
-
-### Master
-----------
-- Manages apache with passenger
-- Setup of config files needed to run master
-- Calls the `puppet::lint` class
-- Calls the `puppet::master::maintenance` class
-- Manages firewall rule for puppet if needed
-- Maintenance to purge filebucket and reports
-
-### Dashboard
--------------
-- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
-- This installation is used by puppet systems, that need access to the dashboard
-
-### Dashboard Server
---------------------
-- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
-- This is the actual server running the Dashboard
-- Configures the Dashboard MySQL settings
-- Creates database for puppet with mysql module
-- Calls the `puppet::dashboard::maintenance` class
-- Maintenance to clean up old reports, optimize database and dump database
-- For the maintenance cron jobs, you should have the following line in your `/etc/sudoers` which is not managed with this module.
-<pre>
-Defaults:root !requiretty
-</pre>
-
-### Lint
---------
-- Manages [puppet-lint](http://github.com/rodjek/puppet-lint)
-
-
-## Compatibility ##
--------------------
-Ruby versions 1.8.7, 1.9.3, 2.0.0 and 2.1.0 on Puppet v3.
-
-### Puppet Master
------------------
-* Debian 6
-* Debian 7
-* EL 6
-* Ubuntu 12.04 LTS
-
-### Puppet Agent
-----------------
-* Debian 6
-* Debian 7
-* EL 6
-* EL 7
-* Solaris
-* Suse 11
-* Ubuntu 12.04 LTS
-
-===
+# puppet-module-puppet
-## Class `puppet::agent` ##
+#### Table of Contents
-### Parameters ###
+1. [Module Description](#module-description)
+1. [Dependencies](#dependencies)
+1. [Compatibility](#compatibility)
+1. [Class Descriptions](#class-descriptions)
+ * [puppet](#class-puppet)
+ * [puppet::server](#class-puppet-server)
-certname
---------
-The certificate name for the client.
-
-- *Default*: $::fqdn
-
-config_path
------------
-The location of the puppet config file.
+# Module description
-- *Default*: /etc/puppet/puppet.conf
+[](https://travis-ci.org/ghoneycutt/puppet-module-puppet)
-config_owner
-------------
-The owner of the config file.
+This module handles the various parts of puppet including the agent and
+puppetserver. It is highly opionated and does not seek to manage the
+agent and server in all ways that they can be configured and
+implemented.
-- *Default*: root
+* The agent runs in noop by default. This is the safest way and ensures
+ that changes are known by having to specify that you want to run in
+ enforcing mode.
-config_group
-------------
-The group for the config file.
+* The agent does not run as a service. There is no good reason for
+ running the service. Instead cron should be used to better manage how
+ and when the agent runs.
-- *Default*: root
+* By default the agent will run every thirty minutes from cron and the
+ minutes will be randomized using fqdn_rand() so they are consistent
+ per host. If you would like a different schedule, this is easily
+ disabled by setting `run_every_thirty` to `false`, in which case,
+ it is suggested that the schedule by specified in your profile.
-config_mode
------------
-The mode for the config file.
-
-- *Default*: 0644
-
-env
----
-The selected environment for the client.
+* The trusted_node_data option in puppet.conf is set to true.
-- *Default*: $::env
+This module is targeted at Puppet v4. If you need support for Puppet v3,
+please see the puppetv3 branch of this module. Which supports the agent,
+master (with apache/passenger), Puppet Dashboard and puppet-lint.
-puppet_server
--------------
-The puppet server the client should connect to.
+To use the agent, use `include ::puppet`. If the system is also a
+puppetserver, use `include ::puppet::server`, which will also manage the
+agent.
-- *Default*: puppet
+It uses puppetlabs/inifile to manage the entries in puppet.conf.
-puppet_masterport
------------------
-The masterport setting in puppet.conf. By default this line is not set.
+# Dependencies
-- *Default*: UNSET
+For version ranges, please see metadata.json.
-puppet_ca_server
-----------------
-The puppet CA server the client should use
+* [puppetlabs/inifile](https://github.com/puppetlabs/puppetlabs-inifile)
+* [puppetlabs/stdlib](https://github.com/puppetlabs/puppetlabs-stdlib)
-- *Default*: UNSET
+# Compatibility
-http_proxy_host
----------------
-The http-proxy the client should use
+Puppet v4 with Ruby versions 2.1.9 and 2.3.1 with the following
+platforms. Please consult the CI testing matrix in .travis.yml for more
+info. If you are looking for Puppet v3, please see the [puppetv3
+branch](https://github.com/ghoneycutt/puppet-module-puppet/tree/puppetv3).
-- *Default*: UNSET
-
-http_proxy_port
-----------------
-The http-proxy port the client should use
-
-- *Default*: UNSET
-
-is_puppet_master
-----------------
-Whether the machine is a puppet master or not.
+* EL 6
-- *Default*: false
+===
-run_method
-----------
-Whether to run as a service or in cron mode. Valid values are `disable`, `cron`, and `service`. The value `disable` disables automatic puppet runs and assumes you are running as a service.
+# Class Descriptions
-- *Default*: service
+## Class `puppet`
-run_interval
-------------
-The interval, in minutes, with which the client should run. If greater than 30, the agent will only run once per hour.
+### Description
-- *Default*: 30
+Manages the puppet agent.
-run_in_noop
------------
-Whether the client should run in noop mode or not.
+A note on types, `Variant[Enum['true', 'false'], Boolean]` means that
+boolean `true` and `false` are supported as well as stringified `'true'`
+and `'false'`.
-- *Default*: false
+### Parameters
-cron_command
-------------
-The command that should be added to the crontab (in cron mode)
+---
+#### certname (type: String)
+The certificate name for the client.
-- *Default*: /usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay
+- *Default*: $::fqdn
-run_at_boot
------------
-Whether the client should run right after boot
+---
+#### run_every_thirty (type: Variant[Enum['true', 'false'], Boolean])
+Determines if a cron job to run the puppet agent every thirty minutes
+should be present.
- *Default*: true
-puppet_binary
--------------
-Path to puppet binary to create symlink from
-
-- *Default*: '/usr/bin/puppet'
-
-symlink_puppet_binary_target
-----------------------------
-Path to where the symlink should be created
-
-- *Default*: '/usr/local/bin/puppet'
-
-symlink_puppet_binary
----------------------
-Boolean for ensuring a symlink for puppet_binary to symlink_puppet_binary_target. This is useful if you install puppet in a non-standard location that is not in your $PATH.
-
-- *Default*: false
-
-agent_sysconfig
----------------
-The location of puppet agent sysconfig file.
-
-- *Default*: use defaults based on osfamily
-
-agent_sysconfig_ensure
-----------------------
-String for 'file' or 'present'. Allows you to not manage the sysconfig file.
-
-- *Default*: use defaults based on osfamily
-
-daemon_name
------------
-The name the puppet agent daemon should run as.
-
-- *Default*: puppet
-
-ssldir
-------
-String with absolute path for ssldir in puppet agent's config. Using the default will set it to: '$vardir/ssl'
-
-- *Default*: 'USE_DEFAULTS'
-
-stringify_facts
----------------
-Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
+---
+#### run_in_noop (type: Variant[Enum['true', 'false'], Boolean])
+Determines if the puppet agent should run in noop mode. This is done by
+appending '--noop' to the `cron_command` parameter.
- *Default*: true
-etckeeper_hooks
----------------
-Boolean to include pre- and postrun hooks for etckeeper in the main section of the puppet agent's config.
-
-- *Default*: false
-
-===
-
-## Class `puppet::dashboard` ##
-
-### Parameters ###
-
-dashboard_package
------------------
-String or Array of the dashboard package(s) name.
-
-- *Default*: 'puppet-dashboard'
-
-dashboard_user
---------------
-The user for dashboard installation.
-
-- *Default*: use defaults based on osfamily
-
-dashboard_group
---------------
-The group for dashboard installation.
-
-- *Default*: use defaults based on osfamily
-
-sysconfig_path
--------------------
-The location of puppet dashboard sysconfig file.
-
-- *Default*: use defaults based on osfamily
-
-external_node_script_path
--------------------------
-The script to call from puppet to get manifests from dashboard.
-
-- *Default*: /usr/share/puppet-dashboard/bin/external_node
-
-dashboard_fqdn
---------------
-The dashboard server FQDN.
-
-- *Default*: puppet.${::domain}
-
-port
-----
-The port the web server will respond to.
+---
+#### cron_command (type: String)
+Command that will be run from cron for the puppet agent.
-- *Default*: 3000
+- *Default*: '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache
+ --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
-manage_mysql_options
---------------------
-Boolean to use modules default mysql::server settings (mysql_max_packet_size).
-For specific mysql::server settings you can use hiera now:
-<pre>
-puppet::dashboard::server::manage_mysql_options: false
-mysql::server::override_options:
- mysqld:
- max_allowed_packet: '32M'
- innodb_buffer_pool_size: '64M'
-</pre>
+---
+#### run_at_boot (type: Variant[Enum['true', 'false'], Boolean])
+Determine if a cron job should present that will run the puppet agent at
+boot time.
- *Default*: true
-===
-
-## Class `puppet::dashboard::server` ##
-
-### Usage ###
-You can optionally specify a hash of htpasswd entries in Hiera.
-
-<pre>
---
-puppet::dashboard::htpasswd:
- admin:
- cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
- puppet:
- cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
-</pre>
-
-### Parameters ###
-
-dashboard_workers
------------------
-Number of dashboard workers to start. Only used on osfamily Debian.
-
-- *Default*: $::processorcount
-
-database_config_path
---------------------
-The path to the database config file.
-
-- *Default*: /usr/share/puppet-dashboard/config/database.yml
-
-database_config_owner
----------------------
-The owner of the database config file.
-
-- *Default*: puppet-dashboard
-
-database_config_group
----------------------
-The database config file group.
-
-- *Default*: puppet-dashboard
-
-database_config_mode
---------------------
-The database config file mode.
-
-- *Default*: 0640
-
-htpasswd
---------
-Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
-
-- *Default*: undef
-
-htpasswd_path
--------------
-String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
-
-- *Default*: `/etc/puppet/dashboard.htpasswd`
-
-htpasswd_owner
---------------
-Owner of htpasswd file.
-
-- *Default*: root
-
-htpasswd_group
---------------
-Group of htpasswd file.
-
-- *Default*: use defaults based on osfamily
-
-htpasswd_mode
--------------
-Mode of htpasswd file.
-
-- *Default*: 0640
-
-log_dir
--------
-The location for the puppet log files.
-
-- *Default*: /var/log/puppet
-
-mysql_user
-----------
-The user for the mysql connection.
-
-- *Default*: dashboard
-
-mysql_password
---------------
-The password for the mysql connection.
-
-- *Default*: puppet
-
-mysql_max_packet_size
----------------------
-The mysql max packet size.
-
-- *Default*: 32M
-
-security
---------
-String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
-
-- *Default*: 'none'
-
-vhost_path
-----------
-The location of puppet dashboard vhost file for apache.
-
-- *Default*: use defaults based on osfamily
-
-===
-
-## Class `puppet::dashboard::maintenance` ##
-
-### Parameters ###
-
-db_optimization_command
------------------------
-The command to run to optimize the db.
-
-- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
-
-db_optimization_user
---------------------
-The user to run db optimization.
-
-- *Default*: root
+#### config_path (type: String)
+The absolute path to the puppet config file.
-db_optimization_hour
---------------------
-The hour on which to run db optimization.
+- *Default*: /etc/puppetlabs/puppet/puppet.conf
-- *Default*: 0
-
-db_optimization_minute
-----------------------
-The minute at which to run db optimization.
-
-- *Default*: 0
-
-db_optimization_monthday
-------------------------
-The day of the month on which to run db optimization.
-
-- *Default*: 1
-
-reports_days_to_keep
---------------------
-How many days to keep the reports.
-
-- *Default*: 30
-
-purge_old_reports_command
--------------------------
-Which command to run to purge old reports.
-Defaults to: '/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=${reports_days_to_keep} unit=day >> /var/log/puppet/dashboard_maintenance.log'
-If using a specific command here, please keep in mind you need to align it with $reports_days_to_keep yourself.
-
-- *Default*: 'USE_DEFAULTS'
-
-
-purge_old_reports_user
-----------------------
-User to purge reports as.
-
-- *Default*: root
-
-purge_old_reports_hour
-----------------------
-On which hour to purge old reports.
-
-- *Default*: 0
-
-purge_old_reports_minute
-------------------------
-At which minute to purge old reports.
-
-- *Default*: 30
-
-remove_old_reports_spool
-------------------------
-Whether we should remove old dashboard reports that have not been imported
-
-- *Default*: 'True'
-
-reports_spool_dir
------------------
-Path to reports in dashboard spool
-
-- *Default*: '/usr/share/puppet-dashboard/spool'
-
-reports_spool_days_to_keep
---------------------------
-How many days to keep the unimported reports.
-
-remove_reports_spool_user
--------------------------
-User to remove unimported reports.
-
-- *Default*: root
-
-remove_reports_spool_hour
--------------------------
-On which hour to remove unimported reports.
-
-- *Default*: 0
-
-remove_reports_spool_minute
----------------------------
-At which minute to remove unimported reports
-
-- *Default*: 45
-
-dump_dir
---------
-The directory to use for dumps.
-
-- *Default*: /var/local
-
-dump_database_command
----------------------
-The command to run to dump the database.
-Defaults to: 'cd ~puppet-dashboard && sudo -u ${puppet::dashboard::dashboard_user_real} /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=${dump_dir}/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 ${dump_dir}/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1'
-If using a specific command here, please keep in mind you need to align it with $puppet::dashboard::dashboard_user & $dump_dir yourself.
-
-- *Default*: 'USE_DEFAULTS'
-
-dump_database_user
-------------------
-User to dump database as.
-
-- *Default*: root
-
-dump_database_hour
-------------------
-On which hour to dump database.
-
-- *Default*: 1
-
-dump_database_minute
---------------------
-At which minute to purge old reports.
-
-- *Default*: 0
+---
+#### server (type: String)
+The name of the puppet server.
-days_to_keep_backups
---------------------
-Number of days to keep database backups.
+- *Default*: 'puppet'
-- *Default*: 7
+---
+#### ca_server (type: String)
+The name of the puppet CA server.
-purge_old_db_backups_user
--------------------------
-User to purge old database dumps as.
+- *Default*: 'puppet'
-- *Default*: root
+---
+#### graph (type: Variant[Enum['true', 'false'], Boolean])
+Value of the graph option in puppet.conf.
-purge_old_db_backups_hour
--------------------------
-On which hour to purge old database dumps.
+- *Default*: false
-- *Default*: 2
+---
+#### archive_files (type: Variant[Enum['true', 'false'], Boolean])
+Value of the archive_files option in puppet.conf.
-purge_old_db_backups_minute
----------------------------
-At which minute to purge old database dumps.
+- *Default*: false
-- *Default*: 0
+---
+#### archive_file_server (type: String)
+Value of the archive_file_server option in puppet.conf.
-===
+- *Default*: 'puppet'
-## Class `puppet::lint` ##
+---
+#### agent_sysconfig_path (type: String)
+The absolute path to the puppet agent sysconfig file.
-### Parameters ###
+- *Default*: '/etc/sysconfig/puppet'
-ensure
-------
-Whether to install lint.
+## Class `puppet::server`
-- *Default*: present
+Manages the puppetserver.
-provider
---------
-Which provider should supply lint.
+---
+#### ca (type: Variant[Enum['true', 'false'], Boolean])
+Determines if the system is a puppet CA (certificate authority). There
+should be only one CA per cluster of puppet masters.
-- *Default*: gem
+- *Default*: false
-version
--------
-If you do not want to use the default version of lint, specify which version you want to use here.
+---
+#### autosign_entries (type: Variant[Array[String, 1], Undef])
+Optional array of entries that will be autosigned.
- *Default*: undef
-lint_args
----------
-Which args should be added to the .puppet-lint.rc file
-
-- *Default*: --no-80chars-check
-
-lintrc_path
------------
-The full path to the lint config file.
-
-- *Default*: ${::root_home}/.puppet-lint.rc
-
-lintrc_owner
-------------
-The owner of the lint config file.
-
-- *Default*: root
-
-lintrc_group
-------------
-The group of the lint config file.
-
-- *Default*: root
-
-lintrc_mode
------------
-The mode of the lint config file.
-
-- *Default*: 0644
-
-===
-
-## Class `puppet::master` ##
-
-### Usage ###
-
-In Hiera you will need to specify the following.
-
-<pre>
-puppet::agent::is_puppet_master: 'true'
-</pre>
-
-### Parameters ###
-
-sysconfig_path
---------------
-The location of puppet master sysconfig file.
-
-- *Default*: use defaults based on osfamily
-
-vhost_path
-----------
-The location of puppet master vhost file for apache.
-
-- *Default*: use defaults based on osfamily
-
-rack_dir
---------
-The rack directory path.
+---
+#### sysconfig_path (type: String)
+The absolute path to the puppetserver sysconfig file.
-- *Default*: /usr/share/puppet/rack/puppetmasterd
+- *Default*: '/etc/sysconfig/puppetserver'
-puppet_user
------------
-The user the puppet master should run as.
+---
+#### memory_size (type: String /^\d+(m|g)$/)
+The amount of memory allocated to the puppetserver. This is passed to
+the Xms and Xmx arguments for java. It must be a whole number followed
+by the unit 'm' for MB or 'g' for GB.
-- *Default*: puppet
+- *Default*: '2g'
-manage_firewall
----------------
-Whether to manage the firewall settings on the client
+---
+#### enc (type: Optional[String])
+The absolute path to an ENC. If this is set, it will be the value for the
+external_nodes option in puppet.conf and the node_terminus option will
+be set to 'exec'.
- *Default*: undef
-passenger_max_requests
-----------------------
-The number of requests that each puppet master process will handle before being restarted.
-
-- *Default*: 1000
-
-===
-
-## Class `puppet::master::maintenance` ##
-
-If you have a cluster of puppet masters mounting the same data, you should
-disable these cronjobs on all systems except for one to ensure they are not all
-cleaning up the same data.
-
-```
-puppet::master::maintenance::clientbucket_cleanup_ensure: 'absent'
-puppet::master::maintenance::reportdir_purge_ensure: 'absent'
-```
-
-### Parameters ###
-
-clientbucket_cleanup_ensure
----------------------------
-String for ensure parameter for filebucket_cleanup cron job.
-
-- *Default*: 'present'
-
-clientbucket_path
------------------
-Path to where the clientbucket files are stored.
-
-- *Default*: /var/lib/puppet/clientbucket
-
-clientbucket_days_to_keep
--------------------------
-The number of days to keep clientbuckets
-
-- *Default*: 30
-
-filebucket_cleanup_command
---------------------------
-Command used to cleanup the clientbuckets.
-
-- *Default*: /usr/bin/find ${clientbucket_path} -type f -mtime +30 -exec /bin/rm -f {} \;
-
-filebucket_cleanup_user
------------------------
-User to run the clientbucket cleanup as.
-
-- *Default*: root
-
-filebucket_cleanup_hour
------------------------
-Hour on which to run the filebucket cleanup.
-
-- *Default*: 0
-
-filebucket_cleanup_minute
--------------------------
-Minute at which to run the filebucket cleanup.
-
-- *Default*: 0
-
-reportdir_purge_ensure
-----------------------
-String for ensure parameter for purge_old_puppet_reports cron job.
-
-- *Default*: 'present'
-
-reportdir
----------
-Directory that holds the reports. `$::puppet_reportdir` is a custom fact that reads the `reportdir` setting from Puppet's configuration. This is likely `/var/lib/puppet/reports/`.
-
-- *Default*: $::puppet_reportdir
-
-reportdir_days_to_key
----------------------
-String for number of days of reports to keep. Must be a positive integer > 0.
-
-- *Default*: '30'
-
-reportdir_purge_command
------------------------
-Command ran by cron to purge old reports.
-
-- *Default*: /usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -f {} \;'
-
-reportdir_purge_user
---------------------
-User for the crontab entry to run the reportdir_purge_command.
-
-- *Default*: root
-
-reportdir_purge_hour
---------------------
-Hour at which to run the reportdir_purge_command.
-
-- *Default*: 0
-
-reportdir_purge_minute
-----------------------
-Minute past the hour in which to run the reportdir_purge_command.
+---
+#### dns_alt_names (type: Optional[String])
+Value of the dns_alt_names option in puppet.conf.
-- *Default*: 15
+- *Default*: undef
diff --git a/Rakefile b/Rakefile
index f2f0456..e2cf8b8 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,19 +1,23 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
+require 'rubocop/rake_task'
+
+RuboCop::RakeTask.new
+
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_140chars')
PuppetLint.configuration.relative = true
-PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
+PuppetLint.configuration.ignore_paths = ['spec/**/*.pp', 'pkg/**/*.pp']
desc 'Validate manifests, templates, and ruby files'
task :validate do
Dir['manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}"
end
- Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
- sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
+ Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file|
+ sh "ruby -c #{ruby_file}" unless ruby_file =~ %r{spec/fixtures}
end
Dir['templates/**/*.erb'].each do |template|
sh "erb -P -x -T '-' #{template} | ruby -c"
end
end
diff --git a/files/config.ru b/files/config.ru
deleted file mode 100644
index fb71aae..0000000
--- a/files/config.ru
+++ /dev/null
@@ -1,39 +0,0 @@
-# This file is being maintained by Puppet.
-# DO NOT EDIT
-
-# a config.ru, for use with every rack-compatible webserver.
-# SSL needs to be handled outside this, though.
-
-# if puppet is not in your RUBYLIB:
-# $LOAD_PATH.unshift('/opt/puppet/lib')
-
-$0 = "master"
-
-# if you want debugging:
-# ARGV << "--debug"
-
-ARGV << "--rack"
-
-# Rack applications typically don't start as root. Set --confdir and --vardir
-# to prevent reading configuration from ~puppet/.puppet/puppet.conf and writing
-# to ~puppet/.puppet
-ARGV << "--confdir" << "/etc/puppet"
-ARGV << "--vardir" << "/var/lib/puppet"
-
-# NOTE: it's unfortunate that we have to use the "CommandLine" class
-# here to launch the app, but it contains some initialization logic
-# (such as triggering the parsing of the config file) that is very
-# important. We should do something less nasty here when we've
-# gotten our API and settings initialization logic cleaned up.
-#
-# Also note that the "$0 = master" line up near the top here is
-# the magic that allows the CommandLine class to know that it's
-# supposed to be running master.
-#
-# --cprice 2012-05-22
-
-require 'puppet/util/command_line'
-# we're usually running inside a Rack::Builder.new {} block,
-# therefore we need to call run *here*.
-run Puppet::Util::CommandLine.new.execute
-
diff --git a/files/etckeeper-commit-post b/files/etckeeper-commit-post
deleted file mode 100755
index 489b2bd..0000000
--- a/files/etckeeper-commit-post
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
-
-which etckeeper > /dev/null 2>&1 || exit 0
-
-etckeeper commit "committing changes in /etc after puppet catalog run"
-
-# Failure of etckeeper should not be fatal.
-exit 0
diff --git a/files/etckeeper-commit-pre b/files/etckeeper-commit-pre
deleted file mode 100755
index a66fb62..0000000
--- a/files/etckeeper-commit-pre
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
-
-which etckeeper > /dev/null 2>&1 || exit 0
-
-etckeeper commit "saving uncommitted changes in /etc prior to puppet catalog run"
-
-# Failure of etckeeper should not be fatal.
-exit 0
diff --git a/lib/facter/puppet_environment.rb b/lib/facter/puppet_environment.rb
deleted file mode 100644
index 1d620c5..0000000
--- a/lib/facter/puppet_environment.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# This facter fact returns the value of the Puppet environment setting for
-# the node running puppet or puppet agent. The intent is to enable external
-# applications such as puppet dashboard to automatically have insight into the
-# environment used in the last puppetrun.
-
-
-begin
- require 'facter/util/puppet_settings'
-rescue LoadError => e
- # puppet apply does not add module lib directories to the $LOAD_PATH (See
- # #4248). It should (in the future) but for the time being we need to be
- # defensive which is what this rescue block is doing.
- rb_file = File.join(File.dirname(__FILE__), 'util', 'puppet_settings.rb')
- load rb_file if File.exists?(rb_file) or raise e
-end
-
-Facter.add(:environment) do
- setcode do
- # This will be nil if Puppet is not available.
- Facter::Util::PuppetSettings.with_puppet do
- Puppet[:environment]
- end
- end
-end
diff --git a/lib/facter/puppet_reportdir.rb b/lib/facter/puppet_reportdir.rb
deleted file mode 100644
index 35988ca..0000000
--- a/lib/facter/puppet_reportdir.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# This fact returns the value of the Puppet reportdir setting.
-
-begin
- require 'facter/util/puppet_settings'
-rescue LoadError => e
- # puppet apply does not add module lib directories to the $LOAD_PATH (See
- # #4248). It should (in the future) but for the time being we need to be
- # defensive which is what this rescue block is doing.
- rb_file = File.join(File.dirname(__FILE__), 'util', 'puppet_settings.rb')
- load rb_file if File.exists?(rb_file) or raise e
-end
-
-Facter.add(:puppet_reportdir) do
- setcode do
- # This will be nil if Puppet is not available.
- Facter::Util::PuppetSettings.with_puppet do
- Puppet[:reportdir]
- end
- end
-end
diff --git a/manifests/agent.pp b/manifests/agent.pp
deleted file mode 100644
index c0c4af7..0000000
--- a/manifests/agent.pp
+++ /dev/null
@@ -1,312 +0,0 @@
-# == Class: puppet::agent
-#
-# Manage Puppet agents
-#
-# We also run puppet once at boot via cron, regardless of if you normally run
-# puppet from cron or as a daemon.
-#
-class puppet::agent (
- $certname = $::fqdn,
- $config_path = 'USE_DEFAULTS',
- $config_owner = 'root',
- $config_group = 'root',
- $config_mode = '0644',
- $env = $::env,
- $puppet_server = 'puppet',
- $puppet_masterport = 'UNSET',
- $puppet_ca_server = 'UNSET',
- $http_proxy_host = 'UNSET',
- $http_proxy_port = 'UNSET',
- $is_puppet_master = false,
- $run_method = 'USE_DEFAULTS',
- $run_interval = '30',
- $run_in_noop = false,
- $cron_command = 'USE_DEFAULTS',
- $run_at_boot = true,
- $puppet_binary = 'USE_DEFAULTS',
- $symlink_puppet_binary_target = '/usr/local/bin/puppet',
- $symlink_puppet_binary = false,
- $agent_sysconfig = 'USE_DEFAULTS',
- $agent_sysconfig_ensure = 'USE_DEFAULTS',
- $daemon_name = 'puppet',
- $ssldir = 'USE_DEFAULTS',
- $stringify_facts = true,
- $etckeeper_hooks = false,
-) {
-
- if versioncmp($::puppetversion, '3.0') > 0 {
- # puppet v4
- $default_config_path = '/etc/puppetlabs/puppet/puppet.conf'
- $default_cron_command = '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
- $default_puppet_binary = '/opt/puppetlabs/bin/puppet'
- $default_run_method = 'cron'
- $is_puppet3 = false
- } else {
- # puppet v3
- $default_config_path = '/etc/puppet/puppet.conf'
- $default_cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
- $default_puppet_binary = '/usr/bin/puppet'
- $default_run_method = 'service'
- $is_puppet3 = true
- }
-
- if $config_path == 'USE_DEFAULTS' {
- $config_path_real = $default_config_path
- } else {
- $config_path_real = $config_path
- }
- validate_absolute_path($config_path_real)
-
- if $cron_command == 'USE_DEFAULTS' {
- $cron_command_real = $default_cron_command
- } else {
- $cron_command_real = $cron_command
- }
- validate_string($cron_command_real)
-
- if $puppet_binary == 'USE_DEFAULTS' {
- $puppet_binary_real = $default_puppet_binary
- } else {
- $puppet_binary_real = $puppet_binary
- }
- validate_absolute_path($puppet_binary_real)
-
- if $run_method == 'USE_DEFAULTS' {
- $run_method_real = $default_run_method
- } else {
- $run_method_real = $run_method
- }
- validate_string($run_method_real)
-
- if is_string($run_in_noop) {
- $run_in_noop_bool = str2bool($run_in_noop)
- } else {
- $run_in_noop_bool = $run_in_noop
- }
- validate_bool($run_in_noop_bool)
-
- if is_string($run_at_boot) {
- $run_at_boot_bool = str2bool($run_at_boot)
- } else {
- $run_at_boot_bool = $run_at_boot
- }
- validate_bool($run_at_boot_bool)
-
- if is_string($is_puppet_master) {
- $is_puppet_master_bool = str2bool($is_puppet_master)
- } else {
- $is_puppet_master_bool = $is_puppet_master
- }
- validate_bool($is_puppet_master_bool)
-
- # env must be set, else fail, since we use it in the puppet_config template
- if ! $env {
- fail('puppet::agent::env must be set')
- }
-
- if $puppet_masterport != 'UNSET' and is_integer($puppet_masterport) == false {
- fail("puppet::agent::puppet_masterport is set to <${puppet_masterport}>. It should be an integer.")
- }
-
- if $ssldir == 'USE_DEFAULTS' {
- $ssldir_real = '$vardir/ssl'
- } else {
- validate_absolute_path($ssldir)
- $ssldir_real = $ssldir
- }
-
- if is_string($stringify_facts) {
- $stringify_facts_bool = str2bool($stringify_facts)
- } else {
- $stringify_facts_bool = $stringify_facts
- }
- validate_bool($stringify_facts_bool)
-
- if is_string($etckeeper_hooks) {
- $etckeeper_hooks_bool = str2bool($etckeeper_hooks)
- } else {
- $etckeeper_hooks_bool = $etckeeper_hooks
- }
- validate_bool($etckeeper_hooks_bool)
-
- if $http_proxy_host != 'UNSET' and (is_domain_name($http_proxy_host) == false and is_ip_address($http_proxy_host) == false){
- fail("puppet::agent::http_proxy_host is set to <${http_proxy_host}>. It should be a fqdn or an ip-address.")
- }
-
- if $http_proxy_port != 'UNSET' and is_integer($http_proxy_port) == false {
- fail("puppet::agent::http_proxy_port is set to <${http_proxy_port}>. It should be an Integer.")
- }
-
- case $::osfamily {
- 'Debian': {
- $default_agent_sysconfig = '/etc/default/puppet'
- $default_agent_sysconfig_ensure = 'file'
- }
- 'RedHat': {
- $default_agent_sysconfig = '/etc/sysconfig/puppet'
- $default_agent_sysconfig_ensure = 'file'
- }
- 'Solaris': {
- $default_agent_sysconfig = undef
- $default_agent_sysconfig_ensure = 'absent'
- }
- 'Suse': {
- $default_agent_sysconfig = '/etc/sysconfig/puppet'
- $default_agent_sysconfig_ensure = 'file'
- }
- default: {
- fail("puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <${::osfamily}>.")
- }
- }
-
- if $agent_sysconfig == 'USE_DEFAULTS' {
- $agent_sysconfig_real = $default_agent_sysconfig
- } else {
- $agent_sysconfig_real = $agent_sysconfig
- }
-
- if $agent_sysconfig_ensure == 'USE_DEFAULTS' {
- $agent_sysconfig_ensure_real = $default_agent_sysconfig_ensure
- } else {
- $agent_sysconfig_ensure_real = $agent_sysconfig_ensure
- }
-
- if $is_puppet_master_bool == false {
- $config_content = template('puppet/puppetagent.conf.erb')
- } else {
- $config_content = undef
- }
-
- case $run_method_real {
- 'service': {
- $daemon_ensure = 'running'
- $daemon_enable = true
- $cron_ensure = 'absent'
- $my_cron_command = undef
- $cron_user = undef
- $cron_hour = undef
- $cron_minute = undef
- }
- 'cron': {
- $daemon_ensure = 'stopped'
- $daemon_enable = false
- $cron_run_one = fqdn_rand($run_interval)
- $cron_run_two = fqdn_rand($run_interval) + 30
- $cron_ensure = 'present'
- $cron_user = 'root'
- $cron_hour = '*'
-
- if $run_interval > '30' {
- $cron_minute = $cron_run_one
- } else {
- $cron_minute = [$cron_run_one, $cron_run_two]
- }
-
- if $run_in_noop_bool == true {
- $my_cron_command = "${cron_command_real} --noop"
- } else {
- $my_cron_command = $cron_command_real
- }
- }
- 'disable': {
- $daemon_ensure = 'stopped'
- $daemon_enable = false
- $cron_ensure = 'absent'
- $my_cron_command = undef
- $cron_user = undef
- $cron_hour = undef
- $cron_minute = undef
- }
- default: {
- fail("puppet::agent::run_method is ${run_method_real} and must be 'disable', 'service' or 'cron'.")
- }
- }
-
- if $run_at_boot_bool == true {
- $at_boot_ensure = 'present'
- } else {
- $at_boot_ensure = 'absent'
- }
-
- if is_string($symlink_puppet_binary) {
- $symlink_puppet_binary_bool = str2bool($symlink_puppet_binary)
- } else {
- $symlink_puppet_binary_bool = $symlink_puppet_binary
- }
- validate_bool($symlink_puppet_binary_bool)
-
- validate_absolute_path($symlink_puppet_binary_target)
-
- # optionally create symlinks to puppet binary
- if $symlink_puppet_binary_bool == true {
-
- file { 'puppet_symlink':
- ensure => link,
- path => $symlink_puppet_binary_target,
- target => $puppet_binary_real,
- }
- }
-
- file { 'puppet_config':
- path => $config_path_real,
- content => $config_content,
- owner => $config_owner,
- group => $config_group,
- mode => $config_mode,
- }
-
- if ($etckeeper_hooks_bool) {
- file { 'etckeeper_pre':
- path => '/etc/puppet/etckeeper-commit-pre',
- owner => 'root',
- group => 'root',
- mode => '0755',
- source => 'puppet:///modules/puppet/etckeeper-commit-pre',
- }
-
- file { 'etckeeper_post':
- path => '/etc/puppet/etckeeper-commit-post',
- owner => 'root',
- group => 'root',
- mode => '0755',
- source => 'puppet:///modules/puppet/etckeeper-commit-post',
- }
- }
-
- if $default_agent_sysconfig_ensure =~ /(present)|(file)/ {
- file { 'puppet_agent_sysconfig':
- ensure => $agent_sysconfig_ensure_real,
- path => $agent_sysconfig_real,
- content => template('puppet/agent_sysconfig.erb'),
- owner => 'root',
- group => 'root',
- mode => '0644',
- }
- }
-
- service { 'puppet_agent_daemon':
- # GH: This service will always show as being running while an agent run is
- # taking place, so we no longer ensure its status. Before doing this, there
- # would *always* be a logged change and the Console could never be green.
- #ensure => $daemon_ensure,
- name => $daemon_name,
- enable => $daemon_enable,
- }
-
- cron { 'puppet_agent':
- ensure => $cron_ensure,
- command => $my_cron_command,
- user => $cron_user,
- hour => $cron_hour,
- minute => $cron_minute,
- }
-
- if $run_method_real == 'cron' {
- cron { 'puppet_agent_once_at_boot':
- ensure => $at_boot_ensure,
- command => $my_cron_command,
- user => $cron_user,
- special => 'reboot',
- }
- }
-}
diff --git a/manifests/dashboard.pp b/manifests/dashboard.pp
deleted file mode 100644
index d74735d..0000000
--- a/manifests/dashboard.pp
+++ /dev/null
@@ -1,89 +0,0 @@
-# == Class: puppet::dashboard
-#
-class puppet::dashboard (
- $dashboard_package = 'puppet-dashboard',
- $dashboard_user = 'USE_DEFAULTS',
- $dashboard_group = 'USE_DEFAULTS',
- $sysconfig_path = 'USE_DEFAULTS',
- $external_node_script_path = '/usr/share/puppet-dashboard/bin/external_node',
- $dashboard_fqdn = "puppet.${::domain}",
- $port = '3000',
-) {
-
- validate_absolute_path($external_node_script_path)
- if !is_string($dashboard_package) and !is_array($dashboard_package) {
- fail('puppet::dashboard::dashboard_package must be a string or an array.')
- }
-
- case $::osfamily {
- 'RedHat': {
- $default_sysconfig_path = '/etc/sysconfig/puppet-dashboard'
- $sysconfig_template = 'dashboard_sysconfig.erb'
- $default_dashboard_user = 'puppet-dashboard'
- $default_dashboard_group = 'puppet-dashboard'
- }
- 'Debian': {
- $default_sysconfig_path = '/etc/default/puppet-dashboard'
- $sysconfig_template = 'dashboard_default.erb'
- $default_dashboard_user = 'puppet'
- $default_dashboard_group = 'puppet'
- }
- default: {
- fail("puppet::dashboard supports osfamilies Debian and RedHat. Detected osfamily is <${::osfamily}>.")
- }
- }
-
- if $sysconfig_path == 'USE_DEFAULTS' {
- $sysconfig_path_real = $default_sysconfig_path
- } else {
- $sysconfig_path_real = $sysconfig_path
- }
- validate_absolute_path($sysconfig_path_real)
-
- if $dashboard_user == 'USE_DEFAULTS' {
- $dashboard_user_real = $default_dashboard_user
- } else {
- $dashboard_user_real = $dashboard_user
- }
-
- if $dashboard_group == 'USE_DEFAULTS' {
- $dashboard_group_real = $default_dashboard_group
- } else {
- $dashboard_group_real = $dashboard_group
- }
-
- package { $dashboard_package:
- ensure => present,
- }
-
- file { 'external_node_script':
- ensure => file,
- content => template('puppet/external_node.erb'),
- path => $external_node_script_path,
- owner => $dashboard_user_real,
- group => $dashboard_group_real,
- mode => '0755',
- require => Package[$dashboard_package],
- }
-
- file { 'dashboard_sysconfig':
- ensure => file,
- path => $sysconfig_path_real,
- content => template("puppet/${sysconfig_template}"),
- owner => 'root',
- group => 'root',
- mode => '0644',
- }
-
- # Dashboard is ran under Passenger with Apache
- service { 'puppet-dashboard':
- ensure => stopped,
- enable => false,
- subscribe => File['dashboard_sysconfig'],
- }
-
- service { 'puppet-dashboard-workers':
- ensure => stopped,
- enable => false,
- }
-}
diff --git a/manifests/dashboard/maintenance.pp b/manifests/dashboard/maintenance.pp
deleted file mode 100644
index 0077a7f..0000000
--- a/manifests/dashboard/maintenance.pp
+++ /dev/null
@@ -1,108 +0,0 @@
-# == Class: puppet::dashboard::maintenance
-#
-class puppet::dashboard::maintenance (
- $db_optimization_command = '/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log',
- $db_optimization_user = 'root',
- $db_optimization_hour = '0',
- $db_optimization_minute = '0',
- $db_optimization_monthday = '1',
- $reports_days_to_keep = '30',
- $purge_old_reports_command = 'USE_DEFAULTS',
- $purge_old_reports_user = 'root',
- $purge_old_reports_hour = '0',
- $purge_old_reports_minute = '30',
- $remove_old_reports_spool = true,
- $reports_spool_dir = '/usr/share/puppet-dashboard/spool',
- $reports_spool_days_to_keep = '7',
- $remove_reports_spool_user = 'root',
- $remove_reports_spool_hour = '0',
- $remove_reports_spool_minute = '45',
- $dump_dir = '/var/local',
- $dump_database_command = 'USE_DEFAULTS',
- $dump_database_user = 'root',
- $dump_database_hour = '1',
- $dump_database_minute = '0',
- $days_to_keep_backups = '7',
- $purge_old_db_backups_user = 'root',
- $purge_old_db_backups_hour = '2',
- $purge_old_db_backups_minute = '0',
-) {
-
- require '::puppet::dashboard'
-
- validate_absolute_path($reports_spool_dir)
- validate_absolute_path($dump_dir)
- validate_string($dump_database_command)
- validate_integer($reports_days_to_keep)
-
- $purge_old_reports_command_real = $purge_old_reports_command ? {
- 'USE_DEFAULTS' => "/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=${reports_days_to_keep} unit=day >> /var/log/puppet/dashboard_maintenance.log",
- default => $purge_old_reports_command
- }
-
- $dump_database_command_real = $dump_database_command ? {
- 'USE_DEFAULTS' => "cd ~puppet-dashboard && sudo -u ${puppet::dashboard::dashboard_user_real} /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=${dump_dir}/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 ${dump_dir}/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1",
- default => $dump_database_command
- }
-
- common::mkdir_p { $dump_dir: }
-
- file { $dump_dir:
- ensure => directory,
- group => $puppet::dashboard::dashboard_group_real,
- mode => '0775',
- require => Common::Mkdir_p[$dump_dir],
- }
-
- cron { 'monthly_dashboard_database_optimization':
- ensure => present,
- command => $db_optimization_command,
- user => $db_optimization_user,
- hour => $db_optimization_hour,
- minute => $db_optimization_minute,
- monthday => $db_optimization_monthday,
- }
-
- cron { 'purge_old_reports':
- ensure => present,
- command => $purge_old_reports_command_real,
- user => $purge_old_reports_user,
- hour => $purge_old_reports_hour,
- minute => $purge_old_reports_minute,
- }
-
- if is_string($remove_old_reports_spool) {
- $enable_remove_old_reports_spool = str2bool($remove_old_reports_spool)
- } else {
- $enable_remove_old_reports_spool = $remove_old_reports_spool
- }
- validate_bool($enable_remove_old_reports_spool)
-
- if $enable_remove_old_reports_spool == true {
- $remove_old_reports_spool_enable = 'present'
- } else {
- $remove_old_reports_spool_enable = 'absent'
- }
-
- cron { 'remove_old_reports_spool':
- ensure => $remove_old_reports_spool_enable,
- command => "/bin/find ${reports_spool_dir} -type f -name \"*.yaml\" -mtime +${$reports_spool_days_to_keep } -exec /bin/rm -f {} \\;",
- user => $remove_reports_spool_user,
- hour => $remove_reports_spool_hour,
- minute => $remove_reports_spool_minute,
- }
-
- cron { 'dump_dashboard_database':
- command => $dump_database_command_real,
- user => $dump_database_user,
- hour => $dump_database_hour,
- minute => $dump_database_minute,
- }
-
- cron { 'purge_old_db_backups':
- command => "/bin/find ${dump_dir} -type f -mtime +${days_to_keep_backups} -exec /bin/rm -f {} \\;",
- user => $purge_old_db_backups_user,
- hour => $purge_old_db_backups_hour,
- minute => $purge_old_db_backups_minute,
- }
-}
diff --git a/manifests/dashboard/server.pp b/manifests/dashboard/server.pp
deleted file mode 100644
index 8b9c6ad..0000000
--- a/manifests/dashboard/server.pp
+++ /dev/null
@@ -1,171 +0,0 @@
-# == Class: puppet::dashboard::server
-#
-class puppet::dashboard::server (
- $dashboard_workers = $::processorcount,
- $database_config_path = '/usr/share/puppet-dashboard/config/database.yml',
- $database_config_owner = 'USE_DEFAULTS',
- $database_config_group = 'USE_DEFAULTS',
- $database_config_mode = '0640',
- $htpasswd = undef,
- $htpasswd_path = '/etc/puppet/dashboard.htpasswd',
- $htpasswd_owner = 'root',
- $htpasswd_group = 'USE_DEFAULTS',
- $htpasswd_mode = '0640',
- $log_dir = '/var/log/puppet',
- $manage_mysql_options = true,
- $mysql_user = 'dashboard',
- $mysql_password = 'puppet',
- $mysql_max_packet_size = '32M',
- $security = 'none',
- $vhost_path = 'USE_DEFAULTS',
-) inherits puppet::dashboard {
-
- validate_re($dashboard_workers, '^\d+$',
- "puppet::dashboard::server::dashboard_workers must be a digit. Detected value is <${dashboard_workers}>."
- )
- validate_absolute_path($htpasswd_path)
- validate_re($security, '^(none|htpasswd)$',
- "Security is <${security}> which does not match regex. Valid values are none and htpasswd."
- )
-
- case $::osfamily {
- 'RedHat': {
- $default_database_config_group = $puppet::dashboard::dashboard_group_real
- $default_htpasswd_group = 'apache'
- $default_vhost_path = '/etc/httpd/conf.d/dashboard.conf'
- }
- 'Debian': {
- $default_database_config_group = 'www-data'
- $default_htpasswd_group = 'www-data'
- $default_vhost_path = '/etc/apache2/sites-enabled/puppetdashboard'
-
- file { 'dashboard_workers_default':
- ensure => file,
- path => '/etc/default/puppet-dashboard-workers',
- content => template('puppet/puppet-dashboard-workers.erb'),
- owner => 'root',
- group => 'root',
- mode => '0644',
- notify => Service['puppet-dashboard-workers'],
- }
- }
- default: {
- fail("puppet::dashboard::server supports osfamilies Debian and RedHat. Detected osfamily is <${::osfamily}>.")
- }
- }
-
- if $database_config_owner == 'USE_DEFAULTS' {
- $database_config_owner_real = $puppet::dashboard::dashboard_user_real
- } else {
- $database_config_owner_real = $database_config_owner
- }
-
- if $database_config_group == 'USE_DEFAULTS' {
- $database_config_group_real = $default_database_config_group
- } else {
- $database_config_group_real = $database_config_group
- }
-
- if $htpasswd_group == 'USE_DEFAULTS' {
- $htpasswd_group_real = $default_htpasswd_group
- } else {
- $htpasswd_group_real = $htpasswd_group
- }
-
- if $vhost_path == 'USE_DEFAULTS' {
- $vhost_path_real = $default_vhost_path
- } else {
- $vhost_path_real = $vhost_path
- }
- validate_absolute_path($vhost_path_real)
-
- require '::passenger'
- include ::puppet::dashboard::maintenance
-
- if is_bool($manage_mysql_options) {
- $manage_mysql_options_real = $manage_mysql_options
- } elsif is_string($manage_mysql_options) {
- $manage_mysql_options_real = str2bool($manage_mysql_options)
- } else {
- fail("puppet::dashboard::server::manage_mysql_options supports booleans only and is <${manage_mysql_options}>.")
- }
-
- if $manage_mysql_options_real == true {
- class { '::mysql::server':
- override_options => {
- 'mysqld' => {
- 'max_allowed_packet' => $mysql_max_packet_size,
- },
- },
- }
- } else {
- include ::mysql::server
- }
-
- if $security == 'htpasswd' and $htpasswd != undef {
-
- Htpasswd {
- target => $htpasswd_path,
- }
-
- Htpasswd <| tag == 'puppet::dashboard::server' |> -> File['dashboard_htpasswd_path']
-
- create_resources('htpasswd',$htpasswd)
-
- file { 'dashboard_htpasswd_path':
- ensure => file,
- path => $htpasswd_path,
- owner => $htpasswd_owner,
- group => $htpasswd_group_real,
- mode => $htpasswd_mode,
- }
- }
-
- file { 'database_config':
- ensure => file,
- content => template('puppet/database.yml.erb'),
- path => $database_config_path,
- owner => $database_config_owner_real,
- group => $database_config_group_real,
- mode => $database_config_mode,
- require => Package[$puppet::dashboard::dashboard_package],
- }
-
- file { 'dashboard_vhost':
- ensure => file,
- path => $vhost_path_real,
- content => template('puppet/dashboard-vhost.conf.erb'),
- owner => 'root',
- group => 'root',
- mode => '0644',
- require => [ File['httpd_vdir'], # apache
-# Exec['compile-passenger'], # passenger
- ],
- notify => Service['httpd'], # apache
- }
-
- mysql::db { 'dashboard':
- user => $mysql_user,
- password => $mysql_password,
- host => 'localhost',
- grant => ['ALL'],
- require => [ Class['mysql::server'],
- File['database_config'],
- ],
- }
-
- exec { 'migrate_dashboard_database':
- command => 'rake RAILS_ENV=production db:migrate',
- onlyif => 'rake RAILS_ENV=production db:version 2>/dev/null|grep ^\'Current version\' | awk -F : \'{print $2}\' | awk \'{print $1}\'|grep ^0$',
- path => '/bin:/usr/bin:/sbin:/usr/sbin',
- cwd => '/usr/share/puppet-dashboard',
- refreshonly => true,
- subscribe => Mysql::Db['dashboard'],
- }
-
- Service['puppet-dashboard-workers'] {
- ensure => running,
- enable => true,
- subscribe => File['dashboard_sysconfig'],
- }
-}
diff --git a/manifests/init.pp b/manifests/init.pp
old mode 100755
new mode 100644
index f13fe62..62e4607
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,7 +1,124 @@
# == Class: puppet
#
-# Full description of class puppet here.
+# Manages puppet agent
#
-class puppet {
+class puppet (
+ String $certname = $::fqdn,
+ Variant[Enum['true', 'false'], Boolean] $run_every_thirty = true, #lint:ignore:quoted_booleans
+ Variant[Enum['true', 'false'], Boolean] $run_in_noop = true, #lint:ignore:quoted_booleans
+ String $cron_command = '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay',
+ Variant[Enum['true', 'false'], Boolean] $run_at_boot = true, #lint:ignore:quoted_booleans
+ String $config_path = '/etc/puppetlabs/puppet/puppet.conf',
+ String $server = 'puppet',
+ String $ca_server = 'puppet',
+ Variant[Enum['true', 'false'], Boolean] $graph = false, #lint:ignore:quoted_booleans
+ Variant[Enum['true', 'false'], Boolean] $archive_files = false, #lint:ignore:quoted_booleans
+ String $archive_file_server = 'puppet',
+ String $agent_sysconfig_path = '/etc/sysconfig/puppet',
+) {
+ if $config_path != undef {
+ validate_absolute_path($config_path)
+ }
+
+ if $agent_sysconfig_path != undef {
+ validate_absolute_path($agent_sysconfig_path)
+ }
+
+ if is_string($run_every_thirty) == true {
+ $run_every_thirty_bool = str2bool($run_every_thirty)
+ } else {
+ $run_every_thirty_bool = $run_every_thirty
+ }
+
+ if is_string($run_in_noop) == true {
+ $run_in_noop_bool = str2bool($run_in_noop)
+ } else {
+ $run_in_noop_bool = $run_in_noop
+ }
+
+ if is_string($run_at_boot) == true {
+ $run_at_boot_bool = str2bool($run_at_boot)
+ } else {
+ $run_at_boot_bool = $run_at_boot
+ }
+
+ if $run_every_thirty_bool == true {
+ $cron_run_one = fqdn_rand(30)
+ $cron_run_two = fqdn_rand(30) + 30
+ $cron_minute = [ $cron_run_one, $cron_run_two]
+ $cron_ensure = 'present'
+ } else {
+ $cron_ensure = 'absent'
+ $cron_minute = undef
+ }
+
+ if $run_in_noop_bool == true {
+ $cron_command_real = "${cron_command} --noop"
+ } else {
+ $cron_command_real = $cron_command
+ }
+
+ cron { 'puppet_agent_every_thirty':
+ ensure => $cron_ensure,
+ command => $cron_command_real,
+ user => 'root',
+ hour => '*',
+ minute => $cron_minute,
+ }
+
+ if $run_at_boot_bool == true {
+ $at_boot_ensure = 'present'
+ } else {
+ $at_boot_ensure = 'absent'
+ }
+
+ cron { 'puppet_agent_once_at_boot':
+ ensure => $at_boot_ensure,
+ command => $cron_command_real,
+ user => 'root',
+ special => 'reboot',
+ }
+
+ $ini_defaults = {
+ ensure => 'present',
+ path => $::puppet::config_path,
+ section => 'main',
+ require => File['puppet_config'],
+ }
+
+ $ini_settings = {
+ 'server' => { setting => 'server', value => $server,},
+ 'ca_server' => { setting => 'ca_server', value => $ca_server,},
+ 'certname' => { setting => 'certname', value => $certname,},
+ 'environment' => { setting => 'environment', value => $environment,},
+ 'trusted_node_data' => { setting => 'trusted_node_data', value => true,},
+ 'graph' => { setting => 'graph', value => $graph,},
+ 'archive_files' => { setting => 'archive_files', value => $archive_files,},
+ 'archive_file_server' => { setting => 'archive_file_server', value => $archive_file_server,},
+ }
+ create_resources('ini_setting', $ini_settings, $ini_defaults)
+
+ file { 'puppet_config':
+ ensure => 'file',
+ path => $config_path,
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ }
+
+ file { 'puppet_agent_sysconfig':
+ ensure => 'file',
+ path => $agent_sysconfig_path,
+ content => template('puppet/agent_sysconfig.erb'),
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ }
+
+ service { 'puppet_agent_daemon':
+ ensure => 'stopped',
+ name => 'puppet',
+ enable => false,
+ }
}
diff --git a/manifests/lint.pp b/manifests/lint.pp
deleted file mode 100644
index f288731..0000000
--- a/manifests/lint.pp
+++ /dev/null
@@ -1,32 +0,0 @@
-# == Class: puppet::lint
-#
-# Manage puppet-lint - http://github.com/rodjek/puppet-lint
-#
-class puppet::lint (
- $ensure = 'present',
- $provider = 'gem',
- $version = undef,
- $lint_args = '--no-80chars-check',
- $lintrc_path = "${::root_home}/.puppet-lint.rc",
- $lintrc_owner = 'root',
- $lintrc_group = 'root',
- $lintrc_mode = '0644',
-) {
-
- if $version {
- $my_ensure = $version
- }
-
- package { 'puppet-lint':
- ensure => $my_ensure,
- provider => $provider,
- }
-
- file { $lintrc_path:
- ensure => file,
- content => "${lint_args}\n",
- owner => $lintrc_owner,
- group => $lintrc_group,
- mode => $lintrc_mode,
- }
-}
diff --git a/manifests/master.pp b/manifests/master.pp
deleted file mode 100644
index 63f74ee..0000000
--- a/manifests/master.pp
+++ /dev/null
@@ -1,118 +0,0 @@
-# == Class: puppet::master
-#
-class puppet::master (
- $sysconfig_path = 'USE_DEFAULTS',
- $rack_dir = '/usr/share/puppet/rack/puppetmasterd',
- $puppet_user = 'puppet',
- $manage_firewall = undef,
- $vhost_path = 'USE_DEFAULTS',
- $passenger_max_requests = 1000,
-) {
-
- case $::osfamily {
- 'RedHat': {
- $default_sysconfig_path = '/etc/sysconfig/puppetmaster'
- $sysconfig_template = 'puppetmaster_sysconfig.erb'
- $default_vhost_path = '/etc/httpd/conf.d/puppetmaster.conf'
- }
- 'Debian': {
- $default_sysconfig_path = '/etc/default/puppetmaster'
- $sysconfig_template = 'puppetmaster_default.erb'
- $default_vhost_path = '/etc/apache2/sites-enabled/puppetmaster'
- }
- default: {
- fail("puppet::master supports osfamilies Debian and RedHat. Detected osfamily is <${::osfamily}>.")
- }
- }
-
- include ::apache::mod::ssl
- include ::common
- include ::passenger
- include ::puppet::lint
- include ::puppet::master::maintenance
-
- if $sysconfig_path == 'USE_DEFAULTS' {
- $sysconfig_path_real = $default_sysconfig_path
- } else {
- $sysconfig_path_real = $sysconfig_path
- }
- validate_absolute_path($sysconfig_path_real)
-
- if $vhost_path == 'USE_DEFAULTS' {
- $vhost_path_real = $default_vhost_path
- } else {
- $vhost_path_real = $vhost_path
- }
- validate_absolute_path($vhost_path_real)
-
- validate_integer($passenger_max_requests)
-
- if $manage_firewall == true {
- firewall { '8140 open port 8140 for Puppet Master':
- action => 'accept',
- dport => 8140,
- proto => 'tcp',
- }
- }
-
- File {
- owner => 'root',
- group => 'root',
- mode => '0644',
- }
-
- file { '/etc/puppet/auth.conf': }
-
- file { '/etc/puppet/fileserver.conf': }
-
- file { 'puppetmaster_sysconfig':
- ensure => file,
- path => $sysconfig_path_real,
- content => template("puppet/${sysconfig_template}"),
- }
-
- # Puppetmaster service cannot be stopped as that would likely break the boot
- # strap process.
- service { 'puppetmaster':
- enable => false,
- }
-
- # Passenger
- common::mkdir_p { $rack_dir: }
- common::mkdir_p { "${rack_dir}/public": }
- common::mkdir_p { "${rack_dir}/tmp": }
-
- file { $rack_dir:
- ensure => directory,
- require => Common::Mkdir_p[$rack_dir],
- }
-
- file { "${rack_dir}/public":
- ensure => directory,
- require => Common::Mkdir_p["${rack_dir}/public"],
- }
-
- file { "${rack_dir}/tmp":
- ensure => directory,
- require => Common::Mkdir_p["${rack_dir}/tmp"],
- }
-
- file { "${rack_dir}/config.ru":
- ensure => file,
- source => 'puppet:///modules/puppet/config.ru',
- owner => $puppet_user,
- group => 'root',
- mode => '0644',
- }
-
- file { 'puppetmaster_vhost':
- ensure => file,
- path => $vhost_path_real,
- content => template('puppet/puppetmaster-vhost.conf.erb'),
- owner => 'root',
- group => 'root',
- mode => '0644',
- require => File['httpd_vdir'],
- notify => Service['httpd'],
- }
-}
diff --git a/manifests/master/maintenance.pp b/manifests/master/maintenance.pp
deleted file mode 100755
index 70db1e4..0000000
--- a/manifests/master/maintenance.pp
+++ /dev/null
@@ -1,60 +0,0 @@
-# == Class: puppet::master::maintenance
-#
-class puppet::master::maintenance (
- $clientbucket_cleanup_ensure = 'present',
- $clientbucket_path = '/var/lib/puppet/clientbucket/',
- $clientbucket_days_to_keep = '30',
- $filebucket_cleanup_command = '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -f {} \;',
- $filebucket_cleanup_user = 'root',
- $filebucket_cleanup_hour = '0',
- $filebucket_cleanup_minute = '0',
- $reportdir_purge_ensure = 'present',
- $reportdir = $::puppet_reportdir,
- $reportdir_days_to_keep = '30',
- $reportdir_purge_command = '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -f {} \;',
- $reportdir_purge_user = 'root',
- $reportdir_purge_hour = '0',
- $reportdir_purge_minute = '15',
-) {
-
- validate_absolute_path($reportdir)
-
- validate_re($clientbucket_cleanup_ensure, '^(present|absent)$', "clientbucket_cleanup_ensure must be 'present' or 'absent'. Detected value is <${clientbucket_cleanup_ensure}>")
-
- validate_re($reportdir_purge_ensure, '^(present|absent)$', "reportdir_purge_ensure must be 'present' or 'absent'. Detected value is <${reportdir_purge_ensure}>")
-
- # if not using the defaults, then construct the command with variables, else
- # use the default command
- if ( $clientbucket_days_to_keep != 30 ) or ( $clientbucket_path != '/var/lib/puppet/clientbucket/' ) {
- $my_filebucket_cleanup_command = "/usr/bin/find ${clientbucket_path} -type f -mtime +${clientbucket_days_to_keep} -exec /bin/rm -f {} \\;"
- } else {
- $my_filebucket_cleanup_command = $filebucket_cleanup_command
- }
-
- cron { 'filebucket_cleanup':
- ensure => $clientbucket_cleanup_ensure,
- command => $my_filebucket_cleanup_command,
- user => $filebucket_cleanup_user,
- hour => $filebucket_cleanup_hour,
- minute => $filebucket_cleanup_minute,
- }
-
- if $reportdir_days_to_keep <= '0' {
- fail("puppet::master::maintenance::reportdir_days_to_keep must be a positive integer greater than zero. Detected value is <${reportdir_days_to_keep}>.")
- }
-
- if ( $reportdir_days_to_keep != 30 ) or ( $reportdir != '/var/lib/puppet/reports' ) {
- $my_reportdir_purge_command = "/usr/bin/find -L ${reportdir} -type f -mtime +${reportdir_days_to_keep} -exec /bin/rm -f {} \\;"
- } else {
- $my_reportdir_purge_command = $reportdir_purge_command
- }
-
- cron { 'purge_old_puppet_reports':
- ensure => $reportdir_purge_ensure,
- command => $my_reportdir_purge_command,
- user => $reportdir_purge_user,
- hour => $reportdir_purge_hour,
- minute => $reportdir_purge_minute,
- }
-
-}
diff --git a/manifests/server.pp b/manifests/server.pp
new file mode 100644
index 0000000..3104ad1
--- /dev/null
+++ b/manifests/server.pp
@@ -0,0 +1,92 @@
+# == Class: puppet::server
+#
+# Manages puppetserver
+#
+class puppet::server(
+ Variant[Enum['true', 'false'], Boolean] $ca = false, #lint:ignore:quoted_booleans
+ Variant[Array[String, 1], Undef] $autosign_entries = undef,
+ String $sysconfig_path = '/etc/sysconfig/puppetserver',
+ String $memory_size = '2g', # only m and g are appropriate for unit
+ Optional[String] $enc = undef,
+ Optional[String] $dns_alt_names = undef,
+) {
+
+ include ::puppet
+
+ if $sysconfig_path != undef {
+ validate_absolute_path($sysconfig_path)
+ }
+
+ validate_re($memory_size, '^\d+(m|g)$',
+ "puppet::memory_size is <${memory_size}> and must be an integer following by the unit 'm' or 'g'.")
+
+ $ini_defaults = {
+ ensure => 'present',
+ path => $::puppet::config_path,
+ section => 'master',
+ require => File['puppet_config'],
+ notify => Service['puppetserver'],
+ }
+
+ $non_conditional_ini_settings = {
+ 'vardir' => { setting => 'vardir', value => '/opt/puppetlabs/server/data/puppetserver',},
+ 'logdir' => { setting => 'logdir', value => '/var/log/puppetlabs/puppetserver',},
+ 'rundir' => { setting => 'rundir', value => '/var/run/puppetlabs/puppetserver',},
+ 'pidfile' => { setting => 'pidfile', value => '/var/run/puppetlabs/puppetserver/puppetserver.pid',},
+ 'codedir' => { setting => 'codedir', value =>'/etc/puppetlabs/code',},
+ 'ca' => { setting => 'ca', value => $ca,},
+ }
+
+ if $enc != undef {
+ validate_absolute_path($enc)
+ $ini_enc_settings = {
+ 'node_terminus' => { setting => 'node_terminus', value => 'exec' },
+ 'external_nodes' => { setting => 'external_nodes', value => $enc },
+ }
+ } else {
+ $ini_enc_settings = {}
+ }
+
+ if $dns_alt_names != undef {
+ $ini_dns_alt_names_settings = {
+ 'dns_alt_names' => { setting => 'dns_alt_names', value => $dns_alt_names },
+ }
+ } else {
+ $ini_dns_alt_names_settings = {}
+ }
+
+ $ini_settings_merged = $non_conditional_ini_settings + $ini_enc_settings + $ini_dns_alt_names_settings
+ create_resources('ini_setting', $ini_settings_merged, $ini_defaults)
+
+ # Ensure that puppet.conf settings in [main] also trigger a restart of
+ # puppetserver
+ Ini_setting <| tag == 'puppet' and section == 'main' |> ~> Service['puppetserver']
+
+ file { 'puppetserver_sysconfig':
+ ensure => 'file',
+ path => $sysconfig_path,
+ content => template('puppet/puppetserver_sysconfig.erb'),
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ }
+
+ file { 'autosign_config':
+ ensure => 'file',
+ path => '/etc/puppetlabs/puppet/autosign.conf',
+ content => template('puppet/autosign.conf.erb'),
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ notify => Service['puppetserver'],
+ }
+
+ service { 'puppetserver':
+ ensure => 'running',
+ enable => true,
+ subscribe => [
+ File['puppet_config'],
+ File['puppetserver_sysconfig'],
+ ],
+ }
+}
diff --git a/metadata.json b/metadata.json
index 91bcc19..33b38a8 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,51 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.19.0",
+ "version": "3.0.0",
"author": "ghoneycutt",
- "summary": "Manage Puppet",
- "description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
+ "summary": "Manages Puppet agent and puppetserver",
+ "description": "Manages Puppet agent and puppetserver.",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
- "version_requirement": ">= 3.2.0 < 5.0.0"
+ "version_requirement": ">= 4.7.0 < 5.0.0"
},
{
"name": "puppet",
- "version_requirement": ">= 3.0.0 < 5.0.0"
+ "version_requirement": ">= 4.7.0 < 5.0.0"
}
],
"operatingsystem_support": [
- {
- "operatingsystem": "Debian",
- "operatingsystemrelease": [
- "6",
- "7"
- ]
- },
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
- "5",
- "6",
- "7"
+ "6"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
- "5",
- "6",
- "7"
+ "6"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
- "5",
- "6",
- "7"
+ "6"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
- "5",
- "6",
- "7"
- ]
- },
- {
- "operatingsystem": "Solaris",
- "operatingsystemrelease": [
- "9",
- "10",
- "11"
- ]
- },
- {
- "operatingsystem": "SLES"
- },
- {
- "operatingsystem": "SLED"
- },
- {
- "operatingsystem": "Ubuntu",
- "operatingsystemrelease": [
- "12.04"
+ "6"
]
}
],
"dependencies": [
- {"name":"ghoneycutt/common","version_requirement":">= 1.6.0 < 2.0.0"},
- {"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1 < 2.0.0"},
- {"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 6.0.0"},
- {"name":"puppetlabs/mysql","version_requirement":">= 2.0.0 < 3.0.0"},
- {"name":"puppetlabs/passenger","version_requirement":">= 0.4.1 < 2.0.0"},
- {"name":"puppetlabs/apache","version_requirement":">= 0.5.0 < 2.0.0"},
- {"name":"puppetlabs/firewall","version_requirement":">= 1.7.1 < 2.0.0"},
- {"name":"puppetlabs/concat","version_requirement":">= 1.2.5 < 2.0.0"}
+ {"name":"puppetlabs/inifile","version_requirement":">= 1.6.0 < 2.0.0"},
+ {"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 6.0.0"}
]
}
diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb
deleted file mode 100644
index 6d6bc4b..0000000
--- a/spec/classes/agent_spec.rb
+++ /dev/null
@@ -1,776 +0,0 @@
-require 'spec_helper'
-describe 'puppet::agent' do
-
- describe 'config file' do
-
- context 'with default settings' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :fqdn => 'agent.example.com',
- }
- end
- let(:params) { { :env => 'production' } }
-
- it { should contain_class('puppet::agent') }
-
- it { should contain_file('puppet_config').with({
- 'path' => '/etc/puppet/puppet.conf',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
-
- it { should contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
- it { should contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
- it { should contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
- it { should contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
- it { should contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
- it { should contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
- it { should contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
- it { should contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
- it { should contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
- it { should_not contain_file('puppet_config').with_content(/masterport =/) }
- it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
- it { should_not contain_file('puppet_config').with_content(/^\s*http_proxy_host =/) }
- it { should_not contain_file('puppet_config').with_content(/^\s*http_proxy_port =/) }
- it { should contain_file('puppet_config').with_content(/^\ *report = true$/) }
- it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
- it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
- it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
- it { should_not contain_file('puppet_config').with_content(/environment = production/) }
- it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
- it { should_not contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
- it { should_not contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
- end
-
- ['false',false].each do |value|
- context "with is_puppet_master set to #{value} (default)" do
- let(:facts) do
- { :osfamily => 'RedHat',
- :fqdn => 'agent.example.com',
- }
- end
- let(:params) do
- { :env => 'production',
- :is_puppet_master => value,
- }
- end
-
- it { should contain_class('puppet::agent') }
-
- it { should contain_file('puppet_config').with({
- 'path' => '/etc/puppet/puppet.conf',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
-
- it { should contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
- it { should contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
- it { should contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
- it { should contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
- it { should contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
- it { should contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
- it { should contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
- it { should contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
- it { should contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
- it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
- it { should contain_file('puppet_config').with_content(/^\ *report = true$/) }
- it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
- it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
- it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
- it { should_not contain_file('puppet_config').with_content(/environment = production/) }
- it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
- end
- end
-
- ['true',true].each do |value|
- context "with is_puppet_master set to #{value}" do
- let(:facts) do
- { :osfamily => 'RedHat',
- :fqdn => 'agent.example.com',
- }
- end
- let(:params) do
- { :env => 'production',
- :is_puppet_master => value,
- }
- end
-
- it { should contain_class('puppet::agent') }
-
- it { should contain_file('puppet_config').with({
- 'path' => '/etc/puppet/puppet.conf',
- 'content' => nil,
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
- it { should_not contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
- it { should_not contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
- it { should_not contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
- it { should_not contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
- it { should_not contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
- it { should_not contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
- it { should_not contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
- it { should_not contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
- it { should_not contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
- it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
- it { should_not contain_file('puppet_config').with_content(/^\ *report = true$/) }
- it { should_not contain_file('puppet_config').with_content(/^\ *graph = true$/) }
- it { should_not contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
- it { should_not contain_file('puppet_config').with_content(/^\ *noop = false$/) }
- it { should_not contain_file('puppet_config').with_content(/environment = production/) }
- it { should_not contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
- end
- end
- end
-
- describe 'with run_interval' do
- ['29','30',30,'45',56].each do |value|
- context "set to #{value}" do
- let(:facts) do
- {
- :osfamily => 'RedHat',
- :fqdn => 'agent.learnpuppet.com',
- }
- end
- let(:params) do
- {
- :run_method => 'cron',
- :run_interval => value,
- :env => 'production',
- }
- end
-
- # Values here are from trial and error based on the fqdn above. Not
- # sure if it is possible to stub fqdn_rand()
- if value.to_s > '30'
- it {
- should contain_cron('puppet_agent').with({
- 'ensure' => 'present',
- 'minute' => 39,
- })
- }
- else
- it {
- should contain_cron('puppet_agent').with({
- 'ensure' => 'present',
- 'minute' => ['7', 37],
- })
- }
- end
- end
- end
-
- [true,false,{ 'k' => 'v'},['1','2']].each do |value|
- context "set to invalid value #{value}" do
- let(:facts) do
- {
- :osfamily => 'RedHat',
- :fqdn => 'agent.learnpuppet.com',
- }
- end
- let(:params) do
- {
- :run_method => 'cron',
- :run_interval => value,
- :env => 'production',
- }
- end
-
- it 'should fail' do
- expect {
- should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/^undefined method `to_i'/)
- end
- end
- end
- end
-
- let(:facts) { { :osfamily => 'RedHat' } }
- describe 'with ssldir' do
- ['/var/lib/puppet/ssl-test','/srv/puppet/ssl'].each do |value|
- context "set to valid #{value} (as #{value.class})" do
- let(:params) do
- {
- :ssldir => value,
- :env => 'production',
- }
- end
-
- it { should contain_file('puppet_config').with_content(/^\s*ssldir = #{Regexp.escape(value)}$/) }
- end
- end
-
- ['../../relative/path','',242,2.42,['array'],a={'ha'=>'sh'},true,nil].each do |value|
- context "set to invalid #{value} (as #{value.class})" do
- let(:params) do
- {
- :ssldir => value,
- :env => 'production',
- }
- end
-
- it 'should fail' do
- expect {
- should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/is not an absolute path/)
- end
- end
- end
- end
-
- describe 'with stringify_facts' do
- ['true',true].each do |value|
- context "set to #{value}" do
- let(:params) do
- {
- :stringify_facts => value,
- :env => 'production',
- }
- end
- let(:facts) { { :osfamily => 'RedHat' } }
-
- it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
- end
- end
-
- ['false',false].each do |value|
- context "set to #{value}" do
- let(:params) do
- {
- :stringify_facts => value,
- :env => 'production',
- }
- end
- let(:facts) { { :osfamily => 'RedHat' } }
-
- it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = false$/) }
- end
- end
-
- context 'set to an invalid setting' do
- let(:params) do
- {
- :stringify_facts => 'invalid',
- :env => 'production',
- }
- end
- let(:facts) { { :osfamily => 'RedHat' } }
-
- it 'should fail' do
- expect {
- should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean given/)
- end
- end
- end
-
- describe 'sysconfig file' do
- context 'Puppet agent sysconfig file on osfamily RedHat' do
- let(:facts) { { :osfamily => 'RedHat' } }
- let(:params) { { :env => 'production' } }
-
- it { should contain_class('puppet::agent') }
-
- it { should contain_file('puppet_agent_sysconfig').with({
- 'path' => '/etc/sysconfig/puppet',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
-
- it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
- end
-
- context 'Puppet agent sysconfig file on osfamily Debian' do
- let(:facts) do
- { :osfamily => 'Debian',
- :lsbdistid => 'Debian',
- }
- end
- let(:params) { { :env => 'production' } }
-
- it { should contain_class('puppet::agent') }
-
- it { should contain_file('puppet_agent_sysconfig').with({
- 'path' => '/etc/default/puppet',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
-
- it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
- end
-
- context 'Puppet agent sysconfig file on Ubuntu' do
- let(:facts) do
- { :osfamily => 'Debian',
- :lsbdistid => 'Ubuntu',
- }
- end
- let(:params) { { :env => 'production' } }
-
- it { should contain_class('puppet::agent') }
-
- it { should contain_file('puppet_agent_sysconfig').with({
- 'path' => '/etc/default/puppet',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
-
- it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
- end
-
- context 'Puppet agent sysconfig file on osfamily Solaris' do
- let(:facts) { { :osfamily => 'Solaris' } }
- let(:params) { { :env => 'production' } }
-
- it { should contain_class('puppet::agent') }
-
- it { should_not contain_file('puppet_agent_sysconfig') }
- end
-
- context 'Puppet agent sysconfig file on osfamily Suse' do
- let(:facts) { { :osfamily => 'Suse' } }
- let(:params) { { :env => 'production' } }
-
- it { should contain_class('puppet::agent') }
-
- it { should contain_file('puppet_agent_sysconfig').with({
- 'path' => '/etc/sysconfig/puppet',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
-
- it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
- end
-
- context 'Puppet agent sysconfig file on invalid osfamily' do
- let(:facts) { { :osfamily => 'invalid' } }
- let(:params) { { :env => 'production' } }
-
- it 'should fail' do
- expect {
- should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <invalid>./)
- end
- end
- end
-
- describe 'with symlink_puppet_binary' do
- ['true',true].each do |value|
- context "set to #{value} (default)" do
- let(:facts) { { :osfamily => 'Debian' } }
- let(:params) do
- { :env => 'production',
- :symlink_puppet_binary => value,
- }
- end
-
- it {
- should contain_file('puppet_symlink').with({
- 'path' => '/usr/local/bin/puppet',
- 'target' => '/usr/bin/puppet',
- 'ensure' => 'link',
- })
- }
- end
- end
-
- ['false',false].each do |value|
- context "set to #{value} (default)" do
- let(:facts) { { :osfamily => 'Debian' } }
- let(:params) do
- { :env => 'production',
- :symlink_puppet_binary => value,
- }
- end
-
- it { should_not contain_file('puppet_symlink') }
- end
- end
-
- context 'enabled with all params specified' do
- let(:facts) { { :osfamily => 'Debian' } }
- let(:params) do
- { :env => 'production',
- :symlink_puppet_binary => true,
- :puppet_binary => '/foo/bar',
- :symlink_puppet_binary_target => '/bar',
- }
- end
-
- it {
- should contain_file('puppet_symlink').with({
- 'path' => '/bar',
- 'target' => '/foo/bar',
- 'ensure' => 'link',
- })
- }
- end
-
- context 'enabled with invalid puppet_binary' do
- let(:facts) { { :osfamily => 'Debian' } }
- let(:params) { {:env => 'production',
- :symlink_puppet_binary => true,
- :puppet_binary => 'invalid/path',
- :symlink_puppet_binary_target => '/bar' } }
-
- it 'should fail' do
- expect {
- should contain_class('puppet::master')
- }.to raise_error(Puppet::Error,/^"invalid\/path" is not an absolute path./)
- end
- end
-
- context 'enabled with invalid symlink_puppet_binary_target' do
- let(:facts) { { :osfamily => 'Debian' } }
- let(:params) { {:env => 'production',
- :symlink_puppet_binary => true,
- :puppet_binary => '/foo/bar',
- :symlink_puppet_binary_target => 'invalid/path' } }
-
- it 'should fail' do
- expect {
- should contain_class('puppet::master')
- }.to raise_error(Puppet::Error,/^"invalid\/path" is not an absolute path./)
- end
- end
- end
-
- describe 'with run_method' do
- context 'set to disable' do
- let(:facts) { { :osfamily => 'RedHat' } }
- let(:params) do
- { :run_method => 'disable',
- :env => 'production',
- }
- end
-
- it { should contain_class('puppet::agent') }
-
- it { should contain_cron('puppet_agent').with({
- 'ensure' => 'absent'
- })
- }
-
- it { should_not contain_cron('puppet_agent_once_at_boot') }
-
- it { should contain_service('puppet_agent_daemon').with({
- 'enable' => false,
- })
- }
- end
-
- context 'set to service' do
- let(:facts) { { :osfamily => 'RedHat' } }
- let(:params) do
- { :run_method => 'service',
- :env => 'production',
- }
- end
-
- it { should contain_class('puppet::agent') }
-
- it { should contain_cron('puppet_agent').with({
- 'ensure' => 'absent'
- })
- }
-
- it { should_not contain_cron('puppet_agent_once_at_boot') }
-
- it { should contain_service('puppet_agent_daemon').with({
- 'enable' => true,
- })
- }
- end
-
- context 'set to cron' do
-
- context 'with run_in_noop set to non-string and non-boolean' do
- let(:facts) { { :osfamily => 'RedHat' } }
- let(:params) do
- { :run_method => 'cron',
- :env => 'production',
- :run_in_noop => ['invalid_type','not_a_string','not_a_boolean'],
- }
- end
-
- it 'should fail' do
- expect {
- should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/^\["invalid_type", "not_a_string", "not_a_boolean"\] is not a boolean./)
- end
-
- end
-
- context 'with run_in_noop set to invalid string' do
- let(:facts) { { :osfamily => 'RedHat' } }
- let(:params) do
- { :run_method => 'cron',
- :env => 'production',
- :run_in_noop => 'invalid_string',
- }
- end
-
- it 'should fail' do
- expect {
- should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean given/)
- end
- end
-
- cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
-
- # iterate through a matrix of setting true and false as booleans and
- # strings for both run_in_noop and run_at_boot.
- ['true',true,'false',false].each do |rin_value|
- context "with run_in_noop => #{rin_value}" do
- ['true',true,'false',false].each do |rab_value|
- context "and run_at_boot => #{rab_value}" do
- let(:facts) { { :osfamily => 'RedHat' } }
- let(:params) do
- { :run_method => 'cron',
- :env => 'production',
- :run_in_noop => rin_value,
- :run_at_boot => rab_value,
- }
- end
-
- if rin_value == true or rin_value == 'true' then
- command = "#{cron_command} --noop"
- else
- command = cron_command
- end
-
- if rab_value == true or rab_value == 'true' then
- at_boot_ensure = 'present'
- else
- at_boot_ensure = 'absent'
- end
-
- it { should contain_class('puppet::agent') }
-
- it {
- should contain_cron('puppet_agent').with({
- 'ensure' => 'present',
- 'user' => 'root',
- 'command' => command,
- })
- }
-
- it { should contain_cron('puppet_agent_once_at_boot').with({
- 'ensure' => at_boot_ensure,
- 'user' => 'root',
- 'command' => command,
- 'special' => 'reboot',
- })
- }
- end
- end
- end
- end
- end
- end
-
- describe 'with puppet_masterport' do
- context 'set to integer' do
- let(:facts) { { :osfamily => 'RedHat' } }
- let(:params) do
- { :puppet_masterport => '8888',
- :env => 'production',
- }
- end
-
- it { should contain_class('puppet::agent') }
- it { should contain_file('puppet_config').with_content(/^\s*masterport = 8888$/) }
- end
-
- context 'set to a string that is not an integer (foo)' do
- let(:facts) { { :osfamily => 'RedHat' } }
- let(:params) do
- { :puppet_masterport => 'foo',
- :env => 'production',
- }
- end
-
- it 'should fail' do
- expect {
- should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/puppet::agent::puppet_masterport is set to <foo>. It should be an integer./)
- end
- end
-
- context 'set to an invalid type (non-string)' do
- let(:facts) { { :osfamily => 'RedHat' } }
- let(:params) do
- { :puppet_masterport => ['invalid','type'],
- :env => 'production',
- }
- end
-
- it 'should fail' do
- expect {
- should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/puppet::agent::puppet_masterport is set to <invalidtype>\. It should be an integer\./)
- end
- end
- end
-
- describe 'with etckeeper_hooks' do
- ['true',true].each do |value|
- context "set to #{value}" do
- let(:params) do
- {
- :etckeeper_hooks => value,
- :env => 'production',
- }
- end
- let(:facts) { { :osfamily => 'RedHat' } }
-
- it { should contain_file('etckeeper_pre') }
- it { should contain_file('etckeeper_post') }
- it { should contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
- it { should contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
- end
- end
-
- ['false',false].each do |value|
- context "set to #{value}" do
- let(:params) do
- {
- :etckeeper_hooks => value,
- :env => 'production',
- }
- end
- let(:facts) { { :osfamily => 'RedHat' } }
-
- it { should_not contain_file('etckeeper_pre') }
- it { should_not contain_file('etckeeper_post') }
- it { should_not contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
- it { should_not contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
- end
- end
-
- context 'set to an invalid setting' do
- let(:params) do
- {
- :etckeeper_hooks => 'invalid',
- :env => 'production',
- }
- end
- let(:facts) { { :osfamily => 'RedHat' } }
-
- it 'should fail' do
- expect {
- should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean given/)
- end
- end
- end
-
- describe 'with http_proxy_host' do
- context 'set to a valid domain' do
- let(:facts) { { :osfamily => 'RedHat' } }
- let(:params) do
- { :http_proxy_host => 'proxy.host.local.domain',
- :env => 'production',
- }
- end
- it { should contain_class('puppet::agent') }
- it {should contain_file('puppet_config').with_content(/^\s*http_proxy_host = proxy\.host\.local\.domain$/) }
- end
-
- ['8.8.8.8','2a00:1450:400f:804::1011'].each do |ip_address|
- context "set to #{ip_address} (ip-address)" do
- let(:facts) { { :osfamily => 'RedHat' } }
- let(:params) do
- { :env => 'production',
- :http_proxy_host => ip_address,
- }
- end
-
- it { should contain_file('puppet_config').with_content(/\s*http_proxy_host = #{Regexp.escape(ip_address)}$/) }
- end
- end
- ['8.8.8.8.#','".#.%.!','foo..bar'].each do |invalid_value|
- context "set to #{invalid_value} (invalid value)" do
- let(:facts) { { :osfamily => 'RedHat' } }
- let(:params) do
- { :env => 'production',
- :http_proxy_host => invalid_value,
- }
- end
- it 'should fail' do
- expect {
- should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/puppet::agent::http_proxy_host is set to <#{Regexp.escape(invalid_value)}>. It should be a fqdn or an ip-address./)
- end
- end
- end
- context 'set to an invalid type' do
- let(:facts) { { :osfamily => 'RedHat' } }
- let(:params) do
- { :http_proxy_host => ['invalid','type'],
- :env => 'production',
- }
- end
- it 'should fail' do
- expect {
- should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/puppet::agent::http_proxy_host is set to <invalidtype>\. It should be a fqdn or an ip-address\./)
- end
- end
- end
-
-
- describe 'with http_proxy_port' do
- context 'set to integer' do
- let(:facts) { { :osfamily => 'RedHat' } }
- let(:params) do
- { :http_proxy_port => '8888',
- :env => 'production',
- }
- end
- it { should contain_class('puppet::agent') }
- it { should contain_file('puppet_config').with_content(/^\s*http_proxy_port = 8888$/) }
- end
- context 'set to an invalid type' do
- let(:facts) { { :osfamily => 'RedHat' } }
- let(:params) do
- { :http_proxy_port => ['invalid','type'],
- :env => 'production',
- }
- end
- it 'should fail' do
- expect {
- should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/puppet::agent::http_proxy_port is set to <invalidtype>\. It should be an Integer\./)
- end
- end
- context 'set to an invalid value' do
- let(:facts) { { :osfamily => 'RedHat' } }
- let(:params) do
- { :http_proxy_port => 'foo',
- :env => 'production',
- }
- end
- it 'should fail' do
- expect {
- should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/puppet::agent::http_proxy_port is set to <foo>. It should be an Integer./)
- end
- end
- end
-end
diff --git a/spec/classes/dashboard_maintenance_spec.rb b/spec/classes/dashboard_maintenance_spec.rb
deleted file mode 100644
index a8772ed..0000000
--- a/spec/classes/dashboard_maintenance_spec.rb
+++ /dev/null
@@ -1,377 +0,0 @@
-require 'spec_helper'
-describe 'puppet::dashboard::maintenance' do
-
- describe 'class puppet::dashboard::maintenance' do
-
- context 'with database dump dir as default value on osfamily RedHat' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- }
- end
-
- it { should contain_class('puppet::dashboard::maintenance') }
-
- it { should contain_file('/var/local').with({
- 'ensure' => 'directory',
- 'group' => 'puppet-dashboard',
- 'mode' => '0775',
- })
- }
- end
-
- context 'with database dump dir as default value on osfamily Debian' do
- let(:facts) do
- { :osfamily => 'Debian',
- :operatingsystemrelease => '6.0.8',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- }
- end
-
- it { should contain_class('puppet::dashboard::maintenance') }
-
- it { should contain_file('/var/local').with({
- 'ensure' => 'directory',
- 'group' => 'puppet',
- 'mode' => '0775',
- })
- }
- end
-
- context 'with database dump dir specified' do
- let(:params) { {:dump_dir => '/foo/bar'} }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- }
- end
-
- it { should contain_class('puppet::dashboard::maintenance') }
-
- it { should contain_file('/foo/bar').with({
- 'ensure' => 'directory',
- 'mode' => '0775',
- })
- }
- end
-
- context 'with database dump dir specified as invalid value' do
- let(:params) { {:dump_dir => 'invalid/path/statement'} }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- }
- end
-
- it do
- expect {
- should contain_class('puppet::dashboard::maintenance')
- }.to raise_error(Puppet::Error,/^"invalid\/path\/statement" is not an absolute path./)
- end
- end
-
- context 'Dashboard database optimization' do
- let(:params) { {:db_optimization_command => '/foo/bar' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- :operatingsystemrelease => '6.4',
- }
- end
-
- it { should contain_class('puppet::dashboard::maintenance') }
-
- it { should contain_cron('monthly_dashboard_database_optimization').with({
- 'command' => '/foo/bar',
- 'user' => 'root',
- 'hour' => '0',
- 'minute' => '0',
- 'monthday' => '1',
- })
- }
- end
-
- context 'Dashboard database purge reports' do
- let(:params) { {:purge_old_reports_command => '/foo/bar' }}
- let(:facts) do
- { :osfamily => 'RedHat',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- :operatingsystemrelease => '6.4',
- }
- end
-
- it { should contain_class('puppet::dashboard::maintenance') }
-
- it { should contain_cron('purge_old_reports').with({
- 'command' => '/foo/bar',
- 'user' => 'root',
- 'hour' => '0',
- 'minute' => '30',
- })
- }
- end
-
- context 'Dashboard spool remove reports with remove_old_reports_spool set to invalid string' do
- let(:params) { {:remove_old_reports_spool => 'invalid_string' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- :operatingsystemrelease => '6.4',
- }
- end
-
- it do
- expect {
- should contain_class('puppet::dashboard::maintenance')
- }.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean/)
- end
- end
-
- context 'Dashboard spool remove reports with remove_old_reports_spool set to invalid type - non-boolean and non-string' do
- let(:params) { {:remove_old_reports_spool => ['invalid_type','not_a_string','not_a_boolean'] } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- :operatingsystemrelease => '6.4',
- }
- end
-
- it do
- expect {
- should contain_class('puppet::dashboard::maintenance')
- }.to raise_error(Puppet::Error,/^\["invalid_type", "not_a_string", "not_a_boolean"\] is not a boolean./)
- end
- end
-
- [true,'true'].each do |value|
- context "Dashboard spool remove reports with remove_old_reports_spool set to #{value}" do
- let(:params) { {:remove_old_reports_spool => value } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- :operatingsystemrelease => '6.4',
- }
- end
-
- it { should contain_class('puppet::dashboard::maintenance') }
- it { should contain_cron('remove_old_reports_spool').with({
- 'command' => '/bin/find /usr/share/puppet-dashboard/spool -type f -name "*.yaml" -mtime +7 -exec /bin/rm -f {} \;',
- 'ensure' => 'present',
- 'user' => 'root',
- 'hour' => '0',
- 'minute' => '45',
- })
- }
- end
- end
-
- context 'Dashboard spool remove reports with params set' do
- let(:params) { {:remove_old_reports_spool => 'true',
- :remove_reports_spool_user => 'user',
- :remove_reports_spool_hour => '5',
- :remove_reports_spool_minute => '6',
- :reports_spool_dir => '/tmp/foo',
- :reports_spool_days_to_keep => '10' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- :operatingsystemrelease => '6.4',
- }
- end
-
- it { should contain_class('puppet::dashboard::maintenance') }
-
- it { should contain_cron('remove_old_reports_spool').with({
- 'ensure' => 'present',
- 'command' => '/bin/find /tmp/foo -type f -name "*.yaml" -mtime +10 -exec /bin/rm -f {} \;',
- 'user' => 'user',
- 'hour' => '5',
- 'minute' => '6',
- })
- }
- end
-
- [false,'false'].each do |value|
- context "Dashboard spool remove reports with remove_old_reports_spool set to #{value}" do
- let(:params) { {:remove_old_reports_spool => value } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- :operatingsystemrelease => '6.4',
- }
- end
-
- it { should contain_class('puppet::dashboard::maintenance') }
-
- it { should contain_cron('remove_old_reports_spool').with({
- 'ensure' => 'absent',
- })
- }
- end
- end
-
- context 'with reports_spool_dir set to an invalid path' do
- let(:params) { {:reports_spool_dir=> 'invalid/path/statement' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- :operatingsystemrelease => '6.4',
- }
- end
-
- it do
- expect {
- should contain_class('puppet::dashboard::maintenance')
- }.to raise_error(Puppet::Error,/^"invalid\/path\/statement" is not an absolute path./)
- end
- end
-
- context 'with dump_database_command set to default value on osfamily RedHat' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- :operatingsystemrelease => '6.4',
- }
- end
-
- it { should contain_class('puppet::dashboard::maintenance') }
-
- it { should contain_cron('dump_dashboard_database').with({
- 'command' => 'cd ~puppet-dashboard && sudo -u puppet-dashboard /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1',
- 'user' => 'root',
- 'hour' => '1',
- 'minute' => '0',
- })
- }
- end
-
- context 'with dump_database_command set to default value on osfamily Debian' do
- let(:facts) do
- { :osfamily => 'Debian',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- :operatingsystemrelease => '6.0.8',
- }
- end
-
- it { should contain_class('puppet::dashboard::maintenance') }
-
- it { should contain_cron('dump_dashboard_database').with({
- 'command' => 'cd ~puppet-dashboard && sudo -u puppet /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1',
- 'user' => 'root',
- 'hour' => '1',
- 'minute' => '0',
- })
- }
- end
-
- describe 'with dump_database_command specified' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- :operatingsystemrelease => '6.4',
- }
- end
-
- ['/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=12 unit=hours','/foo/bar'].each do |value|
- context "to valid #{value} (as #{value.class})" do
- let (:params) {{'dump_database_command' => value }}
-
- it { should contain_cron('dump_dashboard_database').with({
- 'command' => "#{value}",
- 'user' => 'root',
- 'hour' => '1',
- 'minute' => '0',
- })
- }
- end
- end
-
- [true,['array'],a = { 'ha' => 'sh' }].each do |value|
- context "to invalid #{value} (as #{value.class})" do
- let (:params) {{'dump_database_command' => value }}
-
- it 'should fail' do
- expect {
- should contain_class('puppet::dashboard::maintenance')
- }.to raise_error(Puppet::Error,/is not a string. It looks to be a/)
- end
- end
- end
-
- end
-
- describe 'with reports_days_to_keep specified' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- :operatingsystemrelease => '6.4',
- }
- end
-
- [242,'42'].each do |value|
- context "to valid #{value} (as #{value.class})" do
- let (:params) {{'reports_days_to_keep' => value }}
-
- it { should contain_cron('purge_old_reports').with({
- 'command' => "/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=#{value} unit=day >> /var/log/puppet/dashboard_maintenance.log",
- 'user' => 'root',
- 'hour' => '0',
- 'minute' => '30',
- })
- }
- end
- end
-
- [2.42,true,'string',['array'],a = { 'ha' => 'sh' }].each do |value|
- context "to invalid #{value} (as #{value.class})" do
- let (:params) {{'reports_days_to_keep' => value }}
-
- it 'should fail' do
- expect {
- should contain_class('puppet::dashboard::maintenance')
- }.to raise_error(Puppet::Error,/validate_integer\(\)/)
- end
- end
- end
-
- end
-
- context 'Dashboard database backup cleanup' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :concat_basedir => '/tmp',
- :max_allowed_packet => 32,
- :operatingsystemrelease => '6.4',
- }
- end
-
- it { should contain_class('puppet::dashboard::maintenance') }
-
- it { should contain_cron('purge_old_db_backups').with({
- 'user' => 'root',
- 'hour' => '2',
- 'minute' => '0',
- })
- }
- end
- end
-end
diff --git a/spec/classes/dashboard_server_spec.rb b/spec/classes/dashboard_server_spec.rb
deleted file mode 100644
index e8e8d49..0000000
--- a/spec/classes/dashboard_server_spec.rb
+++ /dev/null
@@ -1,523 +0,0 @@
-require 'spec_helper'
-
-describe 'puppet::dashboard::server' do
-
- context 'with default dashboard_workers on osfamily RedHat' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should_not contain_file('dashboard_workers_default') }
- end
-
- context 'with default dashboard_workers on osfamily Debian' do
- let(:facts) do
- { :osfamily => 'Debian',
- :operatingsystemrelease => '6.0.8',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_file('dashboard_workers_default').with({
- 'ensure' => 'file',
- 'path' => '/etc/default/puppet-dashboard-workers',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
-
- it { should contain_file('dashboard_workers_default').with_content(/^START=yes$/) }
- it { should contain_file('dashboard_workers_default').with_content(/^NUM_DELAYED_JOB_WORKERS=8$/) }
- end
-
- context 'with default dashboard_workers set to non-digit' do
- let(:params) { { :dashboard_workers => '8invalid' } }
- let(:facts) do
- { :osfamily => 'Debian',
- :operatingsystemrelease => '6.0.8',
- :ports_file => '/etc/httpd/ports.conf"',
- :concat_basedir => '/tmp',
- }
- end
-
- it do
- expect {
- should contain_class('puppet::dashboard')
- }.to raise_error(Puppet::Error,/puppet::dashboard::server::dashboard_workers must be a digit. Detected value is <8invalid>./)
- end
-
- end
-
- context 'with default htpasswd path on osfamily RedHat' do
- let(:params) do
- { :security => 'htpasswd',
- :htpasswd => {
- 'gh' => {
- 'cryptpasswd' => 'password',
- },
- }
- }
- end
-
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_file('dashboard_htpasswd_path').with({
- 'ensure' => 'file',
- 'path' => '/etc/puppet/dashboard.htpasswd',
- 'owner' => 'root',
- 'group' => 'apache',
- 'mode' => '0640',
- })
- }
- end
-
- context 'with default htpasswd path on osfamily Debian' do
- let(:params) do
- { :security => 'htpasswd',
- :htpasswd => {
- 'gh' => {
- 'cryptpasswd' => 'password',
- },
- }
- }
- end
- let(:facts) do
- { :osfamily => 'Debian',
- :operatingsystemrelease => '6.0.8',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_file('dashboard_htpasswd_path').with({
- 'ensure' => 'file',
- 'path' => '/etc/puppet/dashboard.htpasswd',
- 'owner' => 'root',
- 'group' => 'www-data',
- 'mode' => '0640',
- })
- }
- end
-
- context 'with htpasswd_path set by user' do
- let(:params) do
- { :htpasswd_path => '/var/www/html/dashboard_passwd',
- :security => 'htpasswd',
- :htpasswd => {
- 'gh' => {
- 'cryptpasswd' => 'password',
- },
- }
- }
- end
- let(:facts) do
- { :osfamily => 'Debian',
- :operatingsystemrelease => '6.0.8',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_file('dashboard_htpasswd_path').with({
- 'ensure' => 'file',
- 'path' => '/var/www/html/dashboard_passwd',
- 'owner' => 'root',
- 'group' => 'www-data',
- 'mode' => '0640',
- })
- }
- end
-
- context 'with invalid value for htpasswd_path' do
- let(:params) do
- { :htpasswd_path => 'not/a/valid/path',
- :security => 'htpasswd',
- :htpasswd => {
- 'gh' => {
- 'cryptpasswd' => 'password',
- },
- }
- }
- end
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- :domain => 'example.com',
- }
- end
-
- it do
- expect {
- should contain_class('puppet::dashboard')
- }.to raise_error(Puppet::Error,/^"not\/a\/valid\/path" is not an absolute path./)
- end
- end
-
- [false,'false'].each do |value|
- context "with manage_mysql_options set to <#{value}>" do
- let(:params) { { :manage_mysql_options => "#{value}" } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :processorcount => '8',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_class('mysql::server').with({'override_options' => {},}) }
-
- it { should_not contain_file('/etc/my.cnf').with_content(/^max_allowed_packet = 32M$/) }
-
- end
- end
-
- [true,'true'].each do |value|
- context "with manage_mysql_options set to <#{value}>" do
- let(:params) { { :manage_mysql_options => "#{value}" } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :processorcount => '8',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_file('/etc/my.cnf').with_content(/^max_allowed_packet = 32M$/) }
-
- it {
- should contain_class('mysql::server').with({
- 'override_options' => {
- 'mysqld' => {
- 'max_allowed_packet' => '32M',
- },
- },
- })
- }
-
- end
- end
-
- ['invalid',[ 'dont', 'like', 'arrays', ], { 'nor' => 'hashes', }, ].each do |value|
- context "with manage_mysql_options set to invalid value <#{value}>" do
- let(:params) { { :manage_mysql_options => "#{value}" } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :processorcount => '8',
- }
- end
-
- it do
- expect {
- should contain_class('puppet::dashboard')
- }.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean/)
- end
- end
- end
-
- describe 'Dashboard vhost configuration file content' do
- context 'when vhost_path is invalid it should fail' do
- let(:params) { { :vhost_path => 'not/a/valid/path' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- :domain => 'example.com',
- }
- end
-
- it do
- expect {
- should contain_class('puppet::dashboard')
- }.to raise_error(Puppet::Error,/^"not\/a\/valid\/path" is not an absolute path./)
- end
- end
-
- context 'when htpasswd_path is invalid it should fail' do
- let(:params) { { :htpasswd_path => 'not/a/valid/path' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- :domain => 'example.com',
- }
- end
-
- it do
- expect {
- should contain_class('puppet::dashboard')
- }.to raise_error(Puppet::Error,/^"not\/a\/valid\/path" is not an absolute path./)
- end
- end
-
- context 'when security is invalid it should fail' do
- let(:params) { { :security => 'invalid' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- :domain => 'example.com',
- }
- end
-
- it do
- expect {
- should contain_class('puppet::dashboard')
- }.to raise_error(Puppet::Error,/Security is <invalid> which does not match regex. Valid values are none and htpasswd./)
- end
- end
-
- context 'with default settings' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- :domain => 'example.com',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_file('dashboard_vhost').with_content(/^\s*ServerName puppet.example.com$/) }
- end
-
- context 'with security set to none' do
- let(:params) { { :security => 'none' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_file('dashboard_vhost') }
-
- it { should_not contain_file('dashboard_vhost').with_content(/(\s+|)AuthType(\s+)basic(\s*)/) }
- end
-
- context 'with security set to htpasswd' do
- let(:params) { { :security => 'htpasswd' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_file('dashboard_vhost').with_content(/(\s+|)AuthType(\s+)basic(\s*)/) }
- end
- end
-
- context 'with database configuration file on osfamily RedHat' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_file('database_config').with({
- 'path' => '/usr/share/puppet-dashboard/config/database.yml',
- 'owner' => 'puppet-dashboard',
- 'group' => 'puppet-dashboard',
- 'mode' => '0640',
- 'require' => 'Package[puppet-dashboard]',
- })
- }
- end
-
- context 'with database configuration file on osfamily Debian' do
- let(:facts) do
- { :osfamily => 'Debian',
- :operatingsystemrelease => '6.0.8',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_file('database_config').with({
- 'path' => '/usr/share/puppet-dashboard/config/database.yml',
- 'owner' => 'puppet',
- 'group' => 'www-data',
- 'mode' => '0640',
- 'require' => 'Package[puppet-dashboard]',
- })
- }
- end
-
- context 'Dashboard database configuration file content' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_file('database_config').with_content(/^\s*username: dashboard$/) }
- end
-
- context 'Dashboard vhost configuration file on osfamily RedHat' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- :domain => 'example.com',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_file('dashboard_vhost').with({
- 'ensure' => 'file',
- 'path' => '/etc/httpd/conf.d/dashboard.conf',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
- end
-
- context 'Dashboard vhost configuration file on osfamily Debian' do
- let(:facts) do
- { :osfamily => 'Debian',
- :operatingsystemrelease => '6.0.8',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- :domain => 'example.com',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_file('dashboard_vhost').with({
- 'ensure' => 'file',
- 'path' => '/etc/apache2/sites-enabled/puppetdashboard',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
- end
-
- context 'Dashboard Mysql Database' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_mysql__db('dashboard').with({
- 'user' => 'dashboard',
- 'password' => 'puppet',
- 'host' => 'localhost',
- })
- }
- end
-
- context 'Dashboard database migration' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_exec('migrate_dashboard_database').with({
- 'command' => 'rake RAILS_ENV=production db:migrate',
- 'path' => '/bin:/usr/bin:/sbin:/usr/sbin',
- 'cwd' => '/usr/share/puppet-dashboard',
- 'refreshonly' => true,
- })
- }
- end
-
- context 'Dashboard workers service' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :processorcount => '8',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard::server') }
-
- it { should contain_service('puppet-dashboard-workers').with({
- 'ensure' => 'running',
- 'enable' => true,
- })
- }
- end
-end
diff --git a/spec/classes/dashboard_spec.rb b/spec/classes/dashboard_spec.rb
deleted file mode 100644
index bd89421..0000000
--- a/spec/classes/dashboard_spec.rb
+++ /dev/null
@@ -1,256 +0,0 @@
-require 'spec_helper'
-describe 'puppet::dashboard' do
-
- describe 'class puppet::dashboard' do
- describe 'with dashboard_package set' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :concat_basedir => '/tmp',
- }
- end
- context 'to a string' do
- let(:params) { {:dashboard_package => 'puppet-dashboard' } }
-
- it { should contain_class('puppet::dashboard') }
-
- it { should contain_package('puppet-dashboard').with({
- 'ensure' => 'present',
- })
- }
- end
-
- context 'to an array' do
- let(:params) { {:dashboard_package => ['puppet-dashboard','pdb-somethingelse'] } }
-
- it { should contain_class('puppet::dashboard') }
-
- it { should contain_package('puppet-dashboard').with({
- 'ensure' => 'present',
- })
- }
-
- it { should contain_package('pdb-somethingelse').with({
- 'ensure' => 'present',
- })
- }
- end
-
- context 'to an invalid type (boolean)' do
- let(:params) { {:dashboard_package => true } }
-
- it 'should fail' do
- expect {
- should contain_class('puppet::dashboard')
- }.to raise_error(Puppet::Error,/puppet::dashboard::dashboard_package must be a string or an array./)
- end
- end
- end
-
- context 'external_node_script on osfamily RedHat with default options' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard') }
-
- it { should contain_file('external_node_script').with({
- 'ensure' => 'file',
- 'path' => '/usr/share/puppet-dashboard/bin/external_node',
- 'owner' => 'puppet-dashboard',
- 'group' => 'puppet-dashboard',
- 'mode' => '0755',
- 'require' => 'Package[puppet-dashboard]',
- })
- }
- end
-
- context 'external_node_script on osfamily Debian with default options' do
- let(:facts) do
- { :osfamily => 'Debian',
- :operatingsystemrelease => '6.0.8',
- :ports_file => '/etc/httpd/ports.conf"',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard') }
-
- it { should contain_file('external_node_script').with({
- 'ensure' => 'file',
- 'path' => '/usr/share/puppet-dashboard/bin/external_node',
- 'owner' => 'puppet',
- 'group' => 'puppet',
- 'mode' => '0755',
- 'require' => 'Package[puppet-dashboard]',
- })
- }
- end
-
- context 'external_node_script with non-default external_node_script specified' do
- let(:params) { { :external_node_script_path => '/opt/local/puppet-dashboard/bin/external_node' } }
- let(:facts) do
- { :osfamily => 'Debian',
- :operatingsystemrelease => '6.0.8',
- :ports_file => '/etc/httpd/ports.conf"',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard') }
-
- it { should contain_file('external_node_script').with({
- 'ensure' => 'file',
- 'path' => '/opt/local/puppet-dashboard/bin/external_node',
- 'owner' => 'puppet',
- 'group' => 'puppet',
- 'mode' => '0755',
- 'require' => 'Package[puppet-dashboard]',
- })
- }
- end
-
- context 'external_node_script with invalid path specified' do
- let(:params) { { :external_node_script_path => 'invalid/path/statement' } }
- let(:facts) do
- { :osfamily => 'Debian',
- :operatingsystemrelease => '6.0.8',
- :ports_file => '/etc/httpd/ports.conf"',
- :concat_basedir => '/tmp',
- }
- end
-
- it 'should fail' do
- expect {
- should contain_class('puppet::dashboard')
- }.to raise_error(Puppet::Error,/^"invalid\/path\/statement" is not an absolute path./)
- end
- end
-
- context 'Dashboard sysconfig file on osfamily RedHat' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard') }
-
- it { should contain_file('dashboard_sysconfig').with({
- 'ensure' => 'file',
- 'path' => '/etc/sysconfig/puppet-dashboard',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
-
- it { should contain_file('dashboard_sysconfig').with_content(/^DASHBOARD_PORT=3000$/) }
- end
-
- context 'Dashboard sysconfig file on osfamily Debian' do
- let(:facts) do
- { :osfamily => 'Debian',
- :operatingsystemrelease => '7',
- :ports_file => '/etc/httpd/ports.conf"',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard') }
-
- it { should contain_file('dashboard_sysconfig').with({
- 'ensure' => 'file',
- 'path' => '/etc/default/puppet-dashboard',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
-
- it { should_not contain_file('dashboard_sysconfig').with_content(/^START=yes$/) }
- it { should contain_file('dashboard_sysconfig').with_content(/^DASHBOARD_HOME=\/usr\/share\/puppet-dashboard$/) }
- it { should contain_file('dashboard_sysconfig').with_content(/^DASHBOARD_USER=www-data$/) }
- it { should contain_file('dashboard_sysconfig').with_content(/^DASHBOARD_RUBY=\/usr\/bin\/ruby$/) }
- it { should contain_file('dashboard_sysconfig').with_content(/^DASHBOARD_ENVIRONMENT=production$/) }
- it { should contain_file('dashboard_sysconfig').with_content(/^DASHBOARD_IFACE=0.0.0.0$/) }
- it { should contain_file('dashboard_sysconfig').with_content(/^DASHBOARD_PORT=3000$/) }
- end
-
- context 'Dashboard sysconfig file on invalid osfamily' do
- let(:facts) do
- { :osfamily => 'invalid',
- :operatingsystemrelease => '7',
- :ports_file => '/etc/httpd/ports.conf"',
- :concat_basedir => '/tmp',
- }
- end
-
- it 'should fail' do
- expect {
- should contain_class('puppet::dashboard')
- }.to raise_error(Puppet::Error,/puppet::dashboard supports osfamilies Debian and RedHat. Detected osfamily is <invalid>./)
- end
- end
-
- context 'Dashboard sysconfig specified with invalid path' do
- let(:params) { { :sysconfig_path => 'invalid/path/statement' } }
- let(:facts) do
- { :osfamily => 'Debian',
- :operatingsystemrelease => '7',
- :ports_file => '/etc/httpd/ports.conf"',
- :concat_basedir => '/tmp',
- }
- end
-
- it 'should fail' do
- expect {
- should contain_class('puppet::dashboard')
- }.to raise_error(Puppet::Error,/^"invalid\/path\/statement" is not an absolute path./)
- end
- end
-
- context 'Dashboard service' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard') }
-
- it { should contain_service('puppet-dashboard').with({
- 'ensure' => 'stopped',
- 'enable' => false,
- })
- }
- end
-
- context 'Dashboard workers service' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :ports_file => '/etc/httpd/ports.conf"',
- :concat_basedir => '/tmp',
- }
- end
-
- it { should contain_class('puppet::dashboard') }
-
- it { should contain_service('puppet-dashboard-workers').with({
- 'ensure' => 'stopped',
- 'enable' => false,
- })
- }
- end
- end
-end
diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb
index 1070d1b..9eece6e 100644
--- a/spec/classes/init_spec.rb
+++ b/spec/classes/init_spec.rb
@@ -1,9 +1,271 @@
require 'spec_helper'
describe 'puppet' do
+ # fqdn_rand() entries will always return this
+ minute = [2, 32]
- describe 'class puppet' do
+ # Filter out duplicate platforms
+ platforms = on_supported_os.select { |k, _v| !k.to_s.match(/^(RedHat|Scientific|OracleLinux)/i) }
+ platforms.each do |os, facts|
+ context "on #{os} with default values for parameters" do
+ let(:facts) do
+ facts
+ end
+ it { is_expected.to compile.with_all_deps }
+ it { should contain_class('puppet') }
+ it { should_not contain_file('puppetserver_sysconfig') }
+ it { should_not contain_service('puppetserver') }
+ it { should_not contain_class('puppet::server') }
+
+ it do
+ should contain_cron('puppet_agent_every_thirty').with({
+ :ensure => 'present',
+ :command => '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay --noop',
+ :user => 'root',
+ :hour => '*',
+ #:minute => [16,46],
+ :minute => minute,
+ })
+ end
+
+ it do
+ should contain_cron('puppet_agent_once_at_boot').with({
+ :ensure => 'present',
+ :command => '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay --noop',
+ :user => 'root',
+ :special => 'reboot',
+ })
+ end
+
+ ini_settings = {
+ 'server' => 'puppet',
+ 'ca_server' => 'puppet',
+ 'certname' => 'puppet.example.com',
+ 'environment' => 'rp_env',
+ 'trusted_node_data' => true,
+ 'graph' => false,
+ 'archive_files' => false,
+ 'archive_file_server' => 'puppet',
+ }
+
+ ini_settings.each do |setting, value|
+ it do
+ should contain_ini_setting(setting).with({
+ :ensure => 'present',
+ :setting => setting,
+ :value => value,
+ :path => '/etc/puppetlabs/puppet/puppet.conf',
+ :section => 'main',
+ :require => 'File[puppet_config]',
+ })
+ end
+ end
+
+ it do
+ should contain_file('puppet_config').with({
+ :ensure => 'file',
+ :path => '/etc/puppetlabs/puppet/puppet.conf',
+ :owner => 'root',
+ :group => 'root',
+ :mode => '0644',
+ })
+ end
+
+ puppet_agent_sysconfig = File.read(fixtures('puppet_agent_sysconfig'))
+ it do
+ should contain_file('puppet_agent_sysconfig').with({
+ :ensure => 'file',
+ :path => '/etc/sysconfig/puppet',
+ :content => puppet_agent_sysconfig,
+ :owner => 'root',
+ :group => 'root',
+ :mode => '0644',
+ })
+ end
+
+ it do
+ should contain_service('puppet_agent_daemon').with({
+ :ensure => 'stopped',
+ :name => 'puppet',
+ :enable => false,
+ })
+ end
+ end
+ end
+
+ describe 'with run_every_thirty' do
+ [true, 'true', false, 'false'].each do |value|
+ [true, 'true', false, 'false'].each do |noop_value|
+ context "set to #{value} (as #{value.class}) and run_in_noop set to #{noop_value} (as #{noop_value.class})" do
+ let(:params) do
+ {
+ :run_every_thirty => value,
+ :run_in_noop => noop_value,
+ }
+ end
+
+ if [true, 'true'].include?(value)
+ cron_ensure = 'present'
+ cron_minute = minute
+ else
+ cron_ensure = 'absent'
+ cron_minute = nil
+ end
+
+ if [true, 'true'].include?(noop_value)
+ cron_command = '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay --noop'
+ else
+ cron_command = '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
+ end
+
+ it do
+ should contain_cron('puppet_agent_every_thirty').with({
+ :ensure => cron_ensure,
+ :command => cron_command,
+ :user => 'root',
+ :hour => '*',
+ :minute => cron_minute,
+ })
+ end
+ end
+ end
+ end
end
+
+ describe 'with cron_command specified' do
+ context 'and run_in_noop set to true' do
+ let(:params) do
+ {
+ :run_in_noop => true,
+ :cron_command => '/some/command'
+ }
+ end
+
+ it { should contain_cron('puppet_agent_every_thirty').with_command('/some/command --noop') }
+ it { should contain_cron('puppet_agent_once_at_boot').with_command('/some/command --noop') }
+ end
+
+ context 'and run_in_noop set to false' do
+ let(:params) do
+ {
+ :run_in_noop => false,
+ :cron_command => '/some/command'
+ }
+ end
+
+ it { should contain_cron('puppet_agent_every_thirty').with_command('/some/command') }
+ it { should contain_cron('puppet_agent_once_at_boot').with_command('/some/command') }
+ end
+ end
+
+ describe 'with run_at_boot' do
+ [true, 'true', false, 'false'].each do |value|
+ context "set to #{value} (as #{value.class})" do
+ let(:params) { { :run_at_boot => value } }
+
+ if [true, 'true'].include?(value)
+ foo = 'present'
+ else
+ foo = 'absent'
+ end
+
+ it { should contain_cron('puppet_agent_once_at_boot').with_ensure(foo) }
+ end
+ end
+ end
+
+ describe 'with config_path specified' do
+ let(:params) { { :config_path => '/path/to/puppet.conf' } }
+
+ it { should contain_file('puppet_config').with_path('/path/to/puppet.conf') }
+
+ ini_settings = %w(server ca_server certname environment trusted_node_data graph archive_files archive_file_server)
+
+ ini_settings.each do |setting|
+ it { should contain_ini_setting(setting).with_path('/path/to/puppet.conf') }
+ end
+ end
+
+ describe 'with puppet.conf ini setting' do
+ %w(server ca_server certname graph archive_files archive_file_server).each do |setting|
+ context "#{setting} set to a valid entry" do
+ # 'true' is used because it is acceptable to all of the above
+ # parameters. Some of the settings are strings and some are boolean and
+ # stringified booleans.
+ let(:params) { { setting => 'true' } }
+
+ it do
+ should contain_ini_setting(setting).with({
+ :ensure => 'present',
+ :setting => setting,
+ :value => 'true',
+ :path => '/etc/puppetlabs/puppet/puppet.conf',
+ :section => 'main',
+ :require => 'File[puppet_config]',
+ })
+ end
+ end
+ end
+ end
+
+ describe 'with server specified' do
+ let(:params) { { :server => 'foo' } }
+
+ it do
+ should contain_ini_setting('server').with({
+ :ensure => 'present',
+ :setting => 'server',
+ :value => 'foo',
+ :path => '/etc/puppetlabs/puppet/puppet.conf',
+ :section => 'main',
+ :require => 'File[puppet_config]',
+ })
+ end
+ end
+
+ describe 'parameter type and content validations' do
+ validations = {
+ 'absolute paths' => {
+ :name => %w(config_path agent_sysconfig_path),
+ :valid => ['/absolute/path'],
+ :invalid => ['not/an/absolute/path'],
+ :message => 'is not an absolute path',
+ },
+ 'booleans' => {
+ :name => %w(run_every_thirty run_in_noop run_at_boot graph archive_files),
+ :valid => [true, 'true', false, 'false'],
+ :invalid => ['string', %w(array), { 'ha' => 'sh' }, 3, 2.42],
+ :message => 'Error while evaluating a Resource Statement',
+ },
+ 'strings' => {
+ :name => %w(certname cron_command server ca_server archive_file_server),
+ :valid => ['string'],
+ :invalid => [true, %w(array), { 'ha' => 'sh' }, 3, 2.42],
+ :message => 'Error while evaluating a Resource Statement',
+ },
+ }
+
+ validations.sort.each do |type, var|
+ var[:name].each do |var_name|
+ var[:params] = {} if var[:params].nil?
+ var[:valid].each do |valid|
+ context "when #{var_name} (#{type}) is set to valid #{valid} (as #{valid.class})" do
+ let(:params) { [var[:params], { :"#{var_name}" => valid, }].reduce(:merge) }
+ it { should compile }
+ end
+ end
+
+ var[:invalid].each do |invalid|
+ context "when #{var_name} (#{type}) is set to invalid #{invalid} (as #{invalid.class})" do
+ let(:params) { [var[:params], { :"#{var_name}" => invalid, }].reduce(:merge) }
+ it 'should fail' do
+ expect { should contain_class(subject) }.to raise_error(Puppet::Error, /#{var[:message]}/)
+ end
+ end
+ end
+ end # var[:name].each
+ end # validations.sort.each
+ end # describe 'parameter type content validations'
end
diff --git a/spec/classes/lint_spec.rb b/spec/classes/lint_spec.rb
deleted file mode 100644
index 36d5969..0000000
--- a/spec/classes/lint_spec.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-require 'spec_helper'
-
-describe 'puppet::lint' do
-
- describe 'class puppet::lint' do
-
- context 'Puppet Lint package' do
- let(:params) { {:provider => 'gem' } }
-
- it { should contain_class('puppet::lint') }
-
- it { should contain_package('puppet-lint').with({
- 'provider' => 'gem',
- })
- }
- end
-
- context 'Puppet Lint configuration file' do
- let(:params) do
- { :lintrc_path => '/root/.puppet-lint.rc',
- :lintrc_owner => 'root',
- }
- end
-
- it { should contain_class('puppet::lint') }
-
- it { should contain_file('/root/.puppet-lint.rc').with({
- 'owner' => 'root',
- })
- }
- end
- end
-end
diff --git a/spec/classes/master_maintenance_spec.rb b/spec/classes/master_maintenance_spec.rb
deleted file mode 100644
index d6ace0c..0000000
--- a/spec/classes/master_maintenance_spec.rb
+++ /dev/null
@@ -1,325 +0,0 @@
-require 'spec_helper'
-
-describe 'puppet::master::maintenance' do
-
- describe 'class puppet::master::maintenance' do
-
- context 'Puppetmaster maintenance cron' do
- let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
-
- it { should contain_class('puppet::master::maintenance') }
-
- it { should contain_cron('filebucket_cleanup').with({
- 'user' => 'root',
- 'hour' => '0',
- 'minute' => '0',
- })
- }
- end
-
- context 'with reportdir_purge_ensure set to invalid value' do
- let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports', } }
- let(:params) { { :reportdir_purge_ensure => 'installed', } }
-
- it 'should fail' do
- expect {
- should contain_class('puppet::master::maintenance')
- }.to raise_error(Puppet::Error,/^reportdir_purge_ensure must be 'present' or 'absent'. Detected value is <installed>/)
- end
- end
-
- context 'with clientbucket_cleanup_ensure set to invalid value' do
- let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports', } }
- let(:params) { { :clientbucket_cleanup_ensure => 'installed', } }
-
- it 'should fail' do
- expect {
- should contain_class('puppet::master::maintenance')
- }.to raise_error(Puppet::Error,/^clientbucket_cleanup_ensure must be 'present' or 'absent'. Detected value is <installed>/)
- end
- end
-
- end
-
- describe 'clientbucket cleanup' do
- context 'with default settings' do
- let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
-
- it { should contain_class('puppet::master::maintenance') }
-
- it { should contain_cron('filebucket_cleanup').with({
- 'ensure' => 'present',
- 'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -f {} \;',
- 'user' => 'root',
- 'hour' => '0',
- 'minute' => '0',
- })
- }
- end
-
- context 'with non-default user' do
- let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
- let(:params) do
- { :filebucket_cleanup_user => 'gh', }
- end
-
- it { should contain_class('puppet::master::maintenance') }
-
- it { should contain_cron('filebucket_cleanup').with({
- 'ensure' => 'present',
- 'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -f {} \;',
- 'user' => 'gh',
- 'hour' => '0',
- 'minute' => '0',
- })
- }
- end
-
- context 'with non-default path' do
- let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
- let(:params) do
- { :clientbucket_path => '/var/lib/puppet/filebucket/', }
- end
-
- it { should contain_class('puppet::master::maintenance') }
-
- it { should contain_cron('filebucket_cleanup').with({
- 'ensure' => 'present',
- 'command' => '/usr/bin/find /var/lib/puppet/filebucket/ -type f -mtime +30 -exec /bin/rm -f {} \;',
- 'user' => 'root',
- 'hour' => '0',
- 'minute' => '0',
- })
- }
- end
-
- context 'with non-default number of days to keep' do
- let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
- let(:params) do
- {
- :clientbucket_days_to_keep => '20',
- }
- end
-
- it { should contain_class('puppet::master::maintenance') }
-
- it { should contain_cron('filebucket_cleanup').with({
- 'ensure' => 'present',
- 'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +20 -exec /bin/rm -f {} \;',
- 'user' => 'root',
- 'hour' => '0',
- 'minute' => '0',
- })
- }
- end
-
- context 'with non-default hour and minute set' do
- let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
- let(:params) do
- {
- :filebucket_cleanup_hour => '2',
- :filebucket_cleanup_minute => '30',
- }
- end
-
- it { should contain_class('puppet::master::maintenance') }
-
- it { should contain_cron('filebucket_cleanup').with({
- 'ensure' => 'present',
- 'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -f {} \;',
- 'user' => 'root',
- 'hour' => '2',
- 'minute' => '30',
- })
- }
- end
-
- context 'with clientbucket_cleanup_ensure set to absent' do
- let(:facts) do
- { :puppet_reportdir => '/var/lib/puppet/reports', }
- end
- let(:params) do
- { :clientbucket_cleanup_ensure => 'absent', }
- end
-
- it { should contain_class('puppet::master::maintenance') }
-
- it { should contain_cron('filebucket_cleanup').with({
- 'ensure' => 'absent'
- })
- }
- end
-
- end
-
- describe 'purge reportdir' do
- context 'with default settings for params' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_class('puppet::master::maintenance') }
-
- it { should contain_cron('purge_old_puppet_reports').with({
- 'ensure' => 'present',
- 'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -f {} \;',
- 'user' => 'root',
- 'hour' => '0',
- 'minute' => '15',
- })
- }
- end
-
- context 'with reportdir_purge_user, reportdir_purge_hour, and reportdir_purge_minute set' do
- let(:params) do
- { :reportdir_purge_user => 'gh',
- :reportdir_purge_hour => '23',
- :reportdir_purge_minute => '42',
- }
- end
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_class('puppet::master::maintenance') }
-
- it { should contain_cron('purge_old_puppet_reports').with({
- 'ensure' => 'present',
- 'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -f {} \;',
- 'user' => 'gh',
- 'hour' => '23',
- 'minute' => '42',
- })
- }
- end
-
- describe 'with reportdir_days_to_keep specified' do
- context 'as a valid integer greater than zero' do
- let(:params) { { :reportdir_days_to_keep => '42' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_class('puppet::master::maintenance') }
-
- it { should contain_cron('purge_old_puppet_reports').with({
- 'ensure' => 'present',
- 'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +42 -exec /bin/rm -f {} \;',
- 'user' => 'root',
- 'hour' => '0',
- 'minute' => '15',
- })
- }
- end
-
- ['0','-23'].each do |value|
- context "as #{value}" do
- let(:params) { { :reportdir_days_to_keep => value } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it do
- expect {
- should contain_class('puppet::master::maintenance')
- }.to raise_error(Puppet::Error,/puppet::master::maintenance::reportdir_days_to_keep must be a positive integer greater than zero. Detected value is <#{value}>./)
- end
- end
- end
- end
-
- describe 'with reportdir specified' do
- context 'as a valid directory' do
- let(:params) { { :reportdir => '/etc/puppet/reports' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_class('puppet::master::maintenance') }
-
- it { should contain_cron('purge_old_puppet_reports').with({
- 'ensure' => 'present',
- 'command' => '/usr/bin/find -L /etc/puppet/reports -type f -mtime +30 -exec /bin/rm -f {} \;',
- 'user' => 'root',
- 'hour' => '0',
- 'minute' => '15',
- })
- }
- end
-
- context 'as an invalid directory' do
- let(:params) { { :reportdir => 'invalid/path' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it do
- expect {
- should contain_class('puppet::master::maintenance')
- }.to raise_error(Puppet::Error,/^"invalid\/path" is not an absolute path./)
- end
- end
- end
-
- context 'with reportdir and reportdir_days_to_keep specified' do
- let(:params) do
- { :reportdir => '/etc/puppet/reports',
- :reportdir_days_to_keep => '42',
- }
- end
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_class('puppet::master::maintenance') }
-
- it { should contain_cron('purge_old_puppet_reports').with({
- 'ensure' => 'present',
- 'command' => '/usr/bin/find -L /etc/puppet/reports -type f -mtime +42 -exec /bin/rm -f {} \;',
- 'user' => 'root',
- 'hour' => '0',
- 'minute' => '15',
- })
- }
- end
-
- context 'with purge_old_puppet_reports set to absent' do
- let(:facts) do
- { :puppet_reportdir => '/var/lib/puppet/reports', }
- end
- let(:params) do
- { :reportdir_purge_ensure => 'absent', }
- end
-
- it { should contain_class('puppet::master::maintenance') }
-
- it { should contain_cron('purge_old_puppet_reports').with({
- 'ensure' => 'absent'
- })
- }
-
- end
-
- end
-end
diff --git a/spec/classes/master_spec.rb b/spec/classes/master_spec.rb
deleted file mode 100644
index ddab0a5..0000000
--- a/spec/classes/master_spec.rb
+++ /dev/null
@@ -1,281 +0,0 @@
-require 'spec_helper'
-describe 'puppet::master' do
-
- describe 'class puppet::master' do
-
- context 'Puppetmaster auth.conf configuration file' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_class('puppet::master') }
-
- it { should contain_file('/etc/puppet/auth.conf').with({
- 'owner' => 'root',
- })
- }
- end
-
- context 'Puppetmaster fileserver.conf configuration file' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_class('puppet::master') }
-
- it { should contain_file('/etc/puppet/fileserver.conf').with({
- 'owner' => 'root',
- })
- }
- end
-
- context 'Puppetmaster sysconfig file on osfamily RedHat' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_class('puppet::master') }
-
- it { should contain_file('puppetmaster_sysconfig').with_content(/^#PUPPETMASTER_LOG=syslog$/) }
- end
-
- context 'Puppetmaster sysconfig file on osfamily Debian' do
- let(:facts) do
- { :osfamily => 'Debian',
- :operatingsystemrelease => '7',
- :concat_basedir => '/tmp',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_class('puppet::master') }
-
- it { should contain_file('puppetmaster_sysconfig').with_content(/^START=no$/) }
- it { should contain_file('puppetmaster_sysconfig').with_content(/^DAEMON_OPTS=""$/) }
- it { should contain_file('puppetmaster_sysconfig').with_content(/^PORT=8140$/) }
- end
-
- context 'Puppetmaster sysconfig file on invalid osfmaily' do
- let(:facts) do
- { :osfamily => 'invalid',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it 'should fail' do
- expect {
- should contain_class('puppet::master')
- }.to raise_error(Puppet::Error,/puppet::master supports osfamilies Debian and RedHat. Detected osfamily is <invalid>./)
- end
- end
-
- context 'Puppetmaster sysconfig file specified as invalid path' do
- let(:params) { { :sysconfig_path => 'invalid/path/statement' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it 'should fail' do
- expect {
- should contain_class('puppet::master')
- }.to raise_error(Puppet::Error,/^"invalid\/path\/statement" is not an absolute path./)
- end
- end
-
- context 'Puppetmaster rack directory' do
- let(:params) { {:rack_dir => '/foo/bar' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_class('puppet::master') }
-
- it { should contain_file('/foo/bar').with({
- 'ensure' => 'directory',
- })
- }
- end
-
- context 'Puppetmaster rack configuration file' do
- let(:params) { {:rack_dir => '/foo/bar' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_class('puppet::master') }
-
- it { should contain_file('/foo/bar/config.ru').with({
- 'owner' => 'puppet',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
- end
-
- context 'Puppetmaster vhost configuration file on osfamily RedHat' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_class('puppet::master') }
-
- it { should contain_file('puppetmaster_vhost').with({
- 'ensure' => 'file',
- 'path' => '/etc/httpd/conf.d/puppetmaster.conf',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
- end
-
- context 'Puppetmaster vhost configuration file on osfamily Debian' do
- let(:facts) do
- { :osfamily => 'Debian',
- :operatingsystemrelease => '6.0.8',
- :concat_basedir => '/tmp',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_class('puppet::master') }
-
- it { should contain_file('puppetmaster_vhost').with({
- 'ensure' => 'file',
- 'path' => '/etc/apache2/sites-enabled/puppetmaster',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
- end
-
- context 'Puppetmaster vhost configuration file specified as param' do
- let(:params) { { :vhost_path => '/usr/local/apache/conf.d/puppetmaster.conf' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_class('puppet::master') }
-
- it { should contain_file('puppetmaster_vhost').with({
- 'ensure' => 'file',
- 'path' => '/usr/local/apache/conf.d/puppetmaster.conf',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
- end
-
- context 'Puppetmaster vhost configuration file specified as invalid path' do
- let(:params) { { :vhost_path => 'invalid/path/statement' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it 'should fail' do
- expect {
- should contain_class('puppet::master')
- }.to raise_error(Puppet::Error,/^"invalid\/path\/statement" is not an absolute path./)
- end
- end
-
- context 'Puppetmaster vhost configuration file content' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_class('puppet::master') }
-
- it { should contain_file('puppetmaster_vhost').with_content(/^\s*<Directory \/usr\/share\/puppet\/rack\/puppetmasterd\/>$/) }
- end
-
- context 'Puppetmaster vhost configuration default PassengerMaxRequests' do
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_class('puppet::master') }
-
- it { should contain_file('puppetmaster_vhost').with_content(/^\s*PassengerMaxRequests 1000$/) }
- end
-
- context 'Puppetmaster vhost configuration of PassengerMaxRequests' do
- let(:params) { { :passenger_max_requests => 5 } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it { should contain_file('puppetmaster_vhost').with_content(/^\s*PassengerMaxRequests 5$/) }
- end
-
- context 'Puppetmaster vhost configuration parameter error for PassengerMaxRequests' do
- let(:params) { { :passenger_max_requests => 'Invalid' } }
- let(:facts) do
- { :osfamily => 'RedHat',
- :operatingsystemrelease => '6.4',
- :concat_basedir => '/tmp',
- :puppet_reportdir => '/var/lib/puppet/reports',
- }
- end
-
- it 'should fail' do
- expect {
- should contain_class('puppet::master')
- }.to raise_error(Puppet::Error,/Expected first argument to be an Integer/)
- end
- end
-
- end
-end
diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb
new file mode 100644
index 0000000..c83c4de
--- /dev/null
+++ b/spec/classes/server_spec.rb
@@ -0,0 +1,223 @@
+require 'spec_helper'
+describe 'puppet::server' do
+ # Filter out duplicate platforms
+ platforms = on_supported_os.select { |k, _v| !k.to_s.match(/^(RedHat|Scientific|OracleLinux)/i) }
+
+ platforms.each do |os, facts|
+ context "on #{os} with default values for parameters" do
+ let(:facts) do
+ facts
+ end
+
+ it { is_expected.to compile.with_all_deps }
+ it { should contain_class('puppet') }
+ it { should contain_class('puppet::server') }
+
+ non_conditional_ini_settings = {
+ 'vardir' => '/opt/puppetlabs/server/data/puppetserver',
+ 'logdir' => '/var/log/puppetlabs/puppetserver',
+ 'rundir' => '/var/run/puppetlabs/puppetserver',
+ 'pidfile' => '/var/run/puppetlabs/puppetserver/puppetserver.pid',
+ 'codedir' => '/etc/puppetlabs/code',
+ 'ca' => false,
+ }
+
+ non_conditional_ini_settings.each do |setting, value|
+ it do
+ should contain_ini_setting(setting).with({
+ :ensure => 'present',
+ :setting => setting,
+ :value => value,
+ :path => '/etc/puppetlabs/puppet/puppet.conf',
+ :section => 'master',
+ :require => 'File[puppet_config]',
+ :notify => 'Service[puppetserver]',
+ })
+ end
+ end
+
+ %w(node_terminus external_nodes dns_alt_names).each do |setting|
+ it { should_not contain_ini_setting(setting) }
+ end
+
+ empty_autosign_content = <<-END.gsub(/^\s+\|/, '')
+ |# This file is being maintained by Puppet.
+ |# DO NOT EDIT
+ END
+
+ it do
+ should contain_file('autosign_config').with({
+ :ensure => 'file',
+ :path => '/etc/puppetlabs/puppet/autosign.conf',
+ :content => empty_autosign_content,
+ :owner => 'root',
+ :group => 'root',
+ :mode => '0644',
+ :notify => 'Service[puppetserver]',
+ })
+ end
+
+ puppetserver_sysconfig = File.read(fixtures('puppetserver_sysconfig'))
+ it do
+ should contain_file('puppetserver_sysconfig').with({
+ :ensure => 'file',
+ :path => '/etc/sysconfig/puppetserver',
+ :content => puppetserver_sysconfig,
+ :owner => 'root',
+ :group => 'root',
+ :mode => '0644',
+ })
+ end
+
+ it do
+ should contain_service('puppetserver').with({
+ :ensure => 'running',
+ :enable => true,
+ :subscribe => [
+ 'File[puppet_config]',
+ 'File[puppetserver_sysconfig]',
+ ],
+ })
+ end
+ end
+ end
+
+ describe 'with ca' do
+ [true, 'true', false, 'false'].each do |value|
+ context "set to #{value} (as #{value.class})" do
+ let(:params) { { :ca => value } }
+
+ it do
+ should contain_ini_setting('ca').with({
+ :ensure => 'present',
+ :setting => 'ca',
+ :value => value,
+ :path => '/etc/puppetlabs/puppet/puppet.conf',
+ :section => 'master',
+ :require => 'File[puppet_config]',
+ :notify => 'Service[puppetserver]',
+ })
+ end
+ end
+ end
+ end
+
+ describe 'with enc' do
+ context 'set to a valid path' do
+ let(:params) { { :enc => '/path/to/enc' } }
+
+ it do
+ should contain_ini_setting('external_nodes').with({
+ :ensure => 'present',
+ :setting => 'external_nodes',
+ :value => '/path/to/enc',
+ :path => '/etc/puppetlabs/puppet/puppet.conf',
+ :section => 'master',
+ :require => 'File[puppet_config]',
+ :notify => 'Service[puppetserver]',
+ })
+ end
+
+ it do
+ should contain_ini_setting('node_terminus').with({
+ :ensure => 'present',
+ :setting => 'node_terminus',
+ :value => 'exec',
+ :path => '/etc/puppetlabs/puppet/puppet.conf',
+ :section => 'master',
+ :require => 'File[puppet_config]',
+ :notify => 'Service[puppetserver]',
+ })
+ end
+ end
+ end
+
+ describe 'with dns_alt_names' do
+ context 'set to a valid path' do
+ let(:params) { { :dns_alt_names => 'foo,foo1,foo1.example.com,foo.example.com' } }
+
+ it do
+ should contain_ini_setting('dns_alt_names').with({
+ :ensure => 'present',
+ :setting => 'dns_alt_names',
+ :value => 'foo,foo1,foo1.example.com,foo.example.com',
+ :path => '/etc/puppetlabs/puppet/puppet.conf',
+ :section => 'master',
+ :require => 'File[puppet_config]',
+ :notify => 'Service[puppetserver]',
+ })
+ end
+ end
+ end
+
+ describe 'with autosign_entries' do
+ context 'set to a valid array of strings' do
+ let(:params) { { :autosign_entries => ['*.example.org', '*.dev.example.org'] } }
+
+ autosign_conf_content = <<-END.gsub(/^\s+\|/, '')
+ |# This file is being maintained by Puppet.
+ |# DO NOT EDIT
+ |*.example.org
+ |*.dev.example.org
+ END
+
+ it { should contain_file('autosign_config').with_content(autosign_conf_content) }
+ end
+ end
+
+ describe 'parameter type and content validations' do
+ validations = {
+ 'absolute paths' => {
+ :name => %w(sysconfig_path enc),
+ :valid => ['/absolute/path'],
+ :invalid => ['not/an/absolute/path'],
+ :message => 'is not an absolute path',
+ },
+ 'booleans' => {
+ :name => %w(ca),
+ :valid => [true, 'true', false, 'false'],
+ :invalid => ['string', %w(array), { 'ha' => 'sh' }, 3, 2.42],
+ :message => 'Error while evaluating a Resource Statement',
+ },
+ 'strings' => {
+ :name => %w(dns_alt_names),
+ :valid => ['string'],
+ :invalid => [true, %w(array), { 'ha' => 'sh' }, 3, 2.42],
+ :message => 'Error while evaluating a Resource Statement',
+ },
+ 'non-empty array of strings' => {
+ :name => %w(autosign_entries),
+ :valid => [['array with one string'], %w(array with many strings)],
+ :invalid => [%w(), [1,'not_all','string'], true, 'string', { 'ha' => 'sh' }, 3, 2.42],
+ :message => 'Error while evaluating a Resource Statement',
+ },
+ 'memory size regex' => {
+ :name => %w(memory_size),
+ :valid => ['1g', '1m', '1500m', '3g'],
+ :invalid => ['1g1', 'm', '1k', '2t', 'g3', '1.2g'],
+ :message => 'must be an integer following by the unit',
+ },
+ }
+
+ validations.sort.each do |type, var|
+ var[:name].each do |var_name|
+ var[:params] = {} if var[:params].nil?
+ var[:valid].each do |valid|
+ context "when #{var_name} (#{type}) is set to valid #{valid} (as #{valid.class})" do
+ let(:params) { [var[:params], { :"#{var_name}" => valid, }].reduce(:merge) }
+ it { should compile }
+ end
+ end
+
+ var[:invalid].each do |invalid|
+ context "when #{var_name} (#{type}) is set to invalid #{invalid} (as #{invalid.class})" do
+ let(:params) { [var[:params], { :"#{var_name}" => invalid, }].reduce(:merge) }
+ it 'should fail' do
+ expect { should contain_class(subject) }.to raise_error(Puppet::Error, /#{var[:message]}/)
+ end
+ end
+ end
+ end # var[:name].each
+ end # validations.sort.each
+ end # describe 'parameter type content validations'
+end
diff --git a/spec/fixtures/puppet_agent_sysconfig b/spec/fixtures/puppet_agent_sysconfig
new file mode 100644
index 0000000..43c20a5
--- /dev/null
+++ b/spec/fixtures/puppet_agent_sysconfig
@@ -0,0 +1,5 @@
+# This file is being maintained by Puppet.
+# DO NOT EDIT
+
+# You may specify parameters to the puppet client here
+#PUPPET_EXTRA_OPTS=--waitforcert=500
diff --git a/spec/fixtures/puppetserver_sysconfig b/spec/fixtures/puppetserver_sysconfig
new file mode 100644
index 0000000..6971878
--- /dev/null
+++ b/spec/fixtures/puppetserver_sysconfig
@@ -0,0 +1,28 @@
+# This file is being maintained by Puppet.
+# DO NOT EDIT
+
+###########################################
+# Init settings for puppetserver
+###########################################
+
+# Location of your Java binary (version 7 or higher)
+JAVA_BIN="/usr/bin/java"
+
+# Modify this if you'd like to change the memory allocation, enable JMX, etc
+JAVA_ARGS="-Xms2g -Xmx2g -XX:MaxPermSize=256m"
+
+# These normally shouldn't need to be edited if using OS packages
+USER="puppet"
+GROUP="puppet"
+INSTALL_DIR="/opt/puppetlabs/server/apps/puppetserver"
+CONFIG="/etc/puppetlabs/puppetserver/conf.d"
+
+# Bootstrap path
+BOOTSTRAP_CONFIG="/etc/puppetlabs/puppetserver/services.d/,/opt/puppetlabs/server/apps/puppetserver/config/services.d/"
+
+SERVICE_STOP_RETRIES=60
+
+# START_TIMEOUT can be set here to alter the default startup timeout in
+# seconds. This is used in System-V style init scripts only, and will have no
+# effect in systemd.
+# START_TIMEOUT=300
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 2c6f566..10e055c 100755
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1 +1,23 @@
require 'puppetlabs_spec_helper/module_spec_helper'
+require 'rspec-puppet-facts'
+include RspecPuppetFacts
+
+RSpec.configure do |config|
+ config.hiera_config = 'spec/fixtures/hiera/hiera.yaml'
+ config.before :each do
+ # Ensure that we don't accidentally cache facts and environment between
+ # test cases. This requires each example group to explicitly load the
+ # facts being exercised with something like
+ # Facter.collection.loader.load(:ipaddress)
+ Facter.clear
+ Facter.clear_messages
+ end
+ config.default_facts = {
+ :environment => 'rp_env',
+ :fqdn => 'puppet.example.com',
+ }
+end
+
+# ensure fqdn matches when using rspec-puppet-facts so that fqdn_rand() gives
+# consistent output
+add_custom_fact :fqdn, 'puppet.example.com'
diff --git a/templates/agent_sysconfig.erb b/templates/agent_sysconfig.erb
index dd8732d..43c20a5 100644
--- a/templates/agent_sysconfig.erb
+++ b/templates/agent_sysconfig.erb
@@ -1,14 +1,5 @@
# This file is being maintained by Puppet.
# DO NOT EDIT
-# The puppetmaster server
-#PUPPET_SERVER=<%= @puppet_server %>
-
-# If you wish to specify the port to connect to do so here
-#PUPPET_PORT=8140
-
-# Where to log to. Specify syslog to send log messages to the system log.
-#PUPPET_LOG=/var/log/puppet/puppet.log
-
-# You may specify other parameters to the puppet client here
+# You may specify parameters to the puppet client here
#PUPPET_EXTRA_OPTS=--waitforcert=500
diff --git a/templates/autosign.conf.erb b/templates/autosign.conf.erb
new file mode 100644
index 0000000..ce663c8
--- /dev/null
+++ b/templates/autosign.conf.erb
@@ -0,0 +1,7 @@
+# This file is being maintained by Puppet.
+# DO NOT EDIT
+<% if @autosign_entries != nil -%>
+<% @autosign_entries.each do |entry| -%>
+<%= entry %>
+<% end -%>
+<% end -%>
diff --git a/templates/dashboard-vhost.conf.erb b/templates/dashboard-vhost.conf.erb
deleted file mode 100644
index 4d9ef26..0000000
--- a/templates/dashboard-vhost.conf.erb
+++ /dev/null
@@ -1,110 +0,0 @@
-# This file is being maintained by Puppet.
-# DO NOT EDIT
-
-#LoadModule passenger_module <%= scope.lookupvar('passenger::mod_passenger_location') %>
-#PassengerRoot <%= scope.lookupvar('passenger::gem_path') %>/passenger-<%= scope.lookupvar('passenger::passenger_version') %>
-#PassengerRuby /usr/bin/ruby
-
-# you may want to tune these settings
-PassengerHighPerformance on
-PassengerMaxPoolSize 12
-PassengerPoolIdleTime 1500
-# PassengerMaxRequests 1000
-PassengerStatThrottleRate 120
-RailsAutoDetect On
-
-<% if @port != '80' %>Listen <%= @port %><% end %>
-<VirtualHost *:<%= @port %>>
- ServerName <%= @dashboard_fqdn %>
- DocumentRoot /usr/share/puppet-dashboard/public/
- <Directory /usr/share/puppet-dashboard/public/>
- Options None
- Order allow,deny
- allow from all
- </Directory>
- ErrorLog <%= @log_dir %>/dashboard_error.log
- LogLevel warn
- CustomLog <%= @log_dir %>/dashboard_access.log combined
- ServerSignature On
-
-<% if @security == 'htpasswd' %>
-# Uncomment this section to enable basic auth. This section can also be copied
-# to the HTTPS VirtualHost example below.
- # For report submission from masters.
- <Location /reports/upload>
- <Limit POST>
- # Configuration restricts HTTP actions to POST only
- Order allow,deny
- # Allow from localhost
- # Allow from localhost.localdomain
- # Allow from 127.0.0.1
- # Allow from example.com
- # This can be locked down to just your puppet master if required
- # See examples above, or http://httpd.apache.org/docs/2.2/howto/access.html
- Allow from all
- Satisfy any
- </Limit>
- </Location>
-
- # For node definitions from masters.
- <Location /nodes>
- <Limit GET>
- # Configuration restricts HTTP actions to GET only
- Order allow,deny
- # Allow from localhost.localdomain
- # Allow from localhost
- # Allow from 127.0.0.1
- # Allow from example.com
- # This can be locked down to just your puppet master if required
- # See examples above, or http://httpd.apache.org/docs/2.2/howto/access.html
- Allow from all
- Satisfy any
- </Limit>
- </Location>
-
- # For web access by humans.
- <Location "/">
- AuthType basic
- AuthName "Puppet Dashboard"
- Require valid-user
- AuthBasicProvider file
- AuthUserFile <%= @htpasswd_path %>
- </Location>
-<% end -%>
-
-</VirtualHost>
-
-# Uncomment this section to enable HTTPS (SSL)
-#Listen 443
-#<VirtualHost *:443>
-# SSLEngine on
-# SSLProtocol -ALL -SSLv3 +TLSv1
-# SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP
-#
-# SSLCertificateFile /usr/share/puppet-dashboard/certs/dashboard.cert.pem
-# SSLCertificateKeyFile /usr/share/puppet-dashboard/certs/dashboard.private_key.pem
-# SSLCACertificateFile /usr/share/puppet-dashboard/certs/dashboard.ca_cert.pem
-#
-# # If Apache complains about invalid signatures on the CRL, you can try disabling
-# # CRL checking by commenting the next line, but this is not recommended.
-# SSLCARevocationFile /usr/share/puppet-dashboard/certs/dashboard.ca_crl.pem
-#
-# SSLVerifyClient optional
-# SSLVerifyDepth 1
-# SSLOptions +StdEnvVars
-#
-# ServerName dashboard.example.com # UPDATE THIS TO YOUR FQDN
-# DocumentRoot /usr/share/puppet-dashboard/public
-# <Directory /usr/share/puppet-dashboard/public>
-# Options None
-# AllowOverride None
-# Order allow,deny
-# allow from all
-# </Directory>
-# <Location / >
-# Order deny,allow
-# Allow from ALL
-# # Enable this to require client-side certificates for Dashboard connections
-# #SSLVerifyClient require
-# </Location>
-#</VirtualHost>
diff --git a/templates/dashboard_default.erb b/templates/dashboard_default.erb
deleted file mode 100644
index 256bdc3..0000000
--- a/templates/dashboard_default.erb
+++ /dev/null
@@ -1,28 +0,0 @@
-# This file is being maintained by Puppet.
-# DO NOT EDIT
-#
-# IMPORTANT: Be sure you have checked the values below, appropriately
-# configured 'config/database.yml' in your DASHBOARD_HOME, and
-# created and migrated the database.
-
-# Uncomment the line below to start Puppet Dashboard.
-### START=yes
-
-# Location where puppet-dashboard is installed:
-DASHBOARD_HOME=/usr/share/puppet-dashboard
-
-# User which runs the puppet-dashboard program:
-DASHBOARD_USER=www-data
-
-# Ruby version to run the puppet-dashboard as:
-DASHBOARD_RUBY=/usr/bin/ruby
-
-# Rails environment in which puppet-dashboard runs:
-DASHBOARD_ENVIRONMENT=production
-
-# Network interface which puppet-dashboard web server is running at:
-DASHBOARD_IFACE=0.0.0.0
-
-# Port on which puppet-dashboard web server is running at, note that if the
-# puppet-dashboard user is not root, it has to be a > 1024:
-DASHBOARD_PORT=3000
diff --git a/templates/dashboard_sysconfig.erb b/templates/dashboard_sysconfig.erb
deleted file mode 100644
index e4fe8a8..0000000
--- a/templates/dashboard_sysconfig.erb
+++ /dev/null
@@ -1,11 +0,0 @@
-# This file is being maintained by Puppet.
-# DO NOT EDIT
-#
-# path to where you installed puppet dashboard
-#
-DASHBOARD_HOME=/usr/share/puppet-dashboard
-DASHBOARD_USER=puppet-dashboard
-DASHBOARD_RUBY=/usr/bin/ruby
-DASHBOARD_ENVIRONMENT=production
-DASHBOARD_IFACE=0.0.0.0
-DASHBOARD_PORT=<%= @port %>
diff --git a/templates/database.yml.erb b/templates/database.yml.erb
deleted file mode 100644
index 251cedc..0000000
--- a/templates/database.yml.erb
+++ /dev/null
@@ -1,69 +0,0 @@
-# This file is being maintained by Puppet.
-# DO NOT EDIT
-#
-# config/database.yml
-#
-# IMPORTANT NOTE: Before starting Dashboard, you will need to ensure that the
-# MySQL user and databases you've specified in this file exist, and that the
-# user has all permissions on the relevant databases. This will have to be done
-# with an external database administration tool. If using the command-line
-# `mysql` client, the commands to do this will resemble the following:
-#
-# CREATE DATABASE dashboard_production CHARACTER SET utf8;
-# CREATE USER 'dashboard'@'localhost' IDENTIFIED BY 'my_password';
-# GRANT ALL PRIVILEGES ON dashboard_production.* TO 'dashboard'@'localhost';
-#
-# -----
-#
-# This file should be a YAML hash with one key for each of the standard Rails
-# environments: production, development, and test.
-#
-# - The "production" environment gives the best performance, and should be used
-# most of the time by most users. **Note that Rails does not consider
-# production its default environment, and you must specify it manually with
-# the RAILS_ENV environment variable when running any rake tasks.**
-# - The "development" environment gives worse performance, but yields better
-# logging and error reporting when something goes wrong.
-# - The "test" environment is only used for running Dashboard's automated tests.
-# It should never be used by most users. If you are using the test
-# environment, **DO NOT set its database to the same database used by the
-# development or production environments,** as it will be erased and
-# re-written every time the automated tests are run.
-#
-# The environment is set when Dashboard is started, a console is started, or a
-# rake task is run. Most production-quality Rails servers (such as Passenger)
-# will default to the production environment, but the included WEBrick server
-# script will default to development unless run with the `-e production` option.
-#
-# Each environment should be a hash with keys for:
-#
-# - database
-# - username
-# - password
-# - encoding
-# - adapter
-#
-# At the moment, "adapter" can only be "mysql", and "encoding" should always
-# be "utf8".
-#
-production:
- database: dashboard
- username: <%= @mysql_user %>
- password: <%= @mysql_password %>
- encoding: utf8
- adapter: mysql
-
-#development:
-# database: dashboard_development
-# username: <%= @mysql_user %>
-# password: <%= @mysql_password %>
-# encoding: utf8
-# adapter: mysql
-#
-#test:
-# database: dashboard_test
-# username: <%= @mysql_user %>
-# password: <%= @mysql_password %>
-# encoding: utf8
-# adapter: mysql
-
diff --git a/templates/external_node.erb b/templates/external_node.erb
deleted file mode 100755
index 5901a0c..0000000
--- a/templates/external_node.erb
+++ /dev/null
@@ -1,52 +0,0 @@
-#! /usr/bin/ruby
-#
-# This file is being maintained by Puppet.
-# DO NOT EDIT
-#
-# Sample External Node script for Puppet Dashboard
-#
-# == puppet.conf Configuration
-#
-# [main]
-# external_nodes = /path/to/external_node
-# node_terminus = exec
-
-require 'yaml'
-require 'uri'
-require 'net/http'
-
-DASHBOARD_URL = "http://<%= @dashboard_fqdn %>:<%= @port %>"
-
-# These settings are only used when connecting to dashboard over https (SSL)
-CERT_PATH = "/etc/puppet/ssl/certs/puppet.pem"
-PKEY_PATH = "/etc/puppet/ssl/private_keys/puppet.pem"
-CA_PATH = "/etc/puppet/ssl/certs/ca.pem"
-
-cert_path = ENV['PUPPET_CERT_PATH'] || CERT_PATH
-pkey_path = ENV['PUPPET_PKEY_PATH'] || PKEY_PATH
-ca_path = ENV['PUPPET_CA_PATH'] || CA_PATH
-
-NODE = ARGV.first
-
-url = ENV['PUPPET_DASHBOARD_URL'] || DASHBOARD_URL
-uri = URI.parse("#{url}/nodes/#{NODE}")
-require 'net/https' if uri.scheme == 'https'
-
-request = Net::HTTP::Get.new(uri.path, initheader = {'Accept' => 'text/yaml'})
-request.basic_auth uri.user, uri.password if uri.user
-http = Net::HTTP.new(uri.host, uri.port)
-if uri.scheme == 'https'
- cert = File.read(cert_path)
- pkey = File.read(pkey_path)
- http.use_ssl = true
- http.cert = OpenSSL::X509::Certificate.new(cert)
- http.key = OpenSSL::PKey::RSA.new(pkey)
- http.ca_file = ca_path
- http.verify_mode = OpenSSL::SSL::VERIFY_PEER
-end
-result = http.start {|http| http.request(request)}
-
-case result
-when Net::HTTPSuccess; puts result.body; exit 0
-else; STDERR.puts "Error: #{result.code} #{result.message.strip}\n#{result.body}"; exit 1
-end
diff --git a/templates/puppet-dashboard-workers.erb b/templates/puppet-dashboard-workers.erb
deleted file mode 100644
index 8b1de95..0000000
--- a/templates/puppet-dashboard-workers.erb
+++ /dev/null
@@ -1,13 +0,0 @@
-# This file is being maintained by Puppet.
-# DO NOT EDIT
-#
-# IMPORTANT: Be sure you have checked the values below, appropriately
-# configured 'config/database.yml' in your DASHBOARD_HOME, and
-# created and migrated the database.
-. /etc/default/puppet-dashboard
-START=yes
-
-# Number of dashboard workers to start. This will be the number of jobs that
-# can be concurrently processed. A simple recommendation would be to start
-# with the number of cores you have available.
-NUM_DELAYED_JOB_WORKERS=<%= @dashboard_workers %>
diff --git a/templates/puppetagent.conf.erb b/templates/puppetagent.conf.erb
deleted file mode 100644
index d564cbe..0000000
--- a/templates/puppetagent.conf.erb
+++ /dev/null
@@ -1,74 +0,0 @@
-# This file is being maintained by Puppet.
-# DO NOT EDIT
-
-<% if @is_puppet3 == true -%>
-[main]
- # The Puppet log directory.
- # The default value is '$vardir/log'.
- logdir = /var/log/puppet
-
- # Where Puppet PID files are kept.
- # The default value is '$vardir/run'.
- rundir = /var/run/puppet
-
- # Where SSL certificates are kept.
- # The default value is '$confdir/ssl'.
- ssldir = <%= @ssldir_real %>
-
- archive_files = true
- archive_file_server = <%= @puppet_server %>
-
- # If stringify_facts is true, you have the classic facter fact that is
- # always a string. If set to false, then you can use structured facts which
- # were introduced in Facter v2
- stringify_facts = <%= @stringify_facts_bool %>
-<% if @etckeeper_hooks_bool == true %>
-
- prerun_command=/etc/puppet/etckeeper-commit-pre
- postrun_command=/etc/puppet/etckeeper-commit-post
-<% end -%>
-[agent]
- # The file in which puppetd stores a list of the classes
- # associated with the retrieved configuratiion. Can be loaded in
- # the separate ``puppet`` executable using the ``--loadclasses``
- # option.
- # The default value is '$confdir/classes.txt'.
- classfile = $vardir/classes.txt
-
- # Where puppetd caches the local configuration. An
- # extension indicating the cache format is added automatically.
- # The default value is '$confdir/localconfig'.
- localconfig = $vardir/localconfig
-
- certname = <%= @certname %>
- server = <%= @puppet_server %>
-<% if @puppet_masterport != 'UNSET' -%>
- masterport = <%= @puppet_masterport %>
-<% end -%>
-<% if @puppet_ca_server != 'UNSET' -%>
- ca_server = <%= @puppet_ca_server %>
-<% end -%>
-<% if @http_proxy_host != 'UNSET' -%>
- http_proxy_host = <%= @http_proxy_host %>
-<% end -%>
-<% if @http_proxy_port != 'UNSET' -%>
- http_proxy_port = <%= @http_proxy_port %>
-<% end -%>
- report = true
- graph = true
- pluginsync = true
-<% if @run_method_real == 'service' %>
- noop = <%= @run_in_noop %>
-<% end -%>
-<% if @env != 'production' -%>
- environment = <%= @env %>
-<% end -%>
-<% else -%>
- [main]
- certname = <%= @certname %>
- server = <%= @puppet_server %>
- <% if @puppet_ca_server != 'UNSET' -%>
- ca_server = <%= @puppet_ca_server %>
- <% end -%>
- graph = true
-<% end -%>
diff --git a/templates/puppetmaster-vhost.conf.erb b/templates/puppetmaster-vhost.conf.erb
deleted file mode 100644
index 5149106..0000000
--- a/templates/puppetmaster-vhost.conf.erb
+++ /dev/null
@@ -1,49 +0,0 @@
-# This file is being maintained by Puppet.
-# DO NOT EDIT
-
-PassengerUseGlobalQueue On
-
-# Recycle master processes after they service the number of requests specified by PassengerMaxRequests. Default is 1000.
-PassengerMaxRequests <%= @passenger_max_requests %>
-
-# Stop processes if they sit idle for 10 minutes
-PassengerPoolIdleTime 600
-
-PassengerStatThrottleRate 120
-RackAutoDetect On
-RailsAutoDetect On
-
-Listen 8140
-<VirtualHost *:8140>
- SSLEngine On
-
- # Only allow high security cryptography. Alter if needed for compatibility.
- SSLProtocol All -SSLv2 -SSLv3
- SSLCipherSuite HIGH:!ADH:RC4+RSA:-MEDIUM:-LOW:-EXP
- SSLCertificateFile /var/lib/puppet/ssl/certs/<%= @fqdn %>.pem
- SSLCertificateKeyFile /var/lib/puppet/ssl/private_keys/<%= @fqdn %>.pem
- SSLCertificateChainFile /var/lib/puppet/ssl/ca/ca_crt.pem
- SSLCACertificateFile /var/lib/puppet/ssl/ca/ca_crt.pem
- SSLCARevocationFile /var/lib/puppet/ssl/ca/ca_crl.pem
- SSLVerifyClient optional
- SSLVerifyDepth 1
- SSLOptions +StdEnvVars +ExportCertData
-
- # This header needs to be set if using a loadbalancer or proxy
- RequestHeader unset X-Forwarded-For
-
- # These request headers are used to pass the client certificate
- # authentication information on to the puppet master process
- RequestHeader set X-SSL-Subject %{SSL_CLIENT_S_DN}e
- RequestHeader set X-Client-DN %{SSL_CLIENT_S_DN}e
- RequestHeader set X-Client-Verify %{SSL_CLIENT_VERIFY}e
-
- RackAutoDetect On
- DocumentRoot <%= @rack_dir %>/public/
- <Directory <%= @rack_dir %>/>
- Options None
- AllowOverride None
- Order Allow,Deny
- Allow from All
- </Directory>
-</VirtualHost>
diff --git a/templates/puppetmaster_default.erb b/templates/puppetmaster_default.erb
deleted file mode 100644
index 0987ec1..0000000
--- a/templates/puppetmaster_default.erb
+++ /dev/null
@@ -1,17 +0,0 @@
-# This file is being maintained by Puppet.
-# DO NOT EDIT
-#
-# Defaults for puppetmaster - sourced by /etc/init.d/puppetmaster
-
-# Enable puppetmaster service?
-# Setting this to "yes" allows the puppet master service to run.
-# Setting this to "no" keeps the puppet master service from running.
-#
-# If you are using Passenger, you should have this set to "no."
-START=no
-
-# Startup options
-DAEMON_OPTS=""
-
-# On what port should the puppet master listen? (default: 8140)
-PORT=8140
diff --git a/templates/puppetmaster_sysconfig.erb b/templates/puppetmaster_sysconfig.erb
deleted file mode 100644
index 54f6632..0000000
--- a/templates/puppetmaster_sysconfig.erb
+++ /dev/null
@@ -1,16 +0,0 @@
-# This file is being maintained by Puppet.
-# DO NOT EDIT
-
-# Location of the main manifest
-#PUPPETMASTER_MANIFEST=/etc/puppet/manifests/site.pp
-
-# Where to log general messages to.
-# Specify syslog to send log messages to the system log.
-#PUPPETMASTER_LOG=syslog
-
-# You may specify an alternate port on which your puppetmaster should listen. Default is: 8140
-# An example with puppetmaster on a different port, run with standard webrick servertype
-#PUPPETMASTER_PORTS="8141"
-
-# You may specify other parameters to the puppetmaster here
-#PUPPETMASTER_EXTRA_OPTS=--no-ca
diff --git a/templates/puppetserver_sysconfig.erb b/templates/puppetserver_sysconfig.erb
new file mode 100644
index 0000000..be8ae47
--- /dev/null
+++ b/templates/puppetserver_sysconfig.erb
@@ -0,0 +1,28 @@
+# This file is being maintained by Puppet.
+# DO NOT EDIT
+
+###########################################
+# Init settings for puppetserver
+###########################################
+
+# Location of your Java binary (version 7 or higher)
+JAVA_BIN="/usr/bin/java"
+
+# Modify this if you'd like to change the memory allocation, enable JMX, etc
+JAVA_ARGS="-Xms<%= @memory_size -%> -Xmx<%= @memory_size -%> -XX:MaxPermSize=256m"
+
+# These normally shouldn't need to be edited if using OS packages
+USER="puppet"
+GROUP="puppet"
+INSTALL_DIR="/opt/puppetlabs/server/apps/puppetserver"
+CONFIG="/etc/puppetlabs/puppetserver/conf.d"
+
+# Bootstrap path
+BOOTSTRAP_CONFIG="/etc/puppetlabs/puppetserver/services.d/,/opt/puppetlabs/server/apps/puppetserver/config/services.d/"
+
+SERVICE_STOP_RETRIES=60
+
+# START_TIMEOUT can be set here to alter the default startup timeout in
+# seconds. This is used in System-V style init scripts only, and will have no
+# effect in systemd.
+# START_TIMEOUT=300
diff --git a/tests/agent.pp b/tests/agent.pp
deleted file mode 100755
index 2d8a693..0000000
--- a/tests/agent.pp
+++ /dev/null
@@ -1 +0,0 @@
-include ::puppet::agent
diff --git a/tests/console/maintenance.pp b/tests/console/maintenance.pp
deleted file mode 100644
index 6b8fd3c..0000000
--- a/tests/console/maintenance.pp
+++ /dev/null
@@ -1 +0,0 @@
-include ::puppet::console::maintenance
diff --git a/tests/init.pp b/tests/init.pp
deleted file mode 100755
index aee8eec..0000000
--- a/tests/init.pp
+++ /dev/null
@@ -1,11 +0,0 @@
-# The baseline for module testing used by Puppet Labs is that each manifest
-# should have a corresponding test manifest that declares that class or defined
-# type.
-#
-# Tests are then run by using puppet apply --noop (to check for compilation errors
-# and view a log of events) or by fully applying the test in a virtual environment
-# (to compare the resulting system state to the desired state).
-#
-# Learn more about module testing here: http://docs.puppetlabs.com/guides/tests_smoke.html
-#
-include ::puppet
diff --git a/tests/master.pp b/tests/master.pp
deleted file mode 100644
index 42a1a75..0000000
--- a/tests/master.pp
+++ /dev/null
@@ -1 +0,0 @@
-include ::puppet::master
diff --git a/tests/master/maintenance.pp b/tests/master/maintenance.pp
deleted file mode 100644
index 85a47d4..0000000
--- a/tests/master/maintenance.pp
+++ /dev/null
@@ -1 +0,0 @@
-include ::puppet::master::maintenance
|
ghoneycutt/puppet-module-puppet
|
6dbd7ee6d58b2b8ab04976ee2332c82cf92fa540
|
Release v2.19.0 - Support Puppet v4 for agent
|
diff --git a/metadata.json b/metadata.json
index 215b42c..91bcc19 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.18.1",
+ "version": "2.19.0",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": ">= 3.2.0 < 5.0.0"
},
{
"name": "puppet",
"version_requirement": ">= 3.0.0 < 5.0.0"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.6.0 < 2.0.0"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1 < 2.0.0"},
{"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 6.0.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0 < 3.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.4.1 < 2.0.0"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0 < 2.0.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 1.7.1 < 2.0.0"},
{"name":"puppetlabs/concat","version_requirement":">= 1.2.5 < 2.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
a0652ffc2ae23628e7e3b5b7b569cc16bb2a5cc4
|
Fix puppet v4 compat with integer and string comparison
|
diff --git a/manifests/agent.pp b/manifests/agent.pp
index 444a8c2..c0c4af7 100644
--- a/manifests/agent.pp
+++ b/manifests/agent.pp
@@ -1,312 +1,312 @@
# == Class: puppet::agent
#
# Manage Puppet agents
#
# We also run puppet once at boot via cron, regardless of if you normally run
# puppet from cron or as a daemon.
#
class puppet::agent (
$certname = $::fqdn,
$config_path = 'USE_DEFAULTS',
$config_owner = 'root',
$config_group = 'root',
$config_mode = '0644',
$env = $::env,
$puppet_server = 'puppet',
$puppet_masterport = 'UNSET',
$puppet_ca_server = 'UNSET',
$http_proxy_host = 'UNSET',
$http_proxy_port = 'UNSET',
$is_puppet_master = false,
$run_method = 'USE_DEFAULTS',
$run_interval = '30',
$run_in_noop = false,
$cron_command = 'USE_DEFAULTS',
$run_at_boot = true,
$puppet_binary = 'USE_DEFAULTS',
$symlink_puppet_binary_target = '/usr/local/bin/puppet',
$symlink_puppet_binary = false,
$agent_sysconfig = 'USE_DEFAULTS',
$agent_sysconfig_ensure = 'USE_DEFAULTS',
$daemon_name = 'puppet',
$ssldir = 'USE_DEFAULTS',
$stringify_facts = true,
$etckeeper_hooks = false,
) {
if versioncmp($::puppetversion, '3.0') > 0 {
# puppet v4
$default_config_path = '/etc/puppetlabs/puppet/puppet.conf'
$default_cron_command = '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
$default_puppet_binary = '/opt/puppetlabs/bin/puppet'
$default_run_method = 'cron'
$is_puppet3 = false
} else {
# puppet v3
$default_config_path = '/etc/puppet/puppet.conf'
$default_cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
$default_puppet_binary = '/usr/bin/puppet'
$default_run_method = 'service'
$is_puppet3 = true
}
if $config_path == 'USE_DEFAULTS' {
$config_path_real = $default_config_path
} else {
$config_path_real = $config_path
}
validate_absolute_path($config_path_real)
if $cron_command == 'USE_DEFAULTS' {
$cron_command_real = $default_cron_command
} else {
$cron_command_real = $cron_command
}
validate_string($cron_command_real)
if $puppet_binary == 'USE_DEFAULTS' {
$puppet_binary_real = $default_puppet_binary
} else {
$puppet_binary_real = $puppet_binary
}
validate_absolute_path($puppet_binary_real)
if $run_method == 'USE_DEFAULTS' {
$run_method_real = $default_run_method
} else {
$run_method_real = $run_method
}
validate_string($run_method_real)
if is_string($run_in_noop) {
$run_in_noop_bool = str2bool($run_in_noop)
} else {
$run_in_noop_bool = $run_in_noop
}
validate_bool($run_in_noop_bool)
if is_string($run_at_boot) {
$run_at_boot_bool = str2bool($run_at_boot)
} else {
$run_at_boot_bool = $run_at_boot
}
validate_bool($run_at_boot_bool)
if is_string($is_puppet_master) {
$is_puppet_master_bool = str2bool($is_puppet_master)
} else {
$is_puppet_master_bool = $is_puppet_master
}
validate_bool($is_puppet_master_bool)
# env must be set, else fail, since we use it in the puppet_config template
if ! $env {
fail('puppet::agent::env must be set')
}
if $puppet_masterport != 'UNSET' and is_integer($puppet_masterport) == false {
fail("puppet::agent::puppet_masterport is set to <${puppet_masterport}>. It should be an integer.")
}
if $ssldir == 'USE_DEFAULTS' {
$ssldir_real = '$vardir/ssl'
} else {
validate_absolute_path($ssldir)
$ssldir_real = $ssldir
}
if is_string($stringify_facts) {
$stringify_facts_bool = str2bool($stringify_facts)
} else {
$stringify_facts_bool = $stringify_facts
}
validate_bool($stringify_facts_bool)
if is_string($etckeeper_hooks) {
$etckeeper_hooks_bool = str2bool($etckeeper_hooks)
} else {
$etckeeper_hooks_bool = $etckeeper_hooks
}
validate_bool($etckeeper_hooks_bool)
if $http_proxy_host != 'UNSET' and (is_domain_name($http_proxy_host) == false and is_ip_address($http_proxy_host) == false){
fail("puppet::agent::http_proxy_host is set to <${http_proxy_host}>. It should be a fqdn or an ip-address.")
}
if $http_proxy_port != 'UNSET' and is_integer($http_proxy_port) == false {
fail("puppet::agent::http_proxy_port is set to <${http_proxy_port}>. It should be an Integer.")
}
case $::osfamily {
'Debian': {
$default_agent_sysconfig = '/etc/default/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'RedHat': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'Solaris': {
$default_agent_sysconfig = undef
$default_agent_sysconfig_ensure = 'absent'
}
'Suse': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
default: {
fail("puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <${::osfamily}>.")
}
}
if $agent_sysconfig == 'USE_DEFAULTS' {
$agent_sysconfig_real = $default_agent_sysconfig
} else {
$agent_sysconfig_real = $agent_sysconfig
}
if $agent_sysconfig_ensure == 'USE_DEFAULTS' {
$agent_sysconfig_ensure_real = $default_agent_sysconfig_ensure
} else {
$agent_sysconfig_ensure_real = $agent_sysconfig_ensure
}
if $is_puppet_master_bool == false {
$config_content = template('puppet/puppetagent.conf.erb')
} else {
$config_content = undef
}
case $run_method_real {
'service': {
$daemon_ensure = 'running'
$daemon_enable = true
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
'cron': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_run_one = fqdn_rand($run_interval)
$cron_run_two = fqdn_rand($run_interval) + 30
$cron_ensure = 'present'
$cron_user = 'root'
$cron_hour = '*'
- if $run_interval > 30 {
+ if $run_interval > '30' {
$cron_minute = $cron_run_one
} else {
$cron_minute = [$cron_run_one, $cron_run_two]
}
if $run_in_noop_bool == true {
$my_cron_command = "${cron_command_real} --noop"
} else {
$my_cron_command = $cron_command_real
}
}
'disable': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
default: {
fail("puppet::agent::run_method is ${run_method_real} and must be 'disable', 'service' or 'cron'.")
}
}
if $run_at_boot_bool == true {
$at_boot_ensure = 'present'
} else {
$at_boot_ensure = 'absent'
}
if is_string($symlink_puppet_binary) {
$symlink_puppet_binary_bool = str2bool($symlink_puppet_binary)
} else {
$symlink_puppet_binary_bool = $symlink_puppet_binary
}
validate_bool($symlink_puppet_binary_bool)
validate_absolute_path($symlink_puppet_binary_target)
# optionally create symlinks to puppet binary
if $symlink_puppet_binary_bool == true {
file { 'puppet_symlink':
ensure => link,
path => $symlink_puppet_binary_target,
target => $puppet_binary_real,
}
}
file { 'puppet_config':
path => $config_path_real,
content => $config_content,
owner => $config_owner,
group => $config_group,
mode => $config_mode,
}
if ($etckeeper_hooks_bool) {
file { 'etckeeper_pre':
path => '/etc/puppet/etckeeper-commit-pre',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/puppet/etckeeper-commit-pre',
}
file { 'etckeeper_post':
path => '/etc/puppet/etckeeper-commit-post',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/puppet/etckeeper-commit-post',
}
}
if $default_agent_sysconfig_ensure =~ /(present)|(file)/ {
file { 'puppet_agent_sysconfig':
ensure => $agent_sysconfig_ensure_real,
path => $agent_sysconfig_real,
content => template('puppet/agent_sysconfig.erb'),
owner => 'root',
group => 'root',
mode => '0644',
}
}
service { 'puppet_agent_daemon':
# GH: This service will always show as being running while an agent run is
# taking place, so we no longer ensure its status. Before doing this, there
# would *always* be a logged change and the Console could never be green.
#ensure => $daemon_ensure,
name => $daemon_name,
enable => $daemon_enable,
}
cron { 'puppet_agent':
ensure => $cron_ensure,
command => $my_cron_command,
user => $cron_user,
hour => $cron_hour,
minute => $cron_minute,
}
if $run_method_real == 'cron' {
cron { 'puppet_agent_once_at_boot':
ensure => $at_boot_ensure,
command => $my_cron_command,
user => $cron_user,
special => 'reboot',
}
}
}
|
ghoneycutt/puppet-module-puppet
|
ab42ec5449e4102f0e3c2627ee27bc63e350c9b0
|
Support Puppet v4 for the agent
|
diff --git a/.fixtures.yml b/.fixtures.yml
index 2e11f1b..1226caf 100644
--- a/.fixtures.yml
+++ b/.fixtures.yml
@@ -1,26 +1,27 @@
fixtures:
repositories:
firewall:
repo: 'https://github.com/puppetlabs/puppetlabs-firewall.git'
- ref: '0.2.1'
+ ref: '1.7.1'
stdlib:
repo: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
ref: '4.6.0'
mysql:
repo: 'https://github.com/puppetlabs/puppetlabs-mysql.git'
ref: '2.0.1-rc1'
passenger:
repo: 'https://github.com/puppetlabs/puppetlabs-passenger.git'
- ref: '0.0.4'
+ ref: '0.4.1'
apache:
repo: 'https://github.com/puppetlabs/puppetlabs-apache.git'
ref: '0.5.0-rc1'
concat:
repo: 'https://github.com/puppetlabs/puppetlabs-concat.git'
- ref: '1.0.0'
+ ref: '1.2.5'
common:
repo: 'https://github.com/ghoneycutt/puppet-module-common.git'
+ ref: 'v1.6.0'
htpasswd:
repo: 'https://github.com/leinaddm/puppet-htpasswd.git'
symlinks:
puppet: "#{source_dir}"
diff --git a/.travis.yml b/.travis.yml
index 872d151..d7d70a2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,41 +1,41 @@
---
language: ruby
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
- 2.1.0
env:
matrix:
- PUPPET_GEM_VERSION="~> 3.1.0"
- PUPPET_GEM_VERSION="~> 3.2.0"
- PUPPET_GEM_VERSION="~> 3.3.0"
- PUPPET_GEM_VERSION="~> 3.4.0"
- PUPPET_GEM_VERSION="~> 3.5.1"
- PUPPET_GEM_VERSION="~> 3.6.0"
- PUPPET_GEM_VERSION="~> 3.7.0"
- PUPPET_GEM_VERSION="~> 3.8.0"
- PUPPET_GEM_VERSION="~> 3"
sudo: false
-script: 'bundle exec rake metadata_lint && bundle exec rake validate && bundle exec rake lint && SPEC_OPTS="--format documentation" bundle exec rake spec'
+script: 'bundle exec rake validate && bundle exec rake lint && SPEC_OPTS="--format documentation" bundle exec rake spec'
matrix:
fast_finish: true
exclude:
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.1.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.1.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.2.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.3.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.4.0"
notifications:
email: false
diff --git a/README.md b/README.md
index 47f12a0..577b0aa 100644
--- a/README.md
+++ b/README.md
@@ -1,521 +1,524 @@
# puppet-module-puppet #
===
[](https://travis-ci.org/ghoneycutt/puppet-module-puppet)
This module handles the various parts of puppet on a given machine.
Dependencies for this module are: apache, common, mysql and passenger
+This module is targeted at Puppet v3. It does support the agent on Puppet v4.
+To use the agent, simply `include ::puppet::agent`.
+
## Components ##
### Agent
---------
- Manages the puppet agent on a client
- Setup of configuration files
- Setup of service or crontask to run the agent periodically
- Ensure puppet agent is run at boottime
### Master
----------
- Manages apache with passenger
- Setup of config files needed to run master
- Calls the `puppet::lint` class
- Calls the `puppet::master::maintenance` class
- Manages firewall rule for puppet if needed
- Maintenance to purge filebucket and reports
### Dashboard
-------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This installation is used by puppet systems, that need access to the dashboard
### Dashboard Server
--------------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This is the actual server running the Dashboard
- Configures the Dashboard MySQL settings
- Creates database for puppet with mysql module
- Calls the `puppet::dashboard::maintenance` class
- Maintenance to clean up old reports, optimize database and dump database
- For the maintenance cron jobs, you should have the following line in your `/etc/sudoers` which is not managed with this module.
<pre>
Defaults:root !requiretty
</pre>
### Lint
--------
- Manages [puppet-lint](http://github.com/rodjek/puppet-lint)
## Compatibility ##
-------------------
Ruby versions 1.8.7, 1.9.3, 2.0.0 and 2.1.0 on Puppet v3.
### Puppet Master
-----------------
* Debian 6
* Debian 7
* EL 6
* Ubuntu 12.04 LTS
### Puppet Agent
----------------
* Debian 6
* Debian 7
* EL 6
* EL 7
* Solaris
* Suse 11
* Ubuntu 12.04 LTS
===
## Class `puppet::agent` ##
### Parameters ###
certname
--------
The certificate name for the client.
- *Default*: $::fqdn
config_path
-----------
The location of the puppet config file.
- *Default*: /etc/puppet/puppet.conf
config_owner
------------
The owner of the config file.
- *Default*: root
config_group
------------
The group for the config file.
- *Default*: root
config_mode
-----------
The mode for the config file.
- *Default*: 0644
env
---
The selected environment for the client.
- *Default*: $::env
puppet_server
-------------
The puppet server the client should connect to.
- *Default*: puppet
puppet_masterport
-----------------
The masterport setting in puppet.conf. By default this line is not set.
- *Default*: UNSET
puppet_ca_server
----------------
The puppet CA server the client should use
- *Default*: UNSET
http_proxy_host
---------------
The http-proxy the client should use
- *Default*: UNSET
http_proxy_port
----------------
The http-proxy port the client should use
- *Default*: UNSET
is_puppet_master
----------------
Whether the machine is a puppet master or not.
- *Default*: false
run_method
----------
Whether to run as a service or in cron mode. Valid values are `disable`, `cron`, and `service`. The value `disable` disables automatic puppet runs and assumes you are running as a service.
- *Default*: service
run_interval
------------
The interval, in minutes, with which the client should run. If greater than 30, the agent will only run once per hour.
- *Default*: 30
run_in_noop
-----------
Whether the client should run in noop mode or not.
- *Default*: false
cron_command
------------
The command that should be added to the crontab (in cron mode)
- *Default*: /usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay
run_at_boot
-----------
Whether the client should run right after boot
- *Default*: true
puppet_binary
-------------
Path to puppet binary to create symlink from
- *Default*: '/usr/bin/puppet'
symlink_puppet_binary_target
----------------------------
Path to where the symlink should be created
- *Default*: '/usr/local/bin/puppet'
symlink_puppet_binary
---------------------
Boolean for ensuring a symlink for puppet_binary to symlink_puppet_binary_target. This is useful if you install puppet in a non-standard location that is not in your $PATH.
- *Default*: false
agent_sysconfig
---------------
The location of puppet agent sysconfig file.
- *Default*: use defaults based on osfamily
agent_sysconfig_ensure
----------------------
String for 'file' or 'present'. Allows you to not manage the sysconfig file.
- *Default*: use defaults based on osfamily
daemon_name
-----------
The name the puppet agent daemon should run as.
- *Default*: puppet
ssldir
------
String with absolute path for ssldir in puppet agent's config. Using the default will set it to: '$vardir/ssl'
- *Default*: 'USE_DEFAULTS'
stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
- *Default*: true
etckeeper_hooks
---------------
Boolean to include pre- and postrun hooks for etckeeper in the main section of the puppet agent's config.
- *Default*: false
===
## Class `puppet::dashboard` ##
### Parameters ###
dashboard_package
-----------------
String or Array of the dashboard package(s) name.
- *Default*: 'puppet-dashboard'
dashboard_user
--------------
The user for dashboard installation.
- *Default*: use defaults based on osfamily
dashboard_group
--------------
The group for dashboard installation.
- *Default*: use defaults based on osfamily
sysconfig_path
-------------------
The location of puppet dashboard sysconfig file.
- *Default*: use defaults based on osfamily
external_node_script_path
-------------------------
The script to call from puppet to get manifests from dashboard.
- *Default*: /usr/share/puppet-dashboard/bin/external_node
dashboard_fqdn
--------------
The dashboard server FQDN.
- *Default*: puppet.${::domain}
port
----
The port the web server will respond to.
- *Default*: 3000
manage_mysql_options
--------------------
Boolean to use modules default mysql::server settings (mysql_max_packet_size).
For specific mysql::server settings you can use hiera now:
<pre>
puppet::dashboard::server::manage_mysql_options: false
mysql::server::override_options:
mysqld:
max_allowed_packet: '32M'
innodb_buffer_pool_size: '64M'
</pre>
- *Default*: true
===
## Class `puppet::dashboard::server` ##
### Usage ###
You can optionally specify a hash of htpasswd entries in Hiera.
<pre>
---
puppet::dashboard::htpasswd:
admin:
cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
puppet:
cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
</pre>
### Parameters ###
dashboard_workers
-----------------
Number of dashboard workers to start. Only used on osfamily Debian.
- *Default*: $::processorcount
database_config_path
--------------------
The path to the database config file.
- *Default*: /usr/share/puppet-dashboard/config/database.yml
database_config_owner
---------------------
The owner of the database config file.
- *Default*: puppet-dashboard
database_config_group
---------------------
The database config file group.
- *Default*: puppet-dashboard
database_config_mode
--------------------
The database config file mode.
- *Default*: 0640
htpasswd
--------
Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
- *Default*: undef
htpasswd_path
-------------
String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
- *Default*: `/etc/puppet/dashboard.htpasswd`
htpasswd_owner
--------------
Owner of htpasswd file.
- *Default*: root
htpasswd_group
--------------
Group of htpasswd file.
- *Default*: use defaults based on osfamily
htpasswd_mode
-------------
Mode of htpasswd file.
- *Default*: 0640
log_dir
-------
The location for the puppet log files.
- *Default*: /var/log/puppet
mysql_user
----------
The user for the mysql connection.
- *Default*: dashboard
mysql_password
--------------
The password for the mysql connection.
- *Default*: puppet
mysql_max_packet_size
---------------------
The mysql max packet size.
- *Default*: 32M
security
--------
String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
- *Default*: 'none'
vhost_path
----------
The location of puppet dashboard vhost file for apache.
- *Default*: use defaults based on osfamily
===
## Class `puppet::dashboard::maintenance` ##
### Parameters ###
db_optimization_command
-----------------------
The command to run to optimize the db.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
db_optimization_user
--------------------
The user to run db optimization.
- *Default*: root
db_optimization_hour
--------------------
The hour on which to run db optimization.
- *Default*: 0
db_optimization_minute
----------------------
The minute at which to run db optimization.
- *Default*: 0
db_optimization_monthday
------------------------
The day of the month on which to run db optimization.
- *Default*: 1
reports_days_to_keep
--------------------
How many days to keep the reports.
- *Default*: 30
purge_old_reports_command
-------------------------
Which command to run to purge old reports.
Defaults to: '/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=${reports_days_to_keep} unit=day >> /var/log/puppet/dashboard_maintenance.log'
If using a specific command here, please keep in mind you need to align it with $reports_days_to_keep yourself.
- *Default*: 'USE_DEFAULTS'
purge_old_reports_user
----------------------
User to purge reports as.
- *Default*: root
purge_old_reports_hour
----------------------
On which hour to purge old reports.
- *Default*: 0
purge_old_reports_minute
------------------------
At which minute to purge old reports.
- *Default*: 30
remove_old_reports_spool
------------------------
Whether we should remove old dashboard reports that have not been imported
- *Default*: 'True'
reports_spool_dir
-----------------
Path to reports in dashboard spool
- *Default*: '/usr/share/puppet-dashboard/spool'
reports_spool_days_to_keep
--------------------------
How many days to keep the unimported reports.
remove_reports_spool_user
-------------------------
User to remove unimported reports.
- *Default*: root
remove_reports_spool_hour
-------------------------
On which hour to remove unimported reports.
- *Default*: 0
remove_reports_spool_minute
---------------------------
At which minute to remove unimported reports
- *Default*: 45
dump_dir
--------
The directory to use for dumps.
- *Default*: /var/local
dump_database_command
---------------------
The command to run to dump the database.
diff --git a/manifests/agent.pp b/manifests/agent.pp
index da3cce4..444a8c2 100644
--- a/manifests/agent.pp
+++ b/manifests/agent.pp
@@ -1,269 +1,312 @@
# == Class: puppet::agent
#
# Manage Puppet agents
#
# We also run puppet once at boot via cron, regardless of if you normally run
# puppet from cron or as a daemon.
#
class puppet::agent (
$certname = $::fqdn,
- $config_path = '/etc/puppet/puppet.conf',
+ $config_path = 'USE_DEFAULTS',
$config_owner = 'root',
$config_group = 'root',
$config_mode = '0644',
$env = $::env,
$puppet_server = 'puppet',
$puppet_masterport = 'UNSET',
$puppet_ca_server = 'UNSET',
$http_proxy_host = 'UNSET',
$http_proxy_port = 'UNSET',
$is_puppet_master = false,
- $run_method = 'service',
+ $run_method = 'USE_DEFAULTS',
$run_interval = '30',
$run_in_noop = false,
- $cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay',
+ $cron_command = 'USE_DEFAULTS',
$run_at_boot = true,
- $puppet_binary = '/usr/bin/puppet',
+ $puppet_binary = 'USE_DEFAULTS',
$symlink_puppet_binary_target = '/usr/local/bin/puppet',
$symlink_puppet_binary = false,
$agent_sysconfig = 'USE_DEFAULTS',
$agent_sysconfig_ensure = 'USE_DEFAULTS',
$daemon_name = 'puppet',
$ssldir = 'USE_DEFAULTS',
$stringify_facts = true,
$etckeeper_hooks = false,
) {
+ if versioncmp($::puppetversion, '3.0') > 0 {
+ # puppet v4
+ $default_config_path = '/etc/puppetlabs/puppet/puppet.conf'
+ $default_cron_command = '/opt/puppetlabs/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
+ $default_puppet_binary = '/opt/puppetlabs/bin/puppet'
+ $default_run_method = 'cron'
+ $is_puppet3 = false
+ } else {
+ # puppet v3
+ $default_config_path = '/etc/puppet/puppet.conf'
+ $default_cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
+ $default_puppet_binary = '/usr/bin/puppet'
+ $default_run_method = 'service'
+ $is_puppet3 = true
+ }
+
+ if $config_path == 'USE_DEFAULTS' {
+ $config_path_real = $default_config_path
+ } else {
+ $config_path_real = $config_path
+ }
+ validate_absolute_path($config_path_real)
+
+ if $cron_command == 'USE_DEFAULTS' {
+ $cron_command_real = $default_cron_command
+ } else {
+ $cron_command_real = $cron_command
+ }
+ validate_string($cron_command_real)
+
+ if $puppet_binary == 'USE_DEFAULTS' {
+ $puppet_binary_real = $default_puppet_binary
+ } else {
+ $puppet_binary_real = $puppet_binary
+ }
+ validate_absolute_path($puppet_binary_real)
+
+ if $run_method == 'USE_DEFAULTS' {
+ $run_method_real = $default_run_method
+ } else {
+ $run_method_real = $run_method
+ }
+ validate_string($run_method_real)
+
if is_string($run_in_noop) {
$run_in_noop_bool = str2bool($run_in_noop)
} else {
$run_in_noop_bool = $run_in_noop
}
validate_bool($run_in_noop_bool)
if is_string($run_at_boot) {
$run_at_boot_bool = str2bool($run_at_boot)
} else {
$run_at_boot_bool = $run_at_boot
}
validate_bool($run_at_boot_bool)
if is_string($is_puppet_master) {
$is_puppet_master_bool = str2bool($is_puppet_master)
} else {
$is_puppet_master_bool = $is_puppet_master
}
validate_bool($is_puppet_master_bool)
# env must be set, else fail, since we use it in the puppet_config template
if ! $env {
fail('puppet::agent::env must be set')
}
if $puppet_masterport != 'UNSET' and is_integer($puppet_masterport) == false {
fail("puppet::agent::puppet_masterport is set to <${puppet_masterport}>. It should be an integer.")
}
if $ssldir == 'USE_DEFAULTS' {
$ssldir_real = '$vardir/ssl'
} else {
validate_absolute_path($ssldir)
$ssldir_real = $ssldir
}
if is_string($stringify_facts) {
$stringify_facts_bool = str2bool($stringify_facts)
} else {
$stringify_facts_bool = $stringify_facts
}
validate_bool($stringify_facts_bool)
if is_string($etckeeper_hooks) {
$etckeeper_hooks_bool = str2bool($etckeeper_hooks)
} else {
$etckeeper_hooks_bool = $etckeeper_hooks
}
validate_bool($etckeeper_hooks_bool)
if $http_proxy_host != 'UNSET' and (is_domain_name($http_proxy_host) == false and is_ip_address($http_proxy_host) == false){
fail("puppet::agent::http_proxy_host is set to <${http_proxy_host}>. It should be a fqdn or an ip-address.")
}
if $http_proxy_port != 'UNSET' and is_integer($http_proxy_port) == false {
fail("puppet::agent::http_proxy_port is set to <${http_proxy_port}>. It should be an Integer.")
}
case $::osfamily {
'Debian': {
$default_agent_sysconfig = '/etc/default/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'RedHat': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'Solaris': {
$default_agent_sysconfig = undef
$default_agent_sysconfig_ensure = 'absent'
}
'Suse': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
default: {
fail("puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <${::osfamily}>.")
}
}
if $agent_sysconfig == 'USE_DEFAULTS' {
$agent_sysconfig_real = $default_agent_sysconfig
} else {
$agent_sysconfig_real = $agent_sysconfig
}
if $agent_sysconfig_ensure == 'USE_DEFAULTS' {
$agent_sysconfig_ensure_real = $default_agent_sysconfig_ensure
} else {
$agent_sysconfig_ensure_real = $agent_sysconfig_ensure
}
if $is_puppet_master_bool == false {
$config_content = template('puppet/puppetagent.conf.erb')
} else {
$config_content = undef
}
- case $run_method {
+ case $run_method_real {
'service': {
$daemon_ensure = 'running'
$daemon_enable = true
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
'cron': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_run_one = fqdn_rand($run_interval)
$cron_run_two = fqdn_rand($run_interval) + 30
$cron_ensure = 'present'
$cron_user = 'root'
$cron_hour = '*'
if $run_interval > 30 {
$cron_minute = $cron_run_one
} else {
$cron_minute = [$cron_run_one, $cron_run_two]
}
if $run_in_noop_bool == true {
- $my_cron_command = "${cron_command} --noop"
+ $my_cron_command = "${cron_command_real} --noop"
} else {
- $my_cron_command = $cron_command
+ $my_cron_command = $cron_command_real
}
}
'disable': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
default: {
- fail("puppet::agent::run_method is ${run_method} and must be 'disable', 'service' or 'cron'.")
+ fail("puppet::agent::run_method is ${run_method_real} and must be 'disable', 'service' or 'cron'.")
}
}
if $run_at_boot_bool == true {
$at_boot_ensure = 'present'
} else {
$at_boot_ensure = 'absent'
}
if is_string($symlink_puppet_binary) {
$symlink_puppet_binary_bool = str2bool($symlink_puppet_binary)
} else {
$symlink_puppet_binary_bool = $symlink_puppet_binary
}
validate_bool($symlink_puppet_binary_bool)
- validate_absolute_path($puppet_binary)
validate_absolute_path($symlink_puppet_binary_target)
# optionally create symlinks to puppet binary
if $symlink_puppet_binary_bool == true {
file { 'puppet_symlink':
ensure => link,
path => $symlink_puppet_binary_target,
- target => $puppet_binary,
+ target => $puppet_binary_real,
}
}
file { 'puppet_config':
- path => $config_path,
+ path => $config_path_real,
content => $config_content,
owner => $config_owner,
group => $config_group,
mode => $config_mode,
}
if ($etckeeper_hooks_bool) {
file { 'etckeeper_pre':
path => '/etc/puppet/etckeeper-commit-pre',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/puppet/etckeeper-commit-pre',
}
file { 'etckeeper_post':
path => '/etc/puppet/etckeeper-commit-post',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/puppet/etckeeper-commit-post',
}
}
if $default_agent_sysconfig_ensure =~ /(present)|(file)/ {
file { 'puppet_agent_sysconfig':
ensure => $agent_sysconfig_ensure_real,
path => $agent_sysconfig_real,
content => template('puppet/agent_sysconfig.erb'),
owner => 'root',
group => 'root',
mode => '0644',
}
}
service { 'puppet_agent_daemon':
# GH: This service will always show as being running while an agent run is
# taking place, so we no longer ensure its status. Before doing this, there
# would *always* be a logged change and the Console could never be green.
#ensure => $daemon_ensure,
name => $daemon_name,
enable => $daemon_enable,
}
cron { 'puppet_agent':
ensure => $cron_ensure,
command => $my_cron_command,
user => $cron_user,
hour => $cron_hour,
minute => $cron_minute,
}
- if $run_method == 'cron' {
+ if $run_method_real == 'cron' {
cron { 'puppet_agent_once_at_boot':
ensure => $at_boot_ensure,
command => $my_cron_command,
user => $cron_user,
special => 'reboot',
}
}
}
diff --git a/metadata.json b/metadata.json
index 689b216..215b42c 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
"version": "2.18.1",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": ">= 3.2.0 < 5.0.0"
},
{
"name": "puppet",
"version_requirement": ">= 3.0.0 < 5.0.0"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"dependencies": [
- {"name":"ghoneycutt/common","version_requirement":">= 1.0.3 < 2.0.0"},
+ {"name":"ghoneycutt/common","version_requirement":">= 1.6.0 < 2.0.0"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1 < 2.0.0"},
{"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 6.0.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0 < 3.0.0"},
- {"name":"puppetlabs/passenger","version_requirement":">= 0.0.4 < 2.0.0"},
+ {"name":"puppetlabs/passenger","version_requirement":">= 0.4.1 < 2.0.0"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0 < 2.0.0"},
- {"name":"puppetlabs/firewall","version_requirement":">= 0.2.1 < 2.0.0"},
- {"name":"puppetlabs/concat","version_requirement":">= 1.0.0 < 2.0.0"}
+ {"name":"puppetlabs/firewall","version_requirement":">= 1.7.1 < 2.0.0"},
+ {"name":"puppetlabs/concat","version_requirement":">= 1.2.5 < 2.0.0"}
]
}
diff --git a/templates/puppetagent.conf.erb b/templates/puppetagent.conf.erb
index a2252b9..d564cbe 100644
--- a/templates/puppetagent.conf.erb
+++ b/templates/puppetagent.conf.erb
@@ -1,64 +1,74 @@
# This file is being maintained by Puppet.
# DO NOT EDIT
+<% if @is_puppet3 == true -%>
[main]
# The Puppet log directory.
# The default value is '$vardir/log'.
logdir = /var/log/puppet
# Where Puppet PID files are kept.
# The default value is '$vardir/run'.
rundir = /var/run/puppet
# Where SSL certificates are kept.
# The default value is '$confdir/ssl'.
ssldir = <%= @ssldir_real %>
archive_files = true
archive_file_server = <%= @puppet_server %>
# If stringify_facts is true, you have the classic facter fact that is
# always a string. If set to false, then you can use structured facts which
# were introduced in Facter v2
stringify_facts = <%= @stringify_facts_bool %>
<% if @etckeeper_hooks_bool == true %>
prerun_command=/etc/puppet/etckeeper-commit-pre
postrun_command=/etc/puppet/etckeeper-commit-post
<% end -%>
[agent]
# The file in which puppetd stores a list of the classes
# associated with the retrieved configuratiion. Can be loaded in
# the separate ``puppet`` executable using the ``--loadclasses``
# option.
# The default value is '$confdir/classes.txt'.
classfile = $vardir/classes.txt
# Where puppetd caches the local configuration. An
# extension indicating the cache format is added automatically.
# The default value is '$confdir/localconfig'.
localconfig = $vardir/localconfig
certname = <%= @certname %>
server = <%= @puppet_server %>
<% if @puppet_masterport != 'UNSET' -%>
masterport = <%= @puppet_masterport %>
<% end -%>
<% if @puppet_ca_server != 'UNSET' -%>
ca_server = <%= @puppet_ca_server %>
<% end -%>
<% if @http_proxy_host != 'UNSET' -%>
http_proxy_host = <%= @http_proxy_host %>
<% end -%>
<% if @http_proxy_port != 'UNSET' -%>
http_proxy_port = <%= @http_proxy_port %>
<% end -%>
report = true
graph = true
pluginsync = true
-<% if @run_method == 'service' %>
+<% if @run_method_real == 'service' %>
noop = <%= @run_in_noop %>
<% end -%>
<% if @env != 'production' -%>
environment = <%= @env %>
<% end -%>
+<% else -%>
+ [main]
+ certname = <%= @certname %>
+ server = <%= @puppet_server %>
+ <% if @puppet_ca_server != 'UNSET' -%>
+ ca_server = <%= @puppet_ca_server %>
+ <% end -%>
+ graph = true
+<% end -%>
|
ghoneycutt/puppet-module-puppet
|
61264a26442cdccfe42231b9d8fcd42aa8128e39
|
Release v2.18.1 - Bug fix for style and continue supporting software
|
diff --git a/metadata.json b/metadata.json
index cc09c1f..689b216 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.18.0",
+ "version": "2.18.1",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": ">= 3.2.0 < 5.0.0"
},
{
"name": "puppet",
"version_requirement": ">= 3.0.0 < 5.0.0"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3 < 2.0.0"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1 < 2.0.0"},
{"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 6.0.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0 < 3.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4 < 2.0.0"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0 < 2.0.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1 < 2.0.0"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0 < 2.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
e6d91606510836ffa8e36723f580966d3903282e
|
Style fix
|
diff --git a/manifests/dashboard/maintenance.pp b/manifests/dashboard/maintenance.pp
index 40ecfa0..0077a7f 100644
--- a/manifests/dashboard/maintenance.pp
+++ b/manifests/dashboard/maintenance.pp
@@ -1,108 +1,108 @@
# == Class: puppet::dashboard::maintenance
#
class puppet::dashboard::maintenance (
$db_optimization_command = '/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log',
$db_optimization_user = 'root',
$db_optimization_hour = '0',
$db_optimization_minute = '0',
$db_optimization_monthday = '1',
$reports_days_to_keep = '30',
$purge_old_reports_command = 'USE_DEFAULTS',
$purge_old_reports_user = 'root',
$purge_old_reports_hour = '0',
$purge_old_reports_minute = '30',
$remove_old_reports_spool = true,
$reports_spool_dir = '/usr/share/puppet-dashboard/spool',
$reports_spool_days_to_keep = '7',
$remove_reports_spool_user = 'root',
$remove_reports_spool_hour = '0',
$remove_reports_spool_minute = '45',
$dump_dir = '/var/local',
$dump_database_command = 'USE_DEFAULTS',
$dump_database_user = 'root',
$dump_database_hour = '1',
$dump_database_minute = '0',
$days_to_keep_backups = '7',
$purge_old_db_backups_user = 'root',
$purge_old_db_backups_hour = '2',
$purge_old_db_backups_minute = '0',
) {
- require 'puppet::dashboard'
+ require '::puppet::dashboard'
validate_absolute_path($reports_spool_dir)
validate_absolute_path($dump_dir)
validate_string($dump_database_command)
validate_integer($reports_days_to_keep)
$purge_old_reports_command_real = $purge_old_reports_command ? {
'USE_DEFAULTS' => "/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=${reports_days_to_keep} unit=day >> /var/log/puppet/dashboard_maintenance.log",
default => $purge_old_reports_command
}
$dump_database_command_real = $dump_database_command ? {
'USE_DEFAULTS' => "cd ~puppet-dashboard && sudo -u ${puppet::dashboard::dashboard_user_real} /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=${dump_dir}/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 ${dump_dir}/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1",
default => $dump_database_command
}
common::mkdir_p { $dump_dir: }
file { $dump_dir:
ensure => directory,
group => $puppet::dashboard::dashboard_group_real,
mode => '0775',
require => Common::Mkdir_p[$dump_dir],
}
cron { 'monthly_dashboard_database_optimization':
ensure => present,
command => $db_optimization_command,
user => $db_optimization_user,
hour => $db_optimization_hour,
minute => $db_optimization_minute,
monthday => $db_optimization_monthday,
}
cron { 'purge_old_reports':
ensure => present,
command => $purge_old_reports_command_real,
user => $purge_old_reports_user,
hour => $purge_old_reports_hour,
minute => $purge_old_reports_minute,
}
if is_string($remove_old_reports_spool) {
$enable_remove_old_reports_spool = str2bool($remove_old_reports_spool)
} else {
$enable_remove_old_reports_spool = $remove_old_reports_spool
}
validate_bool($enable_remove_old_reports_spool)
if $enable_remove_old_reports_spool == true {
$remove_old_reports_spool_enable = 'present'
} else {
$remove_old_reports_spool_enable = 'absent'
}
cron { 'remove_old_reports_spool':
ensure => $remove_old_reports_spool_enable,
command => "/bin/find ${reports_spool_dir} -type f -name \"*.yaml\" -mtime +${$reports_spool_days_to_keep } -exec /bin/rm -f {} \\;",
user => $remove_reports_spool_user,
hour => $remove_reports_spool_hour,
minute => $remove_reports_spool_minute,
}
cron { 'dump_dashboard_database':
command => $dump_database_command_real,
user => $dump_database_user,
hour => $dump_database_hour,
minute => $dump_database_minute,
}
cron { 'purge_old_db_backups':
command => "/bin/find ${dump_dir} -type f -mtime +${days_to_keep_backups} -exec /bin/rm -f {} \\;",
user => $purge_old_db_backups_user,
hour => $purge_old_db_backups_hour,
minute => $purge_old_db_backups_minute,
}
}
|
ghoneycutt/puppet-module-puppet
|
2292dfb36925416dc6bace2cac8e2a5584785921
|
Pin version of json to continue supporting ruby versions < 2
|
diff --git a/Gemfile b/Gemfile
index d6bdad9..eea8e8e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,29 +1,33 @@
source 'https://rubygems.org'
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
gem 'metadata-json-lint'
gem 'puppetlabs_spec_helper', '>= 1.1.1'
gem 'facter', '>= 1.7.0'
gem 'puppet-lint', '>= 1.0', '< 3.0'
gem 'puppet-lint-absolute_classname-check'
gem 'puppet-lint-alias-check'
gem 'puppet-lint-empty_string-check'
gem 'puppet-lint-file_ensure-check'
gem 'puppet-lint-file_source_rights-check'
gem 'puppet-lint-leading_zero-check'
gem 'puppet-lint-spaceship_operator_without_tag-check'
gem 'puppet-lint-trailing_comma-check'
gem 'puppet-lint-undef_in_function-check'
gem 'puppet-lint-unquoted_string-check'
gem 'puppet-lint-variable_contains_upcase'
# rspec must be v2 for ruby 1.8.7
if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
gem 'rspec', '~> 2.0'
gem 'rake', '~> 10.0'
end
+
+if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '2.0'
+ gem 'json', '~> 1.0'
+end
|
ghoneycutt/puppet-module-puppet
|
b69e2b458526792f47688cf56bb59b3029782e23
|
Allow for puppet-lint v1 or v2, as the community plugins allow
|
diff --git a/Gemfile b/Gemfile
index e6cceaf..d6bdad9 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,29 +1,29 @@
source 'https://rubygems.org'
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
gem 'metadata-json-lint'
gem 'puppetlabs_spec_helper', '>= 1.1.1'
gem 'facter', '>= 1.7.0'
-gem 'puppet-lint', :git => 'https://github.com/rodjek/puppet-lint.git'
+gem 'puppet-lint', '>= 1.0', '< 3.0'
gem 'puppet-lint-absolute_classname-check'
gem 'puppet-lint-alias-check'
gem 'puppet-lint-empty_string-check'
gem 'puppet-lint-file_ensure-check'
gem 'puppet-lint-file_source_rights-check'
gem 'puppet-lint-leading_zero-check'
gem 'puppet-lint-spaceship_operator_without_tag-check'
gem 'puppet-lint-trailing_comma-check'
gem 'puppet-lint-undef_in_function-check'
gem 'puppet-lint-unquoted_string-check'
gem 'puppet-lint-variable_contains_upcase'
# rspec must be v2 for ruby 1.8.7
if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
gem 'rspec', '~> 2.0'
gem 'rake', '~> 10.0'
end
|
ghoneycutt/puppet-module-puppet
|
2d91161447aca8a24d2f3f0f4515985fcbc89e5e
|
Bump year in LICENSE for 2016
|
diff --git a/LICENSE b/LICENSE
index 00f0e3f..bb5ebbd 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,13 +1,13 @@
-Copyright (C) 2010-2015 Garrett Honeycutt <[email protected]>
+Copyright (C) 2010-2016 Garrett Honeycutt <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
ghoneycutt/puppet-module-puppet
|
e2c162cfa56b526cb07f218b22f8a312fc602e26
|
Release v2.18.0 - Add ability to specify passenger max requests
|
diff --git a/metadata.json b/metadata.json
index 7ccf3a4..cc09c1f 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.17.1",
+ "version": "2.18.0",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": ">= 3.2.0 < 5.0.0"
},
{
"name": "puppet",
"version_requirement": ">= 3.0.0 < 5.0.0"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3 < 2.0.0"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1 < 2.0.0"},
{"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 6.0.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0 < 3.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4 < 2.0.0"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0 < 2.0.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1 < 2.0.0"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0 < 2.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
a881209f4bd30c07a94da82ec65351fb2fa3a69c
|
Release v2.17.1 - Modernize testing and support
|
diff --git a/metadata.json b/metadata.json
index 086936e..7ccf3a4 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.17.0",
+ "version": "2.17.1",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": ">= 3.2.0 < 5.0.0"
},
{
"name": "puppet",
"version_requirement": ">= 3.0.0 < 5.0.0"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3 < 2.0.0"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1 < 2.0.0"},
{"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 6.0.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0 < 3.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4 < 2.0.0"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0 < 2.0.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1 < 2.0.0"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0 < 2.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
5a6f25c843a488ac85e6534c33b144ddc0426d03
|
Use community style plugins and adapt to those
|
diff --git a/Gemfile b/Gemfile
index 3920f70..e6cceaf 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,18 +1,29 @@
source 'https://rubygems.org'
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
gem 'metadata-json-lint'
gem 'puppetlabs_spec_helper', '>= 1.1.1'
-gem 'puppet-lint', '>= 1.0.0'
gem 'facter', '>= 1.7.0'
+gem 'puppet-lint', :git => 'https://github.com/rodjek/puppet-lint.git'
+gem 'puppet-lint-absolute_classname-check'
+gem 'puppet-lint-alias-check'
+gem 'puppet-lint-empty_string-check'
+gem 'puppet-lint-file_ensure-check'
+gem 'puppet-lint-file_source_rights-check'
+gem 'puppet-lint-leading_zero-check'
+gem 'puppet-lint-spaceship_operator_without_tag-check'
+gem 'puppet-lint-trailing_comma-check'
+gem 'puppet-lint-undef_in_function-check'
+gem 'puppet-lint-unquoted_string-check'
+gem 'puppet-lint-variable_contains_upcase'
# rspec must be v2 for ruby 1.8.7
if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
gem 'rspec', '~> 2.0'
gem 'rake', '~> 10.0'
end
diff --git a/Rakefile b/Rakefile
index e2c6d52..f2f0456 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,18 +1,19 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.send('disable_80chars')
+PuppetLint.configuration.send('disable_140chars')
PuppetLint.configuration.relative = true
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
desc 'Validate manifests, templates, and ruby files'
task :validate do
Dir['manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}"
end
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
end
Dir['templates/**/*.erb'].each do |template|
sh "erb -P -x -T '-' #{template} | ruby -c"
end
end
diff --git a/manifests/agent.pp b/manifests/agent.pp
index 2695e22..da3cce4 100644
--- a/manifests/agent.pp
+++ b/manifests/agent.pp
@@ -1,269 +1,269 @@
# == Class: puppet::agent
#
# Manage Puppet agents
#
# We also run puppet once at boot via cron, regardless of if you normally run
# puppet from cron or as a daemon.
#
class puppet::agent (
$certname = $::fqdn,
$config_path = '/etc/puppet/puppet.conf',
$config_owner = 'root',
$config_group = 'root',
$config_mode = '0644',
$env = $::env,
$puppet_server = 'puppet',
$puppet_masterport = 'UNSET',
$puppet_ca_server = 'UNSET',
$http_proxy_host = 'UNSET',
$http_proxy_port = 'UNSET',
$is_puppet_master = false,
$run_method = 'service',
$run_interval = '30',
$run_in_noop = false,
$cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay',
$run_at_boot = true,
$puppet_binary = '/usr/bin/puppet',
$symlink_puppet_binary_target = '/usr/local/bin/puppet',
$symlink_puppet_binary = false,
$agent_sysconfig = 'USE_DEFAULTS',
$agent_sysconfig_ensure = 'USE_DEFAULTS',
$daemon_name = 'puppet',
$ssldir = 'USE_DEFAULTS',
$stringify_facts = true,
$etckeeper_hooks = false,
) {
if is_string($run_in_noop) {
$run_in_noop_bool = str2bool($run_in_noop)
} else {
$run_in_noop_bool = $run_in_noop
}
validate_bool($run_in_noop_bool)
if is_string($run_at_boot) {
$run_at_boot_bool = str2bool($run_at_boot)
} else {
$run_at_boot_bool = $run_at_boot
}
validate_bool($run_at_boot_bool)
if is_string($is_puppet_master) {
$is_puppet_master_bool = str2bool($is_puppet_master)
} else {
$is_puppet_master_bool = $is_puppet_master
}
validate_bool($is_puppet_master_bool)
# env must be set, else fail, since we use it in the puppet_config template
if ! $env {
fail('puppet::agent::env must be set')
}
if $puppet_masterport != 'UNSET' and is_integer($puppet_masterport) == false {
fail("puppet::agent::puppet_masterport is set to <${puppet_masterport}>. It should be an integer.")
}
if $ssldir == 'USE_DEFAULTS' {
$ssldir_real = '$vardir/ssl'
} else {
validate_absolute_path($ssldir)
$ssldir_real = $ssldir
}
if is_string($stringify_facts) {
$stringify_facts_bool = str2bool($stringify_facts)
} else {
$stringify_facts_bool = $stringify_facts
}
validate_bool($stringify_facts_bool)
if is_string($etckeeper_hooks) {
$etckeeper_hooks_bool = str2bool($etckeeper_hooks)
} else {
$etckeeper_hooks_bool = $etckeeper_hooks
}
validate_bool($etckeeper_hooks_bool)
if $http_proxy_host != 'UNSET' and (is_domain_name($http_proxy_host) == false and is_ip_address($http_proxy_host) == false){
fail("puppet::agent::http_proxy_host is set to <${http_proxy_host}>. It should be a fqdn or an ip-address.")
}
if $http_proxy_port != 'UNSET' and is_integer($http_proxy_port) == false {
fail("puppet::agent::http_proxy_port is set to <${http_proxy_port}>. It should be an Integer.")
}
case $::osfamily {
'Debian': {
$default_agent_sysconfig = '/etc/default/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'RedHat': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'Solaris': {
$default_agent_sysconfig = undef
$default_agent_sysconfig_ensure = 'absent'
}
'Suse': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
default: {
fail("puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <${::osfamily}>.")
}
}
if $agent_sysconfig == 'USE_DEFAULTS' {
$agent_sysconfig_real = $default_agent_sysconfig
} else {
$agent_sysconfig_real = $agent_sysconfig
}
if $agent_sysconfig_ensure == 'USE_DEFAULTS' {
$agent_sysconfig_ensure_real = $default_agent_sysconfig_ensure
} else {
$agent_sysconfig_ensure_real = $agent_sysconfig_ensure
}
if $is_puppet_master_bool == false {
$config_content = template('puppet/puppetagent.conf.erb')
} else {
$config_content = undef
}
case $run_method {
'service': {
$daemon_ensure = 'running'
$daemon_enable = true
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
'cron': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_run_one = fqdn_rand($run_interval)
$cron_run_two = fqdn_rand($run_interval) + 30
$cron_ensure = 'present'
$cron_user = 'root'
$cron_hour = '*'
if $run_interval > 30 {
$cron_minute = $cron_run_one
} else {
$cron_minute = [$cron_run_one, $cron_run_two]
}
if $run_in_noop_bool == true {
$my_cron_command = "${cron_command} --noop"
} else {
$my_cron_command = $cron_command
}
}
'disable': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
default: {
fail("puppet::agent::run_method is ${run_method} and must be 'disable', 'service' or 'cron'.")
}
}
if $run_at_boot_bool == true {
$at_boot_ensure = 'present'
} else {
$at_boot_ensure = 'absent'
}
if is_string($symlink_puppet_binary) {
$symlink_puppet_binary_bool = str2bool($symlink_puppet_binary)
} else {
$symlink_puppet_binary_bool = $symlink_puppet_binary
}
validate_bool($symlink_puppet_binary_bool)
validate_absolute_path($puppet_binary)
validate_absolute_path($symlink_puppet_binary_target)
# optionally create symlinks to puppet binary
if $symlink_puppet_binary_bool == true {
file { 'puppet_symlink':
ensure => link,
path => $symlink_puppet_binary_target,
target => $puppet_binary,
}
}
file { 'puppet_config':
path => $config_path,
content => $config_content,
owner => $config_owner,
group => $config_group,
mode => $config_mode,
}
if ($etckeeper_hooks_bool) {
file { 'etckeeper_pre':
path => '/etc/puppet/etckeeper-commit-pre',
owner => 'root',
group => 'root',
mode => '0755',
- source => 'puppet:///modules/puppet/etckeeper-commit-pre'
+ source => 'puppet:///modules/puppet/etckeeper-commit-pre',
}
file { 'etckeeper_post':
path => '/etc/puppet/etckeeper-commit-post',
owner => 'root',
group => 'root',
mode => '0755',
- source => 'puppet:///modules/puppet/etckeeper-commit-post'
+ source => 'puppet:///modules/puppet/etckeeper-commit-post',
}
}
if $default_agent_sysconfig_ensure =~ /(present)|(file)/ {
file { 'puppet_agent_sysconfig':
ensure => $agent_sysconfig_ensure_real,
path => $agent_sysconfig_real,
content => template('puppet/agent_sysconfig.erb'),
owner => 'root',
group => 'root',
mode => '0644',
}
}
service { 'puppet_agent_daemon':
# GH: This service will always show as being running while an agent run is
# taking place, so we no longer ensure its status. Before doing this, there
# would *always* be a logged change and the Console could never be green.
#ensure => $daemon_ensure,
name => $daemon_name,
enable => $daemon_enable,
}
cron { 'puppet_agent':
ensure => $cron_ensure,
command => $my_cron_command,
user => $cron_user,
hour => $cron_hour,
minute => $cron_minute,
}
if $run_method == 'cron' {
cron { 'puppet_agent_once_at_boot':
ensure => $at_boot_ensure,
command => $my_cron_command,
user => $cron_user,
special => 'reboot',
}
}
}
diff --git a/manifests/dashboard/maintenance.pp b/manifests/dashboard/maintenance.pp
index 6ce7fb9..40ecfa0 100644
--- a/manifests/dashboard/maintenance.pp
+++ b/manifests/dashboard/maintenance.pp
@@ -1,109 +1,108 @@
# == Class: puppet::dashboard::maintenance
#
class puppet::dashboard::maintenance (
$db_optimization_command = '/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log',
$db_optimization_user = 'root',
$db_optimization_hour = '0',
$db_optimization_minute = '0',
$db_optimization_monthday = '1',
$reports_days_to_keep = '30',
$purge_old_reports_command = 'USE_DEFAULTS',
$purge_old_reports_user = 'root',
$purge_old_reports_hour = '0',
$purge_old_reports_minute = '30',
$remove_old_reports_spool = true,
$reports_spool_dir = '/usr/share/puppet-dashboard/spool',
$reports_spool_days_to_keep = '7',
$remove_reports_spool_user = 'root',
$remove_reports_spool_hour = '0',
$remove_reports_spool_minute = '45',
$dump_dir = '/var/local',
$dump_database_command = 'USE_DEFAULTS',
$dump_database_user = 'root',
$dump_database_hour = '1',
$dump_database_minute = '0',
$days_to_keep_backups = '7',
$purge_old_db_backups_user = 'root',
$purge_old_db_backups_hour = '2',
$purge_old_db_backups_minute = '0',
) {
- include common
require 'puppet::dashboard'
validate_absolute_path($reports_spool_dir)
validate_absolute_path($dump_dir)
validate_string($dump_database_command)
validate_integer($reports_days_to_keep)
$purge_old_reports_command_real = $purge_old_reports_command ? {
'USE_DEFAULTS' => "/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=${reports_days_to_keep} unit=day >> /var/log/puppet/dashboard_maintenance.log",
default => $purge_old_reports_command
}
$dump_database_command_real = $dump_database_command ? {
'USE_DEFAULTS' => "cd ~puppet-dashboard && sudo -u ${puppet::dashboard::dashboard_user_real} /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=${dump_dir}/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 ${dump_dir}/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1",
default => $dump_database_command
}
common::mkdir_p { $dump_dir: }
file { $dump_dir:
ensure => directory,
group => $puppet::dashboard::dashboard_group_real,
mode => '0775',
require => Common::Mkdir_p[$dump_dir],
}
cron { 'monthly_dashboard_database_optimization':
ensure => present,
command => $db_optimization_command,
user => $db_optimization_user,
hour => $db_optimization_hour,
minute => $db_optimization_minute,
monthday => $db_optimization_monthday,
}
cron { 'purge_old_reports':
ensure => present,
command => $purge_old_reports_command_real,
user => $purge_old_reports_user,
hour => $purge_old_reports_hour,
minute => $purge_old_reports_minute,
}
if is_string($remove_old_reports_spool) {
$enable_remove_old_reports_spool = str2bool($remove_old_reports_spool)
} else {
$enable_remove_old_reports_spool = $remove_old_reports_spool
}
validate_bool($enable_remove_old_reports_spool)
if $enable_remove_old_reports_spool == true {
$remove_old_reports_spool_enable = 'present'
} else {
$remove_old_reports_spool_enable = 'absent'
}
cron { 'remove_old_reports_spool':
ensure => $remove_old_reports_spool_enable,
command => "/bin/find ${reports_spool_dir} -type f -name \"*.yaml\" -mtime +${$reports_spool_days_to_keep } -exec /bin/rm -f {} \\;",
user => $remove_reports_spool_user,
hour => $remove_reports_spool_hour,
minute => $remove_reports_spool_minute,
}
cron { 'dump_dashboard_database':
command => $dump_database_command_real,
user => $dump_database_user,
hour => $dump_database_hour,
minute => $dump_database_minute,
}
cron { 'purge_old_db_backups':
command => "/bin/find ${dump_dir} -type f -mtime +${days_to_keep_backups} -exec /bin/rm -f {} \\;",
user => $purge_old_db_backups_user,
hour => $purge_old_db_backups_hour,
minute => $purge_old_db_backups_minute,
}
}
diff --git a/manifests/dashboard/server.pp b/manifests/dashboard/server.pp
index b209076..8b9c6ad 100644
--- a/manifests/dashboard/server.pp
+++ b/manifests/dashboard/server.pp
@@ -1,172 +1,171 @@
# == Class: puppet::dashboard::server
#
class puppet::dashboard::server (
$dashboard_workers = $::processorcount,
$database_config_path = '/usr/share/puppet-dashboard/config/database.yml',
$database_config_owner = 'USE_DEFAULTS',
$database_config_group = 'USE_DEFAULTS',
$database_config_mode = '0640',
$htpasswd = undef,
$htpasswd_path = '/etc/puppet/dashboard.htpasswd',
$htpasswd_owner = 'root',
$htpasswd_group = 'USE_DEFAULTS',
$htpasswd_mode = '0640',
$log_dir = '/var/log/puppet',
$manage_mysql_options = true,
$mysql_user = 'dashboard',
$mysql_password = 'puppet',
$mysql_max_packet_size = '32M',
$security = 'none',
$vhost_path = 'USE_DEFAULTS',
) inherits puppet::dashboard {
validate_re($dashboard_workers, '^\d+$',
"puppet::dashboard::server::dashboard_workers must be a digit. Detected value is <${dashboard_workers}>."
)
validate_absolute_path($htpasswd_path)
validate_re($security, '^(none|htpasswd)$',
"Security is <${security}> which does not match regex. Valid values are none and htpasswd."
)
case $::osfamily {
'RedHat': {
$default_database_config_group = $puppet::dashboard::dashboard_group_real
$default_htpasswd_group = 'apache'
$default_vhost_path = '/etc/httpd/conf.d/dashboard.conf'
}
'Debian': {
$default_database_config_group = 'www-data'
$default_htpasswd_group = 'www-data'
$default_vhost_path = '/etc/apache2/sites-enabled/puppetdashboard'
file { 'dashboard_workers_default':
ensure => file,
path => '/etc/default/puppet-dashboard-workers',
content => template('puppet/puppet-dashboard-workers.erb'),
owner => 'root',
group => 'root',
mode => '0644',
notify => Service['puppet-dashboard-workers'],
}
}
default: {
fail("puppet::dashboard::server supports osfamilies Debian and RedHat. Detected osfamily is <${::osfamily}>.")
}
}
if $database_config_owner == 'USE_DEFAULTS' {
$database_config_owner_real = $puppet::dashboard::dashboard_user_real
} else {
$database_config_owner_real = $database_config_owner
}
if $database_config_group == 'USE_DEFAULTS' {
$database_config_group_real = $default_database_config_group
} else {
$database_config_group_real = $database_config_group
}
if $htpasswd_group == 'USE_DEFAULTS' {
$htpasswd_group_real = $default_htpasswd_group
} else {
$htpasswd_group_real = $htpasswd_group
}
if $vhost_path == 'USE_DEFAULTS' {
$vhost_path_real = $default_vhost_path
} else {
$vhost_path_real = $vhost_path
}
validate_absolute_path($vhost_path_real)
- require 'passenger'
- include puppet::dashboard::maintenance
+ require '::passenger'
+ include ::puppet::dashboard::maintenance
if is_bool($manage_mysql_options) {
$manage_mysql_options_real = $manage_mysql_options
} elsif is_string($manage_mysql_options) {
$manage_mysql_options_real = str2bool($manage_mysql_options)
} else {
fail("puppet::dashboard::server::manage_mysql_options supports booleans only and is <${manage_mysql_options}>.")
}
-
if $manage_mysql_options_real == true {
- class { 'mysql::server':
+ class { '::mysql::server':
override_options => {
'mysqld' => {
'max_allowed_packet' => $mysql_max_packet_size,
- }
- }
+ },
+ },
}
} else {
- include mysql::server
+ include ::mysql::server
}
if $security == 'htpasswd' and $htpasswd != undef {
Htpasswd {
target => $htpasswd_path,
}
- Htpasswd <||> -> File['dashboard_htpasswd_path']
+ Htpasswd <| tag == 'puppet::dashboard::server' |> -> File['dashboard_htpasswd_path']
create_resources('htpasswd',$htpasswd)
file { 'dashboard_htpasswd_path':
ensure => file,
path => $htpasswd_path,
owner => $htpasswd_owner,
group => $htpasswd_group_real,
mode => $htpasswd_mode,
}
}
file { 'database_config':
ensure => file,
content => template('puppet/database.yml.erb'),
path => $database_config_path,
owner => $database_config_owner_real,
group => $database_config_group_real,
mode => $database_config_mode,
require => Package[$puppet::dashboard::dashboard_package],
}
file { 'dashboard_vhost':
ensure => file,
path => $vhost_path_real,
content => template('puppet/dashboard-vhost.conf.erb'),
owner => 'root',
group => 'root',
mode => '0644',
require => [ File['httpd_vdir'], # apache
# Exec['compile-passenger'], # passenger
],
notify => Service['httpd'], # apache
}
mysql::db { 'dashboard':
user => $mysql_user,
password => $mysql_password,
host => 'localhost',
grant => ['ALL'],
require => [ Class['mysql::server'],
File['database_config'],
],
}
exec { 'migrate_dashboard_database':
command => 'rake RAILS_ENV=production db:migrate',
onlyif => 'rake RAILS_ENV=production db:version 2>/dev/null|grep ^\'Current version\' | awk -F : \'{print $2}\' | awk \'{print $1}\'|grep ^0$',
path => '/bin:/usr/bin:/sbin:/usr/sbin',
cwd => '/usr/share/puppet-dashboard',
refreshonly => true,
subscribe => Mysql::Db['dashboard'],
}
Service['puppet-dashboard-workers'] {
ensure => running,
enable => true,
subscribe => File['dashboard_sysconfig'],
}
}
diff --git a/manifests/master.pp b/manifests/master.pp
index a1eee45..0757974 100644
--- a/manifests/master.pp
+++ b/manifests/master.pp
@@ -1,115 +1,115 @@
# == Class: puppet::master
#
class puppet::master (
$sysconfig_path = 'USE_DEFAULTS',
$rack_dir = '/usr/share/puppet/rack/puppetmasterd',
$puppet_user = 'puppet',
$manage_firewall = undef,
$vhost_path = 'USE_DEFAULTS',
) {
case $::osfamily {
'RedHat': {
$default_sysconfig_path = '/etc/sysconfig/puppetmaster'
$sysconfig_template = 'puppetmaster_sysconfig.erb'
$default_vhost_path = '/etc/httpd/conf.d/puppetmaster.conf'
}
'Debian': {
$default_sysconfig_path = '/etc/default/puppetmaster'
$sysconfig_template = 'puppetmaster_default.erb'
$default_vhost_path = '/etc/apache2/sites-enabled/puppetmaster'
}
default: {
fail("puppet::master supports osfamilies Debian and RedHat. Detected osfamily is <${::osfamily}>.")
}
}
- include apache::mod::ssl
- include common
- include passenger
- include puppet::lint
- include puppet::master::maintenance
+ include ::apache::mod::ssl
+ include ::common
+ include ::passenger
+ include ::puppet::lint
+ include ::puppet::master::maintenance
if $sysconfig_path == 'USE_DEFAULTS' {
$sysconfig_path_real = $default_sysconfig_path
} else {
$sysconfig_path_real = $sysconfig_path
}
validate_absolute_path($sysconfig_path_real)
if $vhost_path == 'USE_DEFAULTS' {
$vhost_path_real = $default_vhost_path
} else {
$vhost_path_real = $vhost_path
}
validate_absolute_path($vhost_path_real)
if $manage_firewall == true {
firewall { '8140 open port 8140 for Puppet Master':
action => 'accept',
dport => 8140,
proto => 'tcp',
}
}
File {
owner => 'root',
group => 'root',
mode => '0644',
}
file { '/etc/puppet/auth.conf': }
file { '/etc/puppet/fileserver.conf': }
file { 'puppetmaster_sysconfig':
ensure => file,
path => $sysconfig_path_real,
content => template("puppet/${sysconfig_template}"),
}
# Puppetmaster service cannot be stopped as that would likely break the boot
# strap process.
service { 'puppetmaster':
enable => false,
}
# Passenger
common::mkdir_p { $rack_dir: }
common::mkdir_p { "${rack_dir}/public": }
common::mkdir_p { "${rack_dir}/tmp": }
file { $rack_dir:
ensure => directory,
require => Common::Mkdir_p[$rack_dir],
}
file { "${rack_dir}/public":
ensure => directory,
require => Common::Mkdir_p["${rack_dir}/public"],
}
file { "${rack_dir}/tmp":
ensure => directory,
require => Common::Mkdir_p["${rack_dir}/tmp"],
}
file { "${rack_dir}/config.ru":
ensure => file,
source => 'puppet:///modules/puppet/config.ru',
owner => $puppet_user,
group => 'root',
mode => '0644',
}
file { 'puppetmaster_vhost':
ensure => file,
path => $vhost_path_real,
content => template('puppet/puppetmaster-vhost.conf.erb'),
owner => 'root',
group => 'root',
mode => '0644',
require => File['httpd_vdir'],
notify => Service['httpd'],
}
}
diff --git a/tests/agent.pp b/tests/agent.pp
index be7b020..2d8a693 100755
--- a/tests/agent.pp
+++ b/tests/agent.pp
@@ -1 +1 @@
-include puppet::agent
+include ::puppet::agent
diff --git a/tests/console/maintenance.pp b/tests/console/maintenance.pp
index e942378..6b8fd3c 100644
--- a/tests/console/maintenance.pp
+++ b/tests/console/maintenance.pp
@@ -1 +1 @@
-include puppet::console::maintenance
+include ::puppet::console::maintenance
diff --git a/tests/init.pp b/tests/init.pp
index 4a62a0e..aee8eec 100755
--- a/tests/init.pp
+++ b/tests/init.pp
@@ -1,11 +1,11 @@
# The baseline for module testing used by Puppet Labs is that each manifest
# should have a corresponding test manifest that declares that class or defined
# type.
#
# Tests are then run by using puppet apply --noop (to check for compilation errors
# and view a log of events) or by fully applying the test in a virtual environment
# (to compare the resulting system state to the desired state).
#
# Learn more about module testing here: http://docs.puppetlabs.com/guides/tests_smoke.html
#
-include puppet
+include ::puppet
diff --git a/tests/master.pp b/tests/master.pp
index f88c393..42a1a75 100644
--- a/tests/master.pp
+++ b/tests/master.pp
@@ -1 +1 @@
-include puppet::master
+include ::puppet::master
diff --git a/tests/master/maintenance.pp b/tests/master/maintenance.pp
index a1b113c..85a47d4 100644
--- a/tests/master/maintenance.pp
+++ b/tests/master/maintenance.pp
@@ -1 +1 @@
-include puppet::master::maintenance
+include ::puppet::master::maintenance
|
ghoneycutt/puppet-module-puppet
|
425c704f5d7adfce0e4dd9652c8c60d2b5830f3f
|
Add checking of metadata to travis
|
diff --git a/.travis.yml b/.travis.yml
index d7d70a2..872d151 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,41 +1,41 @@
---
language: ruby
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
- 2.1.0
env:
matrix:
- PUPPET_GEM_VERSION="~> 3.1.0"
- PUPPET_GEM_VERSION="~> 3.2.0"
- PUPPET_GEM_VERSION="~> 3.3.0"
- PUPPET_GEM_VERSION="~> 3.4.0"
- PUPPET_GEM_VERSION="~> 3.5.1"
- PUPPET_GEM_VERSION="~> 3.6.0"
- PUPPET_GEM_VERSION="~> 3.7.0"
- PUPPET_GEM_VERSION="~> 3.8.0"
- PUPPET_GEM_VERSION="~> 3"
sudo: false
-script: 'bundle exec rake validate && bundle exec rake lint && SPEC_OPTS="--format documentation" bundle exec rake spec'
+script: 'bundle exec rake metadata_lint && bundle exec rake validate && bundle exec rake lint && SPEC_OPTS="--format documentation" bundle exec rake spec'
matrix:
fast_finish: true
exclude:
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.1.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.1.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.2.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.3.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.4.0"
notifications:
email: false
diff --git a/Gemfile b/Gemfile
index 4913134..3920f70 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,17 +1,18 @@
source 'https://rubygems.org'
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
+gem 'metadata-json-lint'
gem 'puppetlabs_spec_helper', '>= 1.1.1'
gem 'puppet-lint', '>= 1.0.0'
gem 'facter', '>= 1.7.0'
# rspec must be v2 for ruby 1.8.7
if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
gem 'rspec', '~> 2.0'
gem 'rake', '~> 10.0'
end
|
ghoneycutt/puppet-module-puppet
|
9d35b2befaf3c8dde32a21b768f09f3631ebcd83
|
Require a stable/modern version of puppetlabs_spec_helper
|
diff --git a/Gemfile b/Gemfile
index 391efc7..4913134 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,17 +1,17 @@
source 'https://rubygems.org'
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
-gem 'puppetlabs_spec_helper', '>= 0.1.0'
+gem 'puppetlabs_spec_helper', '>= 1.1.1'
gem 'puppet-lint', '>= 1.0.0'
gem 'facter', '>= 1.7.0'
# rspec must be v2 for ruby 1.8.7
if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
gem 'rspec', '~> 2.0'
gem 'rake', '~> 10.0'
end
|
ghoneycutt/puppet-module-puppet
|
88e54991a72d2046a5b660de7ae6626402211b81
|
Fix ruby 1.8.7 support by pinning the version of rake
|
diff --git a/Gemfile b/Gemfile
index 5d80055..391efc7 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,16 +1,17 @@
source 'https://rubygems.org'
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'puppet-lint', '>= 1.0.0'
gem 'facter', '>= 1.7.0'
# rspec must be v2 for ruby 1.8.7
if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
gem 'rspec', '~> 2.0'
+ gem 'rake', '~> 10.0'
end
|
ghoneycutt/puppet-module-puppet
|
c11b681ff8935e236b31fb6c32302778765e5827
|
removing unneccessary rm -rf
|
diff --git a/README.md b/README.md
index 6f98e93..0366aaa 100644
--- a/README.md
+++ b/README.md
@@ -192,573 +192,573 @@ Path to where the symlink should be created
symlink_puppet_binary
---------------------
Boolean for ensuring a symlink for puppet_binary to symlink_puppet_binary_target. This is useful if you install puppet in a non-standard location that is not in your $PATH.
- *Default*: false
agent_sysconfig
---------------
The location of puppet agent sysconfig file.
- *Default*: use defaults based on osfamily
agent_sysconfig_ensure
----------------------
String for 'file' or 'present'. Allows you to not manage the sysconfig file.
- *Default*: use defaults based on osfamily
daemon_name
-----------
The name the puppet agent daemon should run as.
- *Default*: puppet
ssldir
------
String with absolute path for ssldir in puppet agent's config. Using the default will set it to: '$vardir/ssl'
- *Default*: 'USE_DEFAULTS'
stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
- *Default*: true
etckeeper_hooks
---------------
Boolean to include pre- and postrun hooks for etckeeper in the main section of the puppet agent's config.
- *Default*: false
===
## Class `puppet::dashboard` ##
### Parameters ###
dashboard_package
-----------------
String or Array of the dashboard package(s) name.
- *Default*: 'puppet-dashboard'
dashboard_user
--------------
The user for dashboard installation.
- *Default*: use defaults based on osfamily
dashboard_group
--------------
The group for dashboard installation.
- *Default*: use defaults based on osfamily
sysconfig_path
-------------------
The location of puppet dashboard sysconfig file.
- *Default*: use defaults based on osfamily
external_node_script_path
-------------------------
The script to call from puppet to get manifests from dashboard.
- *Default*: /usr/share/puppet-dashboard/bin/external_node
dashboard_fqdn
--------------
The dashboard server FQDN.
- *Default*: puppet.${::domain}
port
----
The port the web server will respond to.
- *Default*: 3000
manage_mysql_options
--------------------
Boolean to use modules default mysql::server settings (mysql_max_packet_size).
For specific mysql::server settings you can use hiera now:
<pre>
puppet::dashboard::server::manage_mysql_options: false
mysql::server::override_options:
mysqld:
max_allowed_packet: '32M'
innodb_buffer_pool_size: '64M'
</pre>
- *Default*: true
===
## Class `puppet::dashboard::server` ##
### Usage ###
You can optionally specify a hash of htpasswd entries in Hiera.
<pre>
---
puppet::dashboard::htpasswd:
admin:
cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
puppet:
cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
</pre>
### Parameters ###
dashboard_workers
-----------------
Number of dashboard workers to start. Only used on osfamily Debian.
- *Default*: $::processorcount
database_config_path
--------------------
The path to the database config file.
- *Default*: /usr/share/puppet-dashboard/config/database.yml
database_config_owner
---------------------
The owner of the database config file.
- *Default*: puppet-dashboard
database_config_group
---------------------
The database config file group.
- *Default*: puppet-dashboard
database_config_mode
--------------------
The database config file mode.
- *Default*: 0640
htpasswd
--------
Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
- *Default*: undef
htpasswd_path
-------------
String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
- *Default*: `/etc/puppet/dashboard.htpasswd`
htpasswd_owner
--------------
Owner of htpasswd file.
- *Default*: root
htpasswd_group
--------------
Group of htpasswd file.
- *Default*: use defaults based on osfamily
htpasswd_mode
-------------
Mode of htpasswd file.
- *Default*: 0640
log_dir
-------
The location for the puppet log files.
- *Default*: /var/log/puppet
mysql_user
----------
The user for the mysql connection.
- *Default*: dashboard
mysql_password
--------------
The password for the mysql connection.
- *Default*: puppet
mysql_max_packet_size
---------------------
The mysql max packet size.
- *Default*: 32M
security
--------
String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
- *Default*: 'none'
vhost_path
----------
The location of puppet dashboard vhost file for apache.
- *Default*: use defaults based on osfamily
===
## Class `puppet::dashboard::maintenance` ##
### Parameters ###
db_optimization_command
-----------------------
The command to run to optimize the db.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
db_optimization_user
--------------------
The user to run db optimization.
- *Default*: root
db_optimization_hour
--------------------
The hour on which to run db optimization.
- *Default*: 0
db_optimization_minute
----------------------
The minute at which to run db optimization.
- *Default*: 0
db_optimization_monthday
------------------------
The day of the month on which to run db optimization.
- *Default*: 1
reports_days_to_keep
--------------------
How many days to keep the reports.
- *Default*: 30
purge_old_reports_command
-------------------------
Which command to run to purge old reports.
Defaults to: '/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=${reports_days_to_keep} unit=day >> /var/log/puppet/dashboard_maintenance.log'
If using a specific command here, please keep in mind you need to align it with $reports_days_to_keep yourself.
- *Default*: 'USE_DEFAULTS'
purge_old_reports_user
----------------------
User to purge reports as.
- *Default*: root
purge_old_reports_hour
----------------------
On which hour to purge old reports.
- *Default*: 0
purge_old_reports_minute
------------------------
At which minute to purge old reports.
- *Default*: 30
remove_old_reports_spool
------------------------
Whether we should remove old dashboard reports that have not been imported
- *Default*: 'True'
reports_spool_dir
-----------------
Path to reports in dashboard spool
- *Default*: '/usr/share/puppet-dashboard/spool'
reports_spool_days_to_keep
--------------------------
How many days to keep the unimported reports.
remove_reports_spool_user
-------------------------
User to remove unimported reports.
- *Default*: root
remove_reports_spool_hour
-------------------------
On which hour to remove unimported reports.
- *Default*: 0
remove_reports_spool_minute
---------------------------
At which minute to remove unimported reports
- *Default*: 45
dump_dir
--------
The directory to use for dumps.
- *Default*: /var/local
dump_database_command
---------------------
The command to run to dump the database.
Defaults to: 'cd ~puppet-dashboard && sudo -u ${puppet::dashboard::dashboard_user_real} /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=${dump_dir}/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 ${dump_dir}/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1'
If using a specific command here, please keep in mind you need to align it with $puppet::dashboard::dashboard_user & $dump_dir yourself.
- *Default*: 'USE_DEFAULTS'
dump_database_user
------------------
User to dump database as.
- *Default*: root
dump_database_hour
------------------
On which hour to dump database.
- *Default*: 1
dump_database_minute
--------------------
At which minute to purge old reports.
- *Default*: 0
days_to_keep_backups
--------------------
Number of days to keep database backups.
- *Default*: 7
purge_old_db_backups_user
-------------------------
User to purge old database dumps as.
- *Default*: root
purge_old_db_backups_hour
-------------------------
On which hour to purge old database dumps.
- *Default*: 2
purge_old_db_backups_minute
---------------------------
At which minute to purge old database dumps.
- *Default*: 0
===
## Class `puppet::lint` ##
### Parameters ###
ensure
------
Whether to install lint.
- *Default*: present
provider
--------
Which provider should supply lint.
- *Default*: gem
version
-------
If you do not want to use the default version of lint, specify which version you want to use here.
- *Default*: undef
lint_args
---------
Which args should be added to the .puppet-lint.rc file
- *Default*: --no-80chars-check
lintrc_path
-----------
The full path to the lint config file.
- *Default*: ${::root_home}/.puppet-lint.rc
lintrc_owner
------------
The owner of the lint config file.
- *Default*: root
lintrc_group
------------
The group of the lint config file.
- *Default*: root
lintrc_mode
-----------
The mode of the lint config file.
- *Default*: 0644
===
## Class `puppet::master` ##
### Usage ###
In Hiera you will need to specify the following.
<pre>
puppet::agent::is_puppet_master: 'true'
</pre>
### Parameters ###
sysconfig_path
--------------
The location of puppet master sysconfig file.
- *Default*: use defaults based on osfamily
vhost_path
----------
The location of puppet master vhost file for apache.
- *Default*: use defaults based on osfamily
rack_dir
--------
The rack directory path.
- *Default*: /usr/share/puppet/rack/puppetmasterd
puppet_user
-----------
The user the puppet master should run as.
- *Default*: puppet
manage_firewall
---------------
Whether to manage the firewall settings on the client
- *Default*: undef
===
## Class `puppet::master::maintenance` ##
If you have a cluster of puppet masters mounting the same data, you should
disable these cronjobs on all systems except for one to ensure they are not all
cleaning up the same data.
```
puppet::master::maintenance::clientbucket_cleanup_ensure: 'absent'
puppet::master::maintenance::reportdir_purge_ensure: 'absent'
```
### Parameters ###
clientbucket_cleanup_ensure
---------------------------
String for ensure parameter for filebucket_cleanup cron job.
- *Default*: 'present'
clientbucket_path
-----------------
Path to where the clientbucket files are stored.
- *Default*: /var/lib/puppet/clientbucket
clientbucket_days_to_keep
-------------------------
The number of days to keep clientbuckets
- *Default*: 30
filebucket_cleanup_command
--------------------------
Command used to cleanup the clientbuckets.
-- *Default*: /usr/bin/find ${clientbucket_path} -type f -mtime +30 -exec /bin/rm -fr {} \;
+- *Default*: /usr/bin/find ${clientbucket_path} -type f -mtime +30 -exec /bin/rm -f {} \;
filebucket_cleanup_user
-----------------------
User to run the clientbucket cleanup as.
- *Default*: root
filebucket_cleanup_hour
-----------------------
Hour on which to run the filebucket cleanup.
- *Default*: 0
filebucket_cleanup_minute
-------------------------
Minute at which to run the filebucket cleanup.
- *Default*: 0
reportdir_purge_ensure
----------------------
String for ensure parameter for purge_old_puppet_reports cron job.
- *Default*: 'present'
reportdir
---------
Directory that holds the reports. `$::puppet_reportdir` is a custom fact that reads the `reportdir` setting from Puppet's configuration. This is likely `/var/lib/puppet/reports/`.
- *Default*: $::puppet_reportdir
reportdir_days_to_key
---------------------
String for number of days of reports to keep. Must be a positive integer > 0.
- *Default*: '30'
reportdir_purge_command
-----------------------
Command ran by cron to purge old reports.
-- *Default*: /usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;'
+- *Default*: /usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -f {} \;'
reportdir_purge_user
--------------------
User for the crontab entry to run the reportdir_purge_command.
- *Default*: root
reportdir_purge_hour
--------------------
Hour at which to run the reportdir_purge_command.
- *Default*: 0
reportdir_purge_minute
----------------------
Minute past the hour in which to run the reportdir_purge_command.
- *Default*: 15
diff --git a/manifests/master/maintenance.pp b/manifests/master/maintenance.pp
index b9f7676..70db1e4 100755
--- a/manifests/master/maintenance.pp
+++ b/manifests/master/maintenance.pp
@@ -1,60 +1,60 @@
# == Class: puppet::master::maintenance
#
class puppet::master::maintenance (
$clientbucket_cleanup_ensure = 'present',
$clientbucket_path = '/var/lib/puppet/clientbucket/',
$clientbucket_days_to_keep = '30',
- $filebucket_cleanup_command = '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ $filebucket_cleanup_command = '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -f {} \;',
$filebucket_cleanup_user = 'root',
$filebucket_cleanup_hour = '0',
$filebucket_cleanup_minute = '0',
$reportdir_purge_ensure = 'present',
$reportdir = $::puppet_reportdir,
$reportdir_days_to_keep = '30',
- $reportdir_purge_command = '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ $reportdir_purge_command = '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -f {} \;',
$reportdir_purge_user = 'root',
$reportdir_purge_hour = '0',
$reportdir_purge_minute = '15',
) {
validate_absolute_path($reportdir)
validate_re($clientbucket_cleanup_ensure, '^(present|absent)$', "clientbucket_cleanup_ensure must be 'present' or 'absent'. Detected value is <${clientbucket_cleanup_ensure}>")
validate_re($reportdir_purge_ensure, '^(present|absent)$', "reportdir_purge_ensure must be 'present' or 'absent'. Detected value is <${reportdir_purge_ensure}>")
# if not using the defaults, then construct the command with variables, else
# use the default command
if ( $clientbucket_days_to_keep != 30 ) or ( $clientbucket_path != '/var/lib/puppet/clientbucket/' ) {
- $my_filebucket_cleanup_command = "/usr/bin/find ${clientbucket_path} -type f -mtime +${clientbucket_days_to_keep} -exec /bin/rm -fr {} \\;"
+ $my_filebucket_cleanup_command = "/usr/bin/find ${clientbucket_path} -type f -mtime +${clientbucket_days_to_keep} -exec /bin/rm -f {} \\;"
} else {
$my_filebucket_cleanup_command = $filebucket_cleanup_command
}
cron { 'filebucket_cleanup':
ensure => $clientbucket_cleanup_ensure,
command => $my_filebucket_cleanup_command,
user => $filebucket_cleanup_user,
hour => $filebucket_cleanup_hour,
minute => $filebucket_cleanup_minute,
}
if $reportdir_days_to_keep <= '0' {
fail("puppet::master::maintenance::reportdir_days_to_keep must be a positive integer greater than zero. Detected value is <${reportdir_days_to_keep}>.")
}
if ( $reportdir_days_to_keep != 30 ) or ( $reportdir != '/var/lib/puppet/reports' ) {
- $my_reportdir_purge_command = "/usr/bin/find -L ${reportdir} -type f -mtime +${reportdir_days_to_keep} -exec /bin/rm -fr {} \\;"
+ $my_reportdir_purge_command = "/usr/bin/find -L ${reportdir} -type f -mtime +${reportdir_days_to_keep} -exec /bin/rm -f {} \\;"
} else {
$my_reportdir_purge_command = $reportdir_purge_command
}
cron { 'purge_old_puppet_reports':
ensure => $reportdir_purge_ensure,
command => $my_reportdir_purge_command,
user => $reportdir_purge_user,
hour => $reportdir_purge_hour,
minute => $reportdir_purge_minute,
}
}
diff --git a/spec/classes/master_maintenance_spec.rb b/spec/classes/master_maintenance_spec.rb
index 6a69858..d6ace0c 100644
--- a/spec/classes/master_maintenance_spec.rb
+++ b/spec/classes/master_maintenance_spec.rb
@@ -1,325 +1,325 @@
require 'spec_helper'
describe 'puppet::master::maintenance' do
describe 'class puppet::master::maintenance' do
context 'Puppetmaster maintenance cron' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'user' => 'root',
'hour' => '0',
'minute' => '0',
})
}
end
context 'with reportdir_purge_ensure set to invalid value' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports', } }
let(:params) { { :reportdir_purge_ensure => 'installed', } }
it 'should fail' do
expect {
should contain_class('puppet::master::maintenance')
}.to raise_error(Puppet::Error,/^reportdir_purge_ensure must be 'present' or 'absent'. Detected value is <installed>/)
end
end
context 'with clientbucket_cleanup_ensure set to invalid value' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports', } }
let(:params) { { :clientbucket_cleanup_ensure => 'installed', } }
it 'should fail' do
expect {
should contain_class('puppet::master::maintenance')
}.to raise_error(Puppet::Error,/^clientbucket_cleanup_ensure must be 'present' or 'absent'. Detected value is <installed>/)
end
end
end
describe 'clientbucket cleanup' do
context 'with default settings' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'ensure' => 'present',
- 'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ 'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -f {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '0',
})
}
end
context 'with non-default user' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
let(:params) do
{ :filebucket_cleanup_user => 'gh', }
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'ensure' => 'present',
- 'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ 'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -f {} \;',
'user' => 'gh',
'hour' => '0',
'minute' => '0',
})
}
end
context 'with non-default path' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
let(:params) do
{ :clientbucket_path => '/var/lib/puppet/filebucket/', }
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'ensure' => 'present',
- 'command' => '/usr/bin/find /var/lib/puppet/filebucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ 'command' => '/usr/bin/find /var/lib/puppet/filebucket/ -type f -mtime +30 -exec /bin/rm -f {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '0',
})
}
end
context 'with non-default number of days to keep' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
let(:params) do
{
:clientbucket_days_to_keep => '20',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'ensure' => 'present',
- 'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +20 -exec /bin/rm -fr {} \;',
+ 'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +20 -exec /bin/rm -f {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '0',
})
}
end
context 'with non-default hour and minute set' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
let(:params) do
{
:filebucket_cleanup_hour => '2',
:filebucket_cleanup_minute => '30',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'ensure' => 'present',
- 'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ 'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -f {} \;',
'user' => 'root',
'hour' => '2',
'minute' => '30',
})
}
end
context 'with clientbucket_cleanup_ensure set to absent' do
let(:facts) do
{ :puppet_reportdir => '/var/lib/puppet/reports', }
end
let(:params) do
{ :clientbucket_cleanup_ensure => 'absent', }
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'ensure' => 'absent'
})
}
end
end
describe 'purge reportdir' do
context 'with default settings for params' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
- 'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ 'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -f {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
context 'with reportdir_purge_user, reportdir_purge_hour, and reportdir_purge_minute set' do
let(:params) do
{ :reportdir_purge_user => 'gh',
:reportdir_purge_hour => '23',
:reportdir_purge_minute => '42',
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
- 'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ 'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -f {} \;',
'user' => 'gh',
'hour' => '23',
'minute' => '42',
})
}
end
describe 'with reportdir_days_to_keep specified' do
context 'as a valid integer greater than zero' do
let(:params) { { :reportdir_days_to_keep => '42' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
- 'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +42 -exec /bin/rm -fr {} \;',
+ 'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +42 -exec /bin/rm -f {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
['0','-23'].each do |value|
context "as #{value}" do
let(:params) { { :reportdir_days_to_keep => value } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it do
expect {
should contain_class('puppet::master::maintenance')
}.to raise_error(Puppet::Error,/puppet::master::maintenance::reportdir_days_to_keep must be a positive integer greater than zero. Detected value is <#{value}>./)
end
end
end
end
describe 'with reportdir specified' do
context 'as a valid directory' do
let(:params) { { :reportdir => '/etc/puppet/reports' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
- 'command' => '/usr/bin/find -L /etc/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ 'command' => '/usr/bin/find -L /etc/puppet/reports -type f -mtime +30 -exec /bin/rm -f {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
context 'as an invalid directory' do
let(:params) { { :reportdir => 'invalid/path' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it do
expect {
should contain_class('puppet::master::maintenance')
}.to raise_error(Puppet::Error,/^"invalid\/path" is not an absolute path./)
end
end
end
context 'with reportdir and reportdir_days_to_keep specified' do
let(:params) do
{ :reportdir => '/etc/puppet/reports',
:reportdir_days_to_keep => '42',
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
- 'command' => '/usr/bin/find -L /etc/puppet/reports -type f -mtime +42 -exec /bin/rm -fr {} \;',
+ 'command' => '/usr/bin/find -L /etc/puppet/reports -type f -mtime +42 -exec /bin/rm -f {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
context 'with purge_old_puppet_reports set to absent' do
let(:facts) do
{ :puppet_reportdir => '/var/lib/puppet/reports', }
end
let(:params) do
{ :reportdir_purge_ensure => 'absent', }
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'absent'
})
}
end
end
end
|
ghoneycutt/puppet-module-puppet
|
3312b0273ec2e57650d5d0ebf288bef7b78dce51
|
Allow configuration of the number of max requests handled per puppet master process
|
diff --git a/README.md b/README.md
index 6f98e93..60fe3b7 100644
--- a/README.md
+++ b/README.md
@@ -155,610 +155,616 @@ Whether to run as a service or in cron mode. Valid values are `disable`, `cron`,
run_interval
------------
The interval, in minutes, with which the client should run. If greater than 30, the agent will only run once per hour.
- *Default*: 30
run_in_noop
-----------
Whether the client should run in noop mode or not.
- *Default*: false
cron_command
------------
The command that should be added to the crontab (in cron mode)
- *Default*: /usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay
run_at_boot
-----------
Whether the client should run right after boot
- *Default*: true
puppet_binary
-------------
Path to puppet binary to create symlink from
- *Default*: '/usr/bin/puppet'
symlink_puppet_binary_target
----------------------------
Path to where the symlink should be created
- *Default*: '/usr/local/bin/puppet'
symlink_puppet_binary
---------------------
Boolean for ensuring a symlink for puppet_binary to symlink_puppet_binary_target. This is useful if you install puppet in a non-standard location that is not in your $PATH.
- *Default*: false
agent_sysconfig
---------------
The location of puppet agent sysconfig file.
- *Default*: use defaults based on osfamily
agent_sysconfig_ensure
----------------------
String for 'file' or 'present'. Allows you to not manage the sysconfig file.
- *Default*: use defaults based on osfamily
daemon_name
-----------
The name the puppet agent daemon should run as.
- *Default*: puppet
ssldir
------
String with absolute path for ssldir in puppet agent's config. Using the default will set it to: '$vardir/ssl'
- *Default*: 'USE_DEFAULTS'
stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
- *Default*: true
etckeeper_hooks
---------------
Boolean to include pre- and postrun hooks for etckeeper in the main section of the puppet agent's config.
- *Default*: false
===
## Class `puppet::dashboard` ##
### Parameters ###
dashboard_package
-----------------
String or Array of the dashboard package(s) name.
- *Default*: 'puppet-dashboard'
dashboard_user
--------------
The user for dashboard installation.
- *Default*: use defaults based on osfamily
dashboard_group
--------------
The group for dashboard installation.
- *Default*: use defaults based on osfamily
sysconfig_path
-------------------
The location of puppet dashboard sysconfig file.
- *Default*: use defaults based on osfamily
external_node_script_path
-------------------------
The script to call from puppet to get manifests from dashboard.
- *Default*: /usr/share/puppet-dashboard/bin/external_node
dashboard_fqdn
--------------
The dashboard server FQDN.
- *Default*: puppet.${::domain}
port
----
The port the web server will respond to.
- *Default*: 3000
manage_mysql_options
--------------------
Boolean to use modules default mysql::server settings (mysql_max_packet_size).
For specific mysql::server settings you can use hiera now:
<pre>
puppet::dashboard::server::manage_mysql_options: false
mysql::server::override_options:
mysqld:
max_allowed_packet: '32M'
innodb_buffer_pool_size: '64M'
</pre>
- *Default*: true
===
## Class `puppet::dashboard::server` ##
### Usage ###
You can optionally specify a hash of htpasswd entries in Hiera.
<pre>
---
puppet::dashboard::htpasswd:
admin:
cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
puppet:
cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
</pre>
### Parameters ###
dashboard_workers
-----------------
Number of dashboard workers to start. Only used on osfamily Debian.
- *Default*: $::processorcount
database_config_path
--------------------
The path to the database config file.
- *Default*: /usr/share/puppet-dashboard/config/database.yml
database_config_owner
---------------------
The owner of the database config file.
- *Default*: puppet-dashboard
database_config_group
---------------------
The database config file group.
- *Default*: puppet-dashboard
database_config_mode
--------------------
The database config file mode.
- *Default*: 0640
htpasswd
--------
Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
- *Default*: undef
htpasswd_path
-------------
String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
- *Default*: `/etc/puppet/dashboard.htpasswd`
htpasswd_owner
--------------
Owner of htpasswd file.
- *Default*: root
htpasswd_group
--------------
Group of htpasswd file.
- *Default*: use defaults based on osfamily
htpasswd_mode
-------------
Mode of htpasswd file.
- *Default*: 0640
log_dir
-------
The location for the puppet log files.
- *Default*: /var/log/puppet
mysql_user
----------
The user for the mysql connection.
- *Default*: dashboard
mysql_password
--------------
The password for the mysql connection.
- *Default*: puppet
mysql_max_packet_size
---------------------
The mysql max packet size.
- *Default*: 32M
security
--------
String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
- *Default*: 'none'
vhost_path
----------
The location of puppet dashboard vhost file for apache.
- *Default*: use defaults based on osfamily
===
## Class `puppet::dashboard::maintenance` ##
### Parameters ###
db_optimization_command
-----------------------
The command to run to optimize the db.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
db_optimization_user
--------------------
The user to run db optimization.
- *Default*: root
db_optimization_hour
--------------------
The hour on which to run db optimization.
- *Default*: 0
db_optimization_minute
----------------------
The minute at which to run db optimization.
- *Default*: 0
db_optimization_monthday
------------------------
The day of the month on which to run db optimization.
- *Default*: 1
reports_days_to_keep
--------------------
How many days to keep the reports.
- *Default*: 30
purge_old_reports_command
-------------------------
Which command to run to purge old reports.
Defaults to: '/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=${reports_days_to_keep} unit=day >> /var/log/puppet/dashboard_maintenance.log'
If using a specific command here, please keep in mind you need to align it with $reports_days_to_keep yourself.
- *Default*: 'USE_DEFAULTS'
purge_old_reports_user
----------------------
User to purge reports as.
- *Default*: root
purge_old_reports_hour
----------------------
On which hour to purge old reports.
- *Default*: 0
purge_old_reports_minute
------------------------
At which minute to purge old reports.
- *Default*: 30
remove_old_reports_spool
------------------------
Whether we should remove old dashboard reports that have not been imported
- *Default*: 'True'
reports_spool_dir
-----------------
Path to reports in dashboard spool
- *Default*: '/usr/share/puppet-dashboard/spool'
reports_spool_days_to_keep
--------------------------
How many days to keep the unimported reports.
remove_reports_spool_user
-------------------------
User to remove unimported reports.
- *Default*: root
remove_reports_spool_hour
-------------------------
On which hour to remove unimported reports.
- *Default*: 0
remove_reports_spool_minute
---------------------------
At which minute to remove unimported reports
- *Default*: 45
dump_dir
--------
The directory to use for dumps.
- *Default*: /var/local
dump_database_command
---------------------
The command to run to dump the database.
Defaults to: 'cd ~puppet-dashboard && sudo -u ${puppet::dashboard::dashboard_user_real} /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=${dump_dir}/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 ${dump_dir}/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1'
If using a specific command here, please keep in mind you need to align it with $puppet::dashboard::dashboard_user & $dump_dir yourself.
- *Default*: 'USE_DEFAULTS'
dump_database_user
------------------
User to dump database as.
- *Default*: root
dump_database_hour
------------------
On which hour to dump database.
- *Default*: 1
dump_database_minute
--------------------
At which minute to purge old reports.
- *Default*: 0
days_to_keep_backups
--------------------
Number of days to keep database backups.
- *Default*: 7
purge_old_db_backups_user
-------------------------
User to purge old database dumps as.
- *Default*: root
purge_old_db_backups_hour
-------------------------
On which hour to purge old database dumps.
- *Default*: 2
purge_old_db_backups_minute
---------------------------
At which minute to purge old database dumps.
- *Default*: 0
===
## Class `puppet::lint` ##
### Parameters ###
ensure
------
Whether to install lint.
- *Default*: present
provider
--------
Which provider should supply lint.
- *Default*: gem
version
-------
If you do not want to use the default version of lint, specify which version you want to use here.
- *Default*: undef
lint_args
---------
Which args should be added to the .puppet-lint.rc file
- *Default*: --no-80chars-check
lintrc_path
-----------
The full path to the lint config file.
- *Default*: ${::root_home}/.puppet-lint.rc
lintrc_owner
------------
The owner of the lint config file.
- *Default*: root
lintrc_group
------------
The group of the lint config file.
- *Default*: root
lintrc_mode
-----------
The mode of the lint config file.
- *Default*: 0644
===
## Class `puppet::master` ##
### Usage ###
In Hiera you will need to specify the following.
<pre>
puppet::agent::is_puppet_master: 'true'
</pre>
### Parameters ###
sysconfig_path
--------------
The location of puppet master sysconfig file.
- *Default*: use defaults based on osfamily
vhost_path
----------
The location of puppet master vhost file for apache.
- *Default*: use defaults based on osfamily
rack_dir
--------
The rack directory path.
- *Default*: /usr/share/puppet/rack/puppetmasterd
puppet_user
-----------
The user the puppet master should run as.
- *Default*: puppet
manage_firewall
---------------
Whether to manage the firewall settings on the client
- *Default*: undef
+passenger_max_requests
+----------------------
+The number of requests that each puppet master process will handle before being restarted.
+
+- *Default*: 1000
+
===
## Class `puppet::master::maintenance` ##
If you have a cluster of puppet masters mounting the same data, you should
disable these cronjobs on all systems except for one to ensure they are not all
cleaning up the same data.
```
puppet::master::maintenance::clientbucket_cleanup_ensure: 'absent'
puppet::master::maintenance::reportdir_purge_ensure: 'absent'
```
### Parameters ###
clientbucket_cleanup_ensure
---------------------------
String for ensure parameter for filebucket_cleanup cron job.
- *Default*: 'present'
clientbucket_path
-----------------
Path to where the clientbucket files are stored.
- *Default*: /var/lib/puppet/clientbucket
clientbucket_days_to_keep
-------------------------
The number of days to keep clientbuckets
- *Default*: 30
filebucket_cleanup_command
--------------------------
Command used to cleanup the clientbuckets.
- *Default*: /usr/bin/find ${clientbucket_path} -type f -mtime +30 -exec /bin/rm -fr {} \;
filebucket_cleanup_user
-----------------------
User to run the clientbucket cleanup as.
- *Default*: root
filebucket_cleanup_hour
-----------------------
Hour on which to run the filebucket cleanup.
- *Default*: 0
filebucket_cleanup_minute
-------------------------
Minute at which to run the filebucket cleanup.
- *Default*: 0
reportdir_purge_ensure
----------------------
String for ensure parameter for purge_old_puppet_reports cron job.
- *Default*: 'present'
reportdir
---------
Directory that holds the reports. `$::puppet_reportdir` is a custom fact that reads the `reportdir` setting from Puppet's configuration. This is likely `/var/lib/puppet/reports/`.
- *Default*: $::puppet_reportdir
reportdir_days_to_key
---------------------
String for number of days of reports to keep. Must be a positive integer > 0.
- *Default*: '30'
reportdir_purge_command
-----------------------
Command ran by cron to purge old reports.
- *Default*: /usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;'
reportdir_purge_user
--------------------
User for the crontab entry to run the reportdir_purge_command.
- *Default*: root
reportdir_purge_hour
--------------------
Hour at which to run the reportdir_purge_command.
- *Default*: 0
reportdir_purge_minute
----------------------
Minute past the hour in which to run the reportdir_purge_command.
- *Default*: 15
diff --git a/manifests/master.pp b/manifests/master.pp
index a1eee45..7cfe1e1 100644
--- a/manifests/master.pp
+++ b/manifests/master.pp
@@ -1,115 +1,118 @@
# == Class: puppet::master
#
class puppet::master (
- $sysconfig_path = 'USE_DEFAULTS',
- $rack_dir = '/usr/share/puppet/rack/puppetmasterd',
- $puppet_user = 'puppet',
- $manage_firewall = undef,
- $vhost_path = 'USE_DEFAULTS',
+ $sysconfig_path = 'USE_DEFAULTS',
+ $rack_dir = '/usr/share/puppet/rack/puppetmasterd',
+ $puppet_user = 'puppet',
+ $manage_firewall = undef,
+ $vhost_path = 'USE_DEFAULTS',
+ $passenger_max_requests = 1000,
) {
case $::osfamily {
'RedHat': {
$default_sysconfig_path = '/etc/sysconfig/puppetmaster'
$sysconfig_template = 'puppetmaster_sysconfig.erb'
$default_vhost_path = '/etc/httpd/conf.d/puppetmaster.conf'
}
'Debian': {
$default_sysconfig_path = '/etc/default/puppetmaster'
$sysconfig_template = 'puppetmaster_default.erb'
$default_vhost_path = '/etc/apache2/sites-enabled/puppetmaster'
}
default: {
fail("puppet::master supports osfamilies Debian and RedHat. Detected osfamily is <${::osfamily}>.")
}
}
include apache::mod::ssl
include common
include passenger
include puppet::lint
include puppet::master::maintenance
if $sysconfig_path == 'USE_DEFAULTS' {
$sysconfig_path_real = $default_sysconfig_path
} else {
$sysconfig_path_real = $sysconfig_path
}
validate_absolute_path($sysconfig_path_real)
if $vhost_path == 'USE_DEFAULTS' {
$vhost_path_real = $default_vhost_path
} else {
$vhost_path_real = $vhost_path
}
validate_absolute_path($vhost_path_real)
+ validate_integer($passenger_max_requests)
+
if $manage_firewall == true {
firewall { '8140 open port 8140 for Puppet Master':
action => 'accept',
dport => 8140,
proto => 'tcp',
}
}
File {
owner => 'root',
group => 'root',
mode => '0644',
}
file { '/etc/puppet/auth.conf': }
file { '/etc/puppet/fileserver.conf': }
file { 'puppetmaster_sysconfig':
ensure => file,
path => $sysconfig_path_real,
content => template("puppet/${sysconfig_template}"),
}
# Puppetmaster service cannot be stopped as that would likely break the boot
# strap process.
service { 'puppetmaster':
enable => false,
}
# Passenger
common::mkdir_p { $rack_dir: }
common::mkdir_p { "${rack_dir}/public": }
common::mkdir_p { "${rack_dir}/tmp": }
file { $rack_dir:
ensure => directory,
require => Common::Mkdir_p[$rack_dir],
}
file { "${rack_dir}/public":
ensure => directory,
require => Common::Mkdir_p["${rack_dir}/public"],
}
file { "${rack_dir}/tmp":
ensure => directory,
require => Common::Mkdir_p["${rack_dir}/tmp"],
}
file { "${rack_dir}/config.ru":
ensure => file,
source => 'puppet:///modules/puppet/config.ru',
owner => $puppet_user,
group => 'root',
mode => '0644',
}
file { 'puppetmaster_vhost':
ensure => file,
path => $vhost_path_real,
content => template('puppet/puppetmaster-vhost.conf.erb'),
owner => 'root',
group => 'root',
mode => '0644',
require => File['httpd_vdir'],
notify => Service['httpd'],
}
}
diff --git a/spec/classes/master_spec.rb b/spec/classes/master_spec.rb
index 2b69e88..ddab0a5 100644
--- a/spec/classes/master_spec.rb
+++ b/spec/classes/master_spec.rb
@@ -1,236 +1,281 @@
require 'spec_helper'
describe 'puppet::master' do
describe 'class puppet::master' do
context 'Puppetmaster auth.conf configuration file' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('/etc/puppet/auth.conf').with({
'owner' => 'root',
})
}
end
context 'Puppetmaster fileserver.conf configuration file' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('/etc/puppet/fileserver.conf').with({
'owner' => 'root',
})
}
end
context 'Puppetmaster sysconfig file on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('puppetmaster_sysconfig').with_content(/^#PUPPETMASTER_LOG=syslog$/) }
end
context 'Puppetmaster sysconfig file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '7',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('puppetmaster_sysconfig').with_content(/^START=no$/) }
it { should contain_file('puppetmaster_sysconfig').with_content(/^DAEMON_OPTS=""$/) }
it { should contain_file('puppetmaster_sysconfig').with_content(/^PORT=8140$/) }
end
context 'Puppetmaster sysconfig file on invalid osfmaily' do
let(:facts) do
{ :osfamily => 'invalid',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it 'should fail' do
expect {
should contain_class('puppet::master')
}.to raise_error(Puppet::Error,/puppet::master supports osfamilies Debian and RedHat. Detected osfamily is <invalid>./)
end
end
context 'Puppetmaster sysconfig file specified as invalid path' do
let(:params) { { :sysconfig_path => 'invalid/path/statement' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it 'should fail' do
expect {
should contain_class('puppet::master')
}.to raise_error(Puppet::Error,/^"invalid\/path\/statement" is not an absolute path./)
end
end
context 'Puppetmaster rack directory' do
let(:params) { {:rack_dir => '/foo/bar' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('/foo/bar').with({
'ensure' => 'directory',
})
}
end
context 'Puppetmaster rack configuration file' do
let(:params) { {:rack_dir => '/foo/bar' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('/foo/bar/config.ru').with({
'owner' => 'puppet',
'group' => 'root',
'mode' => '0644',
})
}
end
context 'Puppetmaster vhost configuration file on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('puppetmaster_vhost').with({
'ensure' => 'file',
'path' => '/etc/httpd/conf.d/puppetmaster.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
context 'Puppetmaster vhost configuration file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('puppetmaster_vhost').with({
'ensure' => 'file',
'path' => '/etc/apache2/sites-enabled/puppetmaster',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
context 'Puppetmaster vhost configuration file specified as param' do
let(:params) { { :vhost_path => '/usr/local/apache/conf.d/puppetmaster.conf' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('puppetmaster_vhost').with({
'ensure' => 'file',
'path' => '/usr/local/apache/conf.d/puppetmaster.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
context 'Puppetmaster vhost configuration file specified as invalid path' do
let(:params) { { :vhost_path => 'invalid/path/statement' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it 'should fail' do
expect {
should contain_class('puppet::master')
}.to raise_error(Puppet::Error,/^"invalid\/path\/statement" is not an absolute path./)
end
end
context 'Puppetmaster vhost configuration file content' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('puppetmaster_vhost').with_content(/^\s*<Directory \/usr\/share\/puppet\/rack\/puppetmasterd\/>$/) }
end
+
+ context 'Puppetmaster vhost configuration default PassengerMaxRequests' do
+ let(:facts) do
+ { :osfamily => 'RedHat',
+ :operatingsystemrelease => '6.4',
+ :concat_basedir => '/tmp',
+ :puppet_reportdir => '/var/lib/puppet/reports',
+ }
+ end
+
+ it { should contain_class('puppet::master') }
+
+ it { should contain_file('puppetmaster_vhost').with_content(/^\s*PassengerMaxRequests 1000$/) }
+ end
+
+ context 'Puppetmaster vhost configuration of PassengerMaxRequests' do
+ let(:params) { { :passenger_max_requests => 5 } }
+ let(:facts) do
+ { :osfamily => 'RedHat',
+ :operatingsystemrelease => '6.4',
+ :concat_basedir => '/tmp',
+ :puppet_reportdir => '/var/lib/puppet/reports',
+ }
+ end
+
+ it { should contain_file('puppetmaster_vhost').with_content(/^\s*PassengerMaxRequests 5$/) }
+ end
+
+ context 'Puppetmaster vhost configuration parameter error for PassengerMaxRequests' do
+ let(:params) { { :passenger_max_requests => 'Invalid' } }
+ let(:facts) do
+ { :osfamily => 'RedHat',
+ :operatingsystemrelease => '6.4',
+ :concat_basedir => '/tmp',
+ :puppet_reportdir => '/var/lib/puppet/reports',
+ }
+ end
+
+ it 'should fail' do
+ expect {
+ should contain_class('puppet::master')
+ }.to raise_error(Puppet::Error,/Expected first argument to be an Integer/)
+ end
+ end
+
end
end
diff --git a/templates/puppetmaster-vhost.conf.erb b/templates/puppetmaster-vhost.conf.erb
index 6a365da..5149106 100644
--- a/templates/puppetmaster-vhost.conf.erb
+++ b/templates/puppetmaster-vhost.conf.erb
@@ -1,49 +1,49 @@
# This file is being maintained by Puppet.
# DO NOT EDIT
PassengerUseGlobalQueue On
-# Recycle master processes after they service 1000 requests
-PassengerMaxRequests 1000
+# Recycle master processes after they service the number of requests specified by PassengerMaxRequests. Default is 1000.
+PassengerMaxRequests <%= @passenger_max_requests %>
# Stop processes if they sit idle for 10 minutes
PassengerPoolIdleTime 600
PassengerStatThrottleRate 120
RackAutoDetect On
RailsAutoDetect On
Listen 8140
<VirtualHost *:8140>
SSLEngine On
# Only allow high security cryptography. Alter if needed for compatibility.
SSLProtocol All -SSLv2 -SSLv3
SSLCipherSuite HIGH:!ADH:RC4+RSA:-MEDIUM:-LOW:-EXP
SSLCertificateFile /var/lib/puppet/ssl/certs/<%= @fqdn %>.pem
SSLCertificateKeyFile /var/lib/puppet/ssl/private_keys/<%= @fqdn %>.pem
SSLCertificateChainFile /var/lib/puppet/ssl/ca/ca_crt.pem
SSLCACertificateFile /var/lib/puppet/ssl/ca/ca_crt.pem
SSLCARevocationFile /var/lib/puppet/ssl/ca/ca_crl.pem
SSLVerifyClient optional
SSLVerifyDepth 1
SSLOptions +StdEnvVars +ExportCertData
# This header needs to be set if using a loadbalancer or proxy
RequestHeader unset X-Forwarded-For
# These request headers are used to pass the client certificate
# authentication information on to the puppet master process
RequestHeader set X-SSL-Subject %{SSL_CLIENT_S_DN}e
RequestHeader set X-Client-DN %{SSL_CLIENT_S_DN}e
RequestHeader set X-Client-Verify %{SSL_CLIENT_VERIFY}e
RackAutoDetect On
DocumentRoot <%= @rack_dir %>/public/
<Directory <%= @rack_dir %>/>
Options None
AllowOverride None
Order Allow,Deny
Allow from All
</Directory>
</VirtualHost>
|
ghoneycutt/puppet-module-puppet
|
801d1bd174c729f493413ca2dd03b6b980adac54
|
Disable SSLv2 in comments - no actual change to system
|
diff --git a/templates/dashboard-vhost.conf.erb b/templates/dashboard-vhost.conf.erb
index 2df7f5c..4d9ef26 100644
--- a/templates/dashboard-vhost.conf.erb
+++ b/templates/dashboard-vhost.conf.erb
@@ -1,110 +1,110 @@
# This file is being maintained by Puppet.
# DO NOT EDIT
#LoadModule passenger_module <%= scope.lookupvar('passenger::mod_passenger_location') %>
#PassengerRoot <%= scope.lookupvar('passenger::gem_path') %>/passenger-<%= scope.lookupvar('passenger::passenger_version') %>
#PassengerRuby /usr/bin/ruby
# you may want to tune these settings
PassengerHighPerformance on
PassengerMaxPoolSize 12
PassengerPoolIdleTime 1500
# PassengerMaxRequests 1000
PassengerStatThrottleRate 120
RailsAutoDetect On
<% if @port != '80' %>Listen <%= @port %><% end %>
<VirtualHost *:<%= @port %>>
ServerName <%= @dashboard_fqdn %>
DocumentRoot /usr/share/puppet-dashboard/public/
<Directory /usr/share/puppet-dashboard/public/>
Options None
Order allow,deny
allow from all
</Directory>
ErrorLog <%= @log_dir %>/dashboard_error.log
LogLevel warn
CustomLog <%= @log_dir %>/dashboard_access.log combined
ServerSignature On
<% if @security == 'htpasswd' %>
# Uncomment this section to enable basic auth. This section can also be copied
# to the HTTPS VirtualHost example below.
# For report submission from masters.
<Location /reports/upload>
<Limit POST>
# Configuration restricts HTTP actions to POST only
Order allow,deny
# Allow from localhost
# Allow from localhost.localdomain
# Allow from 127.0.0.1
# Allow from example.com
# This can be locked down to just your puppet master if required
# See examples above, or http://httpd.apache.org/docs/2.2/howto/access.html
Allow from all
Satisfy any
</Limit>
</Location>
# For node definitions from masters.
<Location /nodes>
<Limit GET>
# Configuration restricts HTTP actions to GET only
Order allow,deny
# Allow from localhost.localdomain
# Allow from localhost
# Allow from 127.0.0.1
# Allow from example.com
# This can be locked down to just your puppet master if required
# See examples above, or http://httpd.apache.org/docs/2.2/howto/access.html
Allow from all
Satisfy any
</Limit>
</Location>
# For web access by humans.
<Location "/">
AuthType basic
AuthName "Puppet Dashboard"
Require valid-user
AuthBasicProvider file
AuthUserFile <%= @htpasswd_path %>
</Location>
<% end -%>
</VirtualHost>
# Uncomment this section to enable HTTPS (SSL)
#Listen 443
#<VirtualHost *:443>
# SSLEngine on
-# SSLProtocol -ALL +SSLv3 +TLSv1
+# SSLProtocol -ALL -SSLv3 +TLSv1
# SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP
#
# SSLCertificateFile /usr/share/puppet-dashboard/certs/dashboard.cert.pem
# SSLCertificateKeyFile /usr/share/puppet-dashboard/certs/dashboard.private_key.pem
# SSLCACertificateFile /usr/share/puppet-dashboard/certs/dashboard.ca_cert.pem
#
# # If Apache complains about invalid signatures on the CRL, you can try disabling
# # CRL checking by commenting the next line, but this is not recommended.
# SSLCARevocationFile /usr/share/puppet-dashboard/certs/dashboard.ca_crl.pem
#
# SSLVerifyClient optional
# SSLVerifyDepth 1
# SSLOptions +StdEnvVars
#
# ServerName dashboard.example.com # UPDATE THIS TO YOUR FQDN
# DocumentRoot /usr/share/puppet-dashboard/public
# <Directory /usr/share/puppet-dashboard/public>
# Options None
# AllowOverride None
# Order allow,deny
# allow from all
# </Directory>
# <Location / >
# Order deny,allow
# Allow from ALL
# # Enable this to require client-side certificates for Dashboard connections
# #SSLVerifyClient require
# </Location>
#</VirtualHost>
|
ghoneycutt/puppet-module-puppet
|
a7c62256a14e4caaca207f1bc207eee2df505455
|
Release v2.17.0 - Add ssldir parameter and deprecate type()
|
diff --git a/metadata.json b/metadata.json
index 4a9ab76..086936e 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.16.0",
+ "version": "2.17.0",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": ">= 3.2.0 < 5.0.0"
},
{
"name": "puppet",
"version_requirement": ">= 3.0.0 < 5.0.0"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3 < 2.0.0"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1 < 2.0.0"},
{"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 6.0.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0 < 3.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4 < 2.0.0"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0 < 2.0.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1 < 2.0.0"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0 < 2.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
3930278106bd105ebf9d7af848ef3b5d0ca0b144
|
Use https in fixtures to make it easier to get past firewalls
|
diff --git a/.fixtures.yml b/.fixtures.yml
index f65dff1..2e11f1b 100644
--- a/.fixtures.yml
+++ b/.fixtures.yml
@@ -1,26 +1,26 @@
fixtures:
repositories:
firewall:
- repo: 'git://github.com/puppetlabs/puppetlabs-firewall.git'
+ repo: 'https://github.com/puppetlabs/puppetlabs-firewall.git'
ref: '0.2.1'
stdlib:
- repo: 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
+ repo: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
ref: '4.6.0'
mysql:
- repo: 'git://github.com/puppetlabs/puppetlabs-mysql.git'
+ repo: 'https://github.com/puppetlabs/puppetlabs-mysql.git'
ref: '2.0.1-rc1'
passenger:
- repo: 'git://github.com/puppetlabs/puppetlabs-passenger.git'
+ repo: 'https://github.com/puppetlabs/puppetlabs-passenger.git'
ref: '0.0.4'
apache:
- repo: 'git://github.com/puppetlabs/puppetlabs-apache.git'
+ repo: 'https://github.com/puppetlabs/puppetlabs-apache.git'
ref: '0.5.0-rc1'
concat:
- repo: 'git://github.com/puppetlabs/puppetlabs-concat.git'
+ repo: 'https://github.com/puppetlabs/puppetlabs-concat.git'
ref: '1.0.0'
common:
- repo: 'git://github.com/ghoneycutt/puppet-module-common.git'
+ repo: 'https://github.com/ghoneycutt/puppet-module-common.git'
htpasswd:
- repo: 'git://github.com/leinaddm/puppet-htpasswd.git'
+ repo: 'https://github.com/leinaddm/puppet-htpasswd.git'
symlinks:
puppet: "#{source_dir}"
|
ghoneycutt/puppet-module-puppet
|
f10568b6daf75549706960fd0e6e5769a75d8650
|
Fix inconsistency w/ stdlib between metadata and fixtures and add bounds
|
diff --git a/metadata.json b/metadata.json
index 1f1f494..4a9ab76 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
"version": "2.16.0",
"author": "ghoneycutt",
"summary": "Manage Puppet",
+ "description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
- "version_requirement": "3.2.x"
+ "version_requirement": ">= 3.2.0 < 5.0.0"
},
{
"name": "puppet",
- "version_requirement": "3.x"
+ "version_requirement": ">= 3.0.0 < 5.0.0"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
- "description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
- {"name":"ghoneycutt/common","version_requirement":">= 1.0.3"},
- {"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
- {"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0"},
- {"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
- {"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
- {"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
- {"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
- {"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
+ {"name":"ghoneycutt/common","version_requirement":">= 1.0.3 < 2.0.0"},
+ {"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1 < 2.0.0"},
+ {"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 6.0.0"},
+ {"name":"puppetlabs/mysql","version_requirement":">= 2.0.0 < 3.0.0"},
+ {"name":"puppetlabs/passenger","version_requirement":">= 0.0.4 < 2.0.0"},
+ {"name":"puppetlabs/apache","version_requirement":">= 0.5.0 < 2.0.0"},
+ {"name":"puppetlabs/firewall","version_requirement":">= 0.2.1 < 2.0.0"},
+ {"name":"puppetlabs/concat","version_requirement":">= 1.0.0 < 2.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
dd22f5a161c0676daad879707683162f035d030e
|
parameterize ssldir in puppet agent's config
|
diff --git a/README.md b/README.md
index 4b2b21f..6f98e93 100644
--- a/README.md
+++ b/README.md
@@ -1,727 +1,733 @@
# puppet-module-puppet #
===
[](https://travis-ci.org/ghoneycutt/puppet-module-puppet)
This module handles the various parts of puppet on a given machine.
Dependencies for this module are: apache, common, mysql and passenger
## Components ##
### Agent
---------
- Manages the puppet agent on a client
- Setup of configuration files
- Setup of service or crontask to run the agent periodically
- Ensure puppet agent is run at boottime
### Master
----------
- Manages apache with passenger
- Setup of config files needed to run master
- Calls the `puppet::lint` class
- Calls the `puppet::master::maintenance` class
- Manages firewall rule for puppet if needed
- Maintenance to purge filebucket and reports
### Dashboard
-------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This installation is used by puppet systems, that need access to the dashboard
### Dashboard Server
--------------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This is the actual server running the Dashboard
- Configures the Dashboard MySQL settings
- Creates database for puppet with mysql module
- Calls the `puppet::dashboard::maintenance` class
- Maintenance to clean up old reports, optimize database and dump database
- For the maintenance cron jobs, you should have the following line in your `/etc/sudoers` which is not managed with this module.
<pre>
Defaults:root !requiretty
</pre>
### Lint
--------
- Manages [puppet-lint](http://github.com/rodjek/puppet-lint)
## Compatibility ##
-------------------
Ruby versions 1.8.7, 1.9.3, 2.0.0 and 2.1.0 on Puppet v3.
### Puppet Master
-----------------
* Debian 6
* Debian 7
* EL 6
* Ubuntu 12.04 LTS
### Puppet Agent
----------------
* Debian 6
* Debian 7
* EL 6
* EL 7
* Solaris
* Suse 11
* Ubuntu 12.04 LTS
===
## Class `puppet::agent` ##
### Parameters ###
certname
--------
The certificate name for the client.
- *Default*: $::fqdn
config_path
-----------
The location of the puppet config file.
- *Default*: /etc/puppet/puppet.conf
config_owner
------------
The owner of the config file.
- *Default*: root
config_group
------------
The group for the config file.
- *Default*: root
config_mode
-----------
The mode for the config file.
- *Default*: 0644
env
---
The selected environment for the client.
- *Default*: $::env
puppet_server
-------------
The puppet server the client should connect to.
- *Default*: puppet
puppet_masterport
-----------------
The masterport setting in puppet.conf. By default this line is not set.
- *Default*: UNSET
puppet_ca_server
----------------
The puppet CA server the client should use
- *Default*: UNSET
http_proxy_host
---------------
The http-proxy the client should use
- *Default*: UNSET
http_proxy_port
----------------
The http-proxy port the client should use
- *Default*: UNSET
is_puppet_master
----------------
Whether the machine is a puppet master or not.
- *Default*: false
run_method
----------
Whether to run as a service or in cron mode. Valid values are `disable`, `cron`, and `service`. The value `disable` disables automatic puppet runs and assumes you are running as a service.
- *Default*: service
run_interval
------------
The interval, in minutes, with which the client should run. If greater than 30, the agent will only run once per hour.
- *Default*: 30
run_in_noop
-----------
Whether the client should run in noop mode or not.
- *Default*: false
cron_command
------------
The command that should be added to the crontab (in cron mode)
- *Default*: /usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay
run_at_boot
-----------
Whether the client should run right after boot
- *Default*: true
puppet_binary
-------------
Path to puppet binary to create symlink from
- *Default*: '/usr/bin/puppet'
symlink_puppet_binary_target
----------------------------
Path to where the symlink should be created
- *Default*: '/usr/local/bin/puppet'
symlink_puppet_binary
---------------------
Boolean for ensuring a symlink for puppet_binary to symlink_puppet_binary_target. This is useful if you install puppet in a non-standard location that is not in your $PATH.
- *Default*: false
agent_sysconfig
---------------
The location of puppet agent sysconfig file.
- *Default*: use defaults based on osfamily
agent_sysconfig_ensure
----------------------
String for 'file' or 'present'. Allows you to not manage the sysconfig file.
- *Default*: use defaults based on osfamily
daemon_name
-----------
The name the puppet agent daemon should run as.
- *Default*: puppet
+ssldir
+------
+String with absolute path for ssldir in puppet agent's config. Using the default will set it to: '$vardir/ssl'
+
+- *Default*: 'USE_DEFAULTS'
+
stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
- *Default*: true
etckeeper_hooks
---------------
Boolean to include pre- and postrun hooks for etckeeper in the main section of the puppet agent's config.
- *Default*: false
===
## Class `puppet::dashboard` ##
### Parameters ###
dashboard_package
-----------------
String or Array of the dashboard package(s) name.
- *Default*: 'puppet-dashboard'
dashboard_user
--------------
The user for dashboard installation.
- *Default*: use defaults based on osfamily
dashboard_group
--------------
The group for dashboard installation.
- *Default*: use defaults based on osfamily
sysconfig_path
-------------------
The location of puppet dashboard sysconfig file.
- *Default*: use defaults based on osfamily
external_node_script_path
-------------------------
The script to call from puppet to get manifests from dashboard.
- *Default*: /usr/share/puppet-dashboard/bin/external_node
dashboard_fqdn
--------------
The dashboard server FQDN.
- *Default*: puppet.${::domain}
port
----
The port the web server will respond to.
- *Default*: 3000
manage_mysql_options
--------------------
Boolean to use modules default mysql::server settings (mysql_max_packet_size).
For specific mysql::server settings you can use hiera now:
<pre>
puppet::dashboard::server::manage_mysql_options: false
mysql::server::override_options:
mysqld:
max_allowed_packet: '32M'
innodb_buffer_pool_size: '64M'
</pre>
- *Default*: true
===
## Class `puppet::dashboard::server` ##
### Usage ###
You can optionally specify a hash of htpasswd entries in Hiera.
<pre>
---
puppet::dashboard::htpasswd:
admin:
cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
puppet:
cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
</pre>
### Parameters ###
dashboard_workers
-----------------
Number of dashboard workers to start. Only used on osfamily Debian.
- *Default*: $::processorcount
database_config_path
--------------------
The path to the database config file.
- *Default*: /usr/share/puppet-dashboard/config/database.yml
database_config_owner
---------------------
The owner of the database config file.
- *Default*: puppet-dashboard
database_config_group
---------------------
The database config file group.
- *Default*: puppet-dashboard
database_config_mode
--------------------
The database config file mode.
- *Default*: 0640
htpasswd
--------
Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
- *Default*: undef
htpasswd_path
-------------
String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
- *Default*: `/etc/puppet/dashboard.htpasswd`
htpasswd_owner
--------------
Owner of htpasswd file.
- *Default*: root
htpasswd_group
--------------
Group of htpasswd file.
- *Default*: use defaults based on osfamily
htpasswd_mode
-------------
Mode of htpasswd file.
- *Default*: 0640
log_dir
-------
The location for the puppet log files.
- *Default*: /var/log/puppet
mysql_user
----------
The user for the mysql connection.
- *Default*: dashboard
mysql_password
--------------
The password for the mysql connection.
- *Default*: puppet
mysql_max_packet_size
---------------------
The mysql max packet size.
- *Default*: 32M
security
--------
String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
- *Default*: 'none'
vhost_path
----------
The location of puppet dashboard vhost file for apache.
- *Default*: use defaults based on osfamily
===
## Class `puppet::dashboard::maintenance` ##
### Parameters ###
db_optimization_command
-----------------------
The command to run to optimize the db.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
db_optimization_user
--------------------
The user to run db optimization.
- *Default*: root
db_optimization_hour
--------------------
The hour on which to run db optimization.
- *Default*: 0
db_optimization_minute
----------------------
The minute at which to run db optimization.
- *Default*: 0
db_optimization_monthday
------------------------
The day of the month on which to run db optimization.
- *Default*: 1
reports_days_to_keep
--------------------
How many days to keep the reports.
- *Default*: 30
purge_old_reports_command
-------------------------
Which command to run to purge old reports.
Defaults to: '/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=${reports_days_to_keep} unit=day >> /var/log/puppet/dashboard_maintenance.log'
If using a specific command here, please keep in mind you need to align it with $reports_days_to_keep yourself.
- *Default*: 'USE_DEFAULTS'
purge_old_reports_user
----------------------
User to purge reports as.
- *Default*: root
purge_old_reports_hour
----------------------
On which hour to purge old reports.
- *Default*: 0
purge_old_reports_minute
------------------------
At which minute to purge old reports.
- *Default*: 30
remove_old_reports_spool
------------------------
Whether we should remove old dashboard reports that have not been imported
- *Default*: 'True'
reports_spool_dir
-----------------
Path to reports in dashboard spool
- *Default*: '/usr/share/puppet-dashboard/spool'
reports_spool_days_to_keep
--------------------------
How many days to keep the unimported reports.
remove_reports_spool_user
-------------------------
User to remove unimported reports.
- *Default*: root
remove_reports_spool_hour
-------------------------
On which hour to remove unimported reports.
- *Default*: 0
remove_reports_spool_minute
---------------------------
At which minute to remove unimported reports
- *Default*: 45
dump_dir
--------
The directory to use for dumps.
- *Default*: /var/local
dump_database_command
---------------------
The command to run to dump the database.
Defaults to: 'cd ~puppet-dashboard && sudo -u ${puppet::dashboard::dashboard_user_real} /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=${dump_dir}/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 ${dump_dir}/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1'
If using a specific command here, please keep in mind you need to align it with $puppet::dashboard::dashboard_user & $dump_dir yourself.
- *Default*: 'USE_DEFAULTS'
dump_database_user
------------------
User to dump database as.
- *Default*: root
dump_database_hour
------------------
On which hour to dump database.
- *Default*: 1
dump_database_minute
--------------------
At which minute to purge old reports.
- *Default*: 0
days_to_keep_backups
--------------------
Number of days to keep database backups.
- *Default*: 7
purge_old_db_backups_user
-------------------------
User to purge old database dumps as.
- *Default*: root
purge_old_db_backups_hour
-------------------------
On which hour to purge old database dumps.
- *Default*: 2
purge_old_db_backups_minute
---------------------------
At which minute to purge old database dumps.
- *Default*: 0
===
## Class `puppet::lint` ##
### Parameters ###
ensure
------
Whether to install lint.
- *Default*: present
provider
--------
Which provider should supply lint.
- *Default*: gem
version
-------
If you do not want to use the default version of lint, specify which version you want to use here.
- *Default*: undef
lint_args
---------
Which args should be added to the .puppet-lint.rc file
- *Default*: --no-80chars-check
lintrc_path
-----------
The full path to the lint config file.
- *Default*: ${::root_home}/.puppet-lint.rc
lintrc_owner
------------
The owner of the lint config file.
- *Default*: root
lintrc_group
------------
The group of the lint config file.
- *Default*: root
lintrc_mode
-----------
The mode of the lint config file.
- *Default*: 0644
===
## Class `puppet::master` ##
### Usage ###
In Hiera you will need to specify the following.
<pre>
puppet::agent::is_puppet_master: 'true'
</pre>
### Parameters ###
sysconfig_path
--------------
The location of puppet master sysconfig file.
- *Default*: use defaults based on osfamily
vhost_path
----------
The location of puppet master vhost file for apache.
- *Default*: use defaults based on osfamily
rack_dir
--------
The rack directory path.
- *Default*: /usr/share/puppet/rack/puppetmasterd
puppet_user
-----------
The user the puppet master should run as.
- *Default*: puppet
manage_firewall
---------------
Whether to manage the firewall settings on the client
- *Default*: undef
===
## Class `puppet::master::maintenance` ##
If you have a cluster of puppet masters mounting the same data, you should
disable these cronjobs on all systems except for one to ensure they are not all
cleaning up the same data.
```
puppet::master::maintenance::clientbucket_cleanup_ensure: 'absent'
puppet::master::maintenance::reportdir_purge_ensure: 'absent'
```
### Parameters ###
clientbucket_cleanup_ensure
---------------------------
String for ensure parameter for filebucket_cleanup cron job.
- *Default*: 'present'
clientbucket_path
-----------------
Path to where the clientbucket files are stored.
- *Default*: /var/lib/puppet/clientbucket
clientbucket_days_to_keep
-------------------------
The number of days to keep clientbuckets
- *Default*: 30
filebucket_cleanup_command
--------------------------
Command used to cleanup the clientbuckets.
- *Default*: /usr/bin/find ${clientbucket_path} -type f -mtime +30 -exec /bin/rm -fr {} \;
filebucket_cleanup_user
-----------------------
User to run the clientbucket cleanup as.
- *Default*: root
filebucket_cleanup_hour
-----------------------
Hour on which to run the filebucket cleanup.
- *Default*: 0
filebucket_cleanup_minute
-------------------------
Minute at which to run the filebucket cleanup.
- *Default*: 0
reportdir_purge_ensure
----------------------
String for ensure parameter for purge_old_puppet_reports cron job.
- *Default*: 'present'
reportdir
---------
Directory that holds the reports. `$::puppet_reportdir` is a custom fact that reads the `reportdir` setting from Puppet's configuration. This is likely `/var/lib/puppet/reports/`.
diff --git a/manifests/agent.pp b/manifests/agent.pp
old mode 100755
new mode 100644
index 20eb9df..2695e22
--- a/manifests/agent.pp
+++ b/manifests/agent.pp
@@ -1,261 +1,269 @@
# == Class: puppet::agent
#
# Manage Puppet agents
#
# We also run puppet once at boot via cron, regardless of if you normally run
# puppet from cron or as a daemon.
#
class puppet::agent (
$certname = $::fqdn,
$config_path = '/etc/puppet/puppet.conf',
$config_owner = 'root',
$config_group = 'root',
$config_mode = '0644',
$env = $::env,
$puppet_server = 'puppet',
$puppet_masterport = 'UNSET',
$puppet_ca_server = 'UNSET',
$http_proxy_host = 'UNSET',
$http_proxy_port = 'UNSET',
$is_puppet_master = false,
$run_method = 'service',
$run_interval = '30',
$run_in_noop = false,
$cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay',
$run_at_boot = true,
$puppet_binary = '/usr/bin/puppet',
$symlink_puppet_binary_target = '/usr/local/bin/puppet',
$symlink_puppet_binary = false,
$agent_sysconfig = 'USE_DEFAULTS',
$agent_sysconfig_ensure = 'USE_DEFAULTS',
$daemon_name = 'puppet',
+ $ssldir = 'USE_DEFAULTS',
$stringify_facts = true,
$etckeeper_hooks = false,
) {
if is_string($run_in_noop) {
$run_in_noop_bool = str2bool($run_in_noop)
} else {
$run_in_noop_bool = $run_in_noop
}
validate_bool($run_in_noop_bool)
if is_string($run_at_boot) {
$run_at_boot_bool = str2bool($run_at_boot)
} else {
$run_at_boot_bool = $run_at_boot
}
validate_bool($run_at_boot_bool)
if is_string($is_puppet_master) {
$is_puppet_master_bool = str2bool($is_puppet_master)
} else {
$is_puppet_master_bool = $is_puppet_master
}
validate_bool($is_puppet_master_bool)
# env must be set, else fail, since we use it in the puppet_config template
if ! $env {
fail('puppet::agent::env must be set')
}
if $puppet_masterport != 'UNSET' and is_integer($puppet_masterport) == false {
fail("puppet::agent::puppet_masterport is set to <${puppet_masterport}>. It should be an integer.")
}
+ if $ssldir == 'USE_DEFAULTS' {
+ $ssldir_real = '$vardir/ssl'
+ } else {
+ validate_absolute_path($ssldir)
+ $ssldir_real = $ssldir
+ }
+
if is_string($stringify_facts) {
$stringify_facts_bool = str2bool($stringify_facts)
} else {
$stringify_facts_bool = $stringify_facts
}
validate_bool($stringify_facts_bool)
if is_string($etckeeper_hooks) {
$etckeeper_hooks_bool = str2bool($etckeeper_hooks)
} else {
$etckeeper_hooks_bool = $etckeeper_hooks
}
validate_bool($etckeeper_hooks_bool)
if $http_proxy_host != 'UNSET' and (is_domain_name($http_proxy_host) == false and is_ip_address($http_proxy_host) == false){
fail("puppet::agent::http_proxy_host is set to <${http_proxy_host}>. It should be a fqdn or an ip-address.")
}
if $http_proxy_port != 'UNSET' and is_integer($http_proxy_port) == false {
fail("puppet::agent::http_proxy_port is set to <${http_proxy_port}>. It should be an Integer.")
}
case $::osfamily {
'Debian': {
$default_agent_sysconfig = '/etc/default/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'RedHat': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'Solaris': {
$default_agent_sysconfig = undef
$default_agent_sysconfig_ensure = 'absent'
}
'Suse': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
default: {
fail("puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <${::osfamily}>.")
}
}
if $agent_sysconfig == 'USE_DEFAULTS' {
$agent_sysconfig_real = $default_agent_sysconfig
} else {
$agent_sysconfig_real = $agent_sysconfig
}
if $agent_sysconfig_ensure == 'USE_DEFAULTS' {
$agent_sysconfig_ensure_real = $default_agent_sysconfig_ensure
} else {
$agent_sysconfig_ensure_real = $agent_sysconfig_ensure
}
if $is_puppet_master_bool == false {
$config_content = template('puppet/puppetagent.conf.erb')
} else {
$config_content = undef
}
case $run_method {
'service': {
$daemon_ensure = 'running'
$daemon_enable = true
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
'cron': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_run_one = fqdn_rand($run_interval)
$cron_run_two = fqdn_rand($run_interval) + 30
$cron_ensure = 'present'
$cron_user = 'root'
$cron_hour = '*'
if $run_interval > 30 {
$cron_minute = $cron_run_one
} else {
$cron_minute = [$cron_run_one, $cron_run_two]
}
if $run_in_noop_bool == true {
$my_cron_command = "${cron_command} --noop"
} else {
$my_cron_command = $cron_command
}
}
'disable': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
default: {
fail("puppet::agent::run_method is ${run_method} and must be 'disable', 'service' or 'cron'.")
}
}
if $run_at_boot_bool == true {
$at_boot_ensure = 'present'
} else {
$at_boot_ensure = 'absent'
}
if is_string($symlink_puppet_binary) {
$symlink_puppet_binary_bool = str2bool($symlink_puppet_binary)
} else {
$symlink_puppet_binary_bool = $symlink_puppet_binary
}
validate_bool($symlink_puppet_binary_bool)
validate_absolute_path($puppet_binary)
validate_absolute_path($symlink_puppet_binary_target)
# optionally create symlinks to puppet binary
if $symlink_puppet_binary_bool == true {
file { 'puppet_symlink':
ensure => link,
path => $symlink_puppet_binary_target,
target => $puppet_binary,
}
}
file { 'puppet_config':
path => $config_path,
content => $config_content,
owner => $config_owner,
group => $config_group,
mode => $config_mode,
}
if ($etckeeper_hooks_bool) {
file { 'etckeeper_pre':
path => '/etc/puppet/etckeeper-commit-pre',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/puppet/etckeeper-commit-pre'
}
file { 'etckeeper_post':
path => '/etc/puppet/etckeeper-commit-post',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/puppet/etckeeper-commit-post'
}
}
if $default_agent_sysconfig_ensure =~ /(present)|(file)/ {
file { 'puppet_agent_sysconfig':
ensure => $agent_sysconfig_ensure_real,
path => $agent_sysconfig_real,
content => template('puppet/agent_sysconfig.erb'),
owner => 'root',
group => 'root',
mode => '0644',
}
}
service { 'puppet_agent_daemon':
# GH: This service will always show as being running while an agent run is
# taking place, so we no longer ensure its status. Before doing this, there
# would *always* be a logged change and the Console could never be green.
#ensure => $daemon_ensure,
name => $daemon_name,
enable => $daemon_enable,
}
cron { 'puppet_agent':
ensure => $cron_ensure,
command => $my_cron_command,
user => $cron_user,
hour => $cron_hour,
minute => $cron_minute,
}
if $run_method == 'cron' {
cron { 'puppet_agent_once_at_boot':
ensure => $at_boot_ensure,
command => $my_cron_command,
user => $cron_user,
special => 'reboot',
}
}
}
diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb
index fd70408..6d6bc4b 100644
--- a/spec/classes/agent_spec.rb
+++ b/spec/classes/agent_spec.rb
@@ -1,705 +1,738 @@
require 'spec_helper'
describe 'puppet::agent' do
describe 'config file' do
context 'with default settings' do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/masterport =/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should_not contain_file('puppet_config').with_content(/^\s*http_proxy_host =/) }
it { should_not contain_file('puppet_config').with_content(/^\s*http_proxy_port =/) }
it { should contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
it { should_not contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
['false',false].each do |value|
context "with is_puppet_master set to #{value} (default)" do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) do
{ :env => 'production',
:is_puppet_master => value,
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['true',true].each do |value|
context "with is_puppet_master set to #{value}" do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) do
{ :env => 'production',
:is_puppet_master => value,
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'content' => nil,
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should_not contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should_not contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should_not contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
end
describe 'with run_interval' do
['29','30',30,'45',56].each do |value|
context "set to #{value}" do
let(:facts) do
{
:osfamily => 'RedHat',
:fqdn => 'agent.learnpuppet.com',
}
end
let(:params) do
{
:run_method => 'cron',
:run_interval => value,
:env => 'production',
}
end
# Values here are from trial and error based on the fqdn above. Not
# sure if it is possible to stub fqdn_rand()
if value.to_s > '30'
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'minute' => 39,
})
}
else
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'minute' => ['7', 37],
})
}
end
end
end
[true,false,{ 'k' => 'v'},['1','2']].each do |value|
context "set to invalid value #{value}" do
let(:facts) do
{
:osfamily => 'RedHat',
:fqdn => 'agent.learnpuppet.com',
}
end
let(:params) do
{
:run_method => 'cron',
:run_interval => value,
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/^undefined method `to_i'/)
end
end
end
end
+ let(:facts) { { :osfamily => 'RedHat' } }
+ describe 'with ssldir' do
+ ['/var/lib/puppet/ssl-test','/srv/puppet/ssl'].each do |value|
+ context "set to valid #{value} (as #{value.class})" do
+ let(:params) do
+ {
+ :ssldir => value,
+ :env => 'production',
+ }
+ end
+
+ it { should contain_file('puppet_config').with_content(/^\s*ssldir = #{Regexp.escape(value)}$/) }
+ end
+ end
+
+ ['../../relative/path','',242,2.42,['array'],a={'ha'=>'sh'},true,nil].each do |value|
+ context "set to invalid #{value} (as #{value.class})" do
+ let(:params) do
+ {
+ :ssldir => value,
+ :env => 'production',
+ }
+ end
+
+ it 'should fail' do
+ expect {
+ should contain_class('puppet::agent')
+ }.to raise_error(Puppet::Error,/is not an absolute path/)
+ end
+ end
+ end
+ end
+
describe 'with stringify_facts' do
['true',true].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['false',false].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = false$/) }
end
end
context 'set to an invalid setting' do
let(:params) do
{
:stringify_facts => 'invalid',
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean given/)
end
end
end
describe 'sysconfig file' do
context 'Puppet agent sysconfig file on osfamily RedHat' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Debian',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on Ubuntu' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Solaris' do
let(:facts) { { :osfamily => 'Solaris' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should_not contain_file('puppet_agent_sysconfig') }
end
context 'Puppet agent sysconfig file on osfamily Suse' do
let(:facts) { { :osfamily => 'Suse' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on invalid osfamily' do
let(:facts) { { :osfamily => 'invalid' } }
let(:params) { { :env => 'production' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <invalid>./)
end
end
end
describe 'with symlink_puppet_binary' do
['true',true].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/usr/local/bin/puppet',
'target' => '/usr/bin/puppet',
'ensure' => 'link',
})
}
end
end
['false',false].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it { should_not contain_file('puppet_symlink') }
end
end
context 'enabled with all params specified' do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => '/bar',
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/bar',
'target' => '/foo/bar',
'ensure' => 'link',
})
}
end
context 'enabled with invalid puppet_binary' do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => 'invalid/path',
:symlink_puppet_binary_target => '/bar' } }
it 'should fail' do
expect {
should contain_class('puppet::master')
}.to raise_error(Puppet::Error,/^"invalid\/path" is not an absolute path./)
end
end
context 'enabled with invalid symlink_puppet_binary_target' do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => 'invalid/path' } }
it 'should fail' do
expect {
should contain_class('puppet::master')
}.to raise_error(Puppet::Error,/^"invalid\/path" is not an absolute path./)
end
end
end
describe 'with run_method' do
context 'set to disable' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'disable',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => false,
})
}
end
context 'set to service' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'service',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => true,
})
}
end
context 'set to cron' do
context 'with run_in_noop set to non-string and non-boolean' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => ['invalid_type','not_a_string','not_a_boolean'],
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/^\["invalid_type", "not_a_string", "not_a_boolean"\] is not a boolean./)
end
end
context 'with run_in_noop set to invalid string' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => 'invalid_string',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean given/)
end
end
cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
# iterate through a matrix of setting true and false as booleans and
# strings for both run_in_noop and run_at_boot.
['true',true,'false',false].each do |rin_value|
context "with run_in_noop => #{rin_value}" do
['true',true,'false',false].each do |rab_value|
context "and run_at_boot => #{rab_value}" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => rin_value,
:run_at_boot => rab_value,
}
end
if rin_value == true or rin_value == 'true' then
command = "#{cron_command} --noop"
else
command = cron_command
end
if rab_value == true or rab_value == 'true' then
at_boot_ensure = 'present'
else
at_boot_ensure = 'absent'
end
it { should contain_class('puppet::agent') }
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'user' => 'root',
'command' => command,
})
}
it { should contain_cron('puppet_agent_once_at_boot').with({
'ensure' => at_boot_ensure,
'user' => 'root',
'command' => command,
'special' => 'reboot',
})
}
end
end
end
end
end
end
describe 'with puppet_masterport' do
context 'set to integer' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => '8888',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with_content(/^\s*masterport = 8888$/) }
end
context 'set to a string that is not an integer (foo)' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => 'foo',
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::puppet_masterport is set to <foo>. It should be an integer./)
end
end
context 'set to an invalid type (non-string)' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => ['invalid','type'],
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::puppet_masterport is set to <invalidtype>\. It should be an integer\./)
end
end
end
describe 'with etckeeper_hooks' do
['true',true].each do |value|
context "set to #{value}" do
let(:params) do
{
:etckeeper_hooks => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('etckeeper_pre') }
it { should contain_file('etckeeper_post') }
it { should contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
it { should contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
end
['false',false].each do |value|
context "set to #{value}" do
let(:params) do
{
:etckeeper_hooks => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should_not contain_file('etckeeper_pre') }
it { should_not contain_file('etckeeper_post') }
it { should_not contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
it { should_not contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
end
context 'set to an invalid setting' do
let(:params) do
{
:etckeeper_hooks => 'invalid',
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean given/)
end
end
end
describe 'with http_proxy_host' do
context 'set to a valid domain' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_host => 'proxy.host.local.domain',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it {should contain_file('puppet_config').with_content(/^\s*http_proxy_host = proxy\.host\.local\.domain$/) }
end
['8.8.8.8','2a00:1450:400f:804::1011'].each do |ip_address|
context "set to #{ip_address} (ip-address)" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :env => 'production',
:http_proxy_host => ip_address,
}
end
it { should contain_file('puppet_config').with_content(/\s*http_proxy_host = #{Regexp.escape(ip_address)}$/) }
end
end
['8.8.8.8.#','".#.%.!','foo..bar'].each do |invalid_value|
context "set to #{invalid_value} (invalid value)" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :env => 'production',
:http_proxy_host => invalid_value,
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::http_proxy_host is set to <#{Regexp.escape(invalid_value)}>. It should be a fqdn or an ip-address./)
end
end
end
context 'set to an invalid type' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_host => ['invalid','type'],
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::http_proxy_host is set to <invalidtype>\. It should be a fqdn or an ip-address\./)
end
end
end
describe 'with http_proxy_port' do
diff --git a/templates/puppetagent.conf.erb b/templates/puppetagent.conf.erb
index 01f873d..a2252b9 100644
--- a/templates/puppetagent.conf.erb
+++ b/templates/puppetagent.conf.erb
@@ -1,64 +1,64 @@
# This file is being maintained by Puppet.
# DO NOT EDIT
[main]
# The Puppet log directory.
# The default value is '$vardir/log'.
logdir = /var/log/puppet
# Where Puppet PID files are kept.
# The default value is '$vardir/run'.
rundir = /var/run/puppet
# Where SSL certificates are kept.
# The default value is '$confdir/ssl'.
- ssldir = $vardir/ssl
+ ssldir = <%= @ssldir_real %>
archive_files = true
archive_file_server = <%= @puppet_server %>
# If stringify_facts is true, you have the classic facter fact that is
# always a string. If set to false, then you can use structured facts which
# were introduced in Facter v2
stringify_facts = <%= @stringify_facts_bool %>
<% if @etckeeper_hooks_bool == true %>
prerun_command=/etc/puppet/etckeeper-commit-pre
postrun_command=/etc/puppet/etckeeper-commit-post
<% end -%>
[agent]
# The file in which puppetd stores a list of the classes
# associated with the retrieved configuratiion. Can be loaded in
# the separate ``puppet`` executable using the ``--loadclasses``
# option.
# The default value is '$confdir/classes.txt'.
classfile = $vardir/classes.txt
# Where puppetd caches the local configuration. An
# extension indicating the cache format is added automatically.
# The default value is '$confdir/localconfig'.
localconfig = $vardir/localconfig
certname = <%= @certname %>
server = <%= @puppet_server %>
<% if @puppet_masterport != 'UNSET' -%>
masterport = <%= @puppet_masterport %>
<% end -%>
<% if @puppet_ca_server != 'UNSET' -%>
ca_server = <%= @puppet_ca_server %>
<% end -%>
<% if @http_proxy_host != 'UNSET' -%>
http_proxy_host = <%= @http_proxy_host %>
<% end -%>
<% if @http_proxy_port != 'UNSET' -%>
http_proxy_port = <%= @http_proxy_port %>
<% end -%>
report = true
graph = true
pluginsync = true
<% if @run_method == 'service' %>
noop = <%= @run_in_noop %>
<% end -%>
<% if @env != 'production' -%>
environment = <%= @env %>
<% end -%>
|
ghoneycutt/puppet-module-puppet
|
6981e27dfab97e61cc6fb4ff30f35172c2a16abf
|
Changed outdated type-function to is_<type> and set stdlib version to 4.6
|
diff --git a/Modulefile b/Modulefile
index 30c7281..8055a88 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,17 +1,17 @@
name 'ghoneycutt-puppet'
version '2.15.0'
source 'git://github.com/ghoneycutt/puppet-module-puppet.git'
author 'ghoneycutt'
license 'Apache-2.0'
summary 'Manage Puppet'
description 'Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.'
project_page 'https://github.com/ghoneycutt/puppet-module-puppet'
dependency 'ghoneycutt/common', '>= 1.0.3'
dependency 'leinaddm/htpasswd', '>= 0.0.1'
-dependency 'puppetlabs/stdlib', '>= 3.2.0'
+dependency 'puppetlabs/stdlib', '>= 4.6.0'
dependency 'puppetlabs/mysql', '>= 2.0.0'
dependency 'puppetlabs/passenger', '>= 0.0.4'
dependency 'puppetlabs/apache', '>= 0.5.0'
dependency 'puppetlabs/firewall', '>= 0.2.1'
dependency 'puppetlabs/concat', '>= 1.0.0'
diff --git a/manifests/agent.pp b/manifests/agent.pp
index 1910214..20eb9df 100755
--- a/manifests/agent.pp
+++ b/manifests/agent.pp
@@ -1,261 +1,261 @@
# == Class: puppet::agent
#
# Manage Puppet agents
#
# We also run puppet once at boot via cron, regardless of if you normally run
# puppet from cron or as a daemon.
#
class puppet::agent (
$certname = $::fqdn,
$config_path = '/etc/puppet/puppet.conf',
$config_owner = 'root',
$config_group = 'root',
$config_mode = '0644',
$env = $::env,
$puppet_server = 'puppet',
$puppet_masterport = 'UNSET',
$puppet_ca_server = 'UNSET',
$http_proxy_host = 'UNSET',
$http_proxy_port = 'UNSET',
$is_puppet_master = false,
$run_method = 'service',
$run_interval = '30',
$run_in_noop = false,
$cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay',
$run_at_boot = true,
$puppet_binary = '/usr/bin/puppet',
$symlink_puppet_binary_target = '/usr/local/bin/puppet',
$symlink_puppet_binary = false,
$agent_sysconfig = 'USE_DEFAULTS',
$agent_sysconfig_ensure = 'USE_DEFAULTS',
$daemon_name = 'puppet',
$stringify_facts = true,
$etckeeper_hooks = false,
) {
- if type($run_in_noop) == 'String' {
+ if is_string($run_in_noop) {
$run_in_noop_bool = str2bool($run_in_noop)
} else {
$run_in_noop_bool = $run_in_noop
}
validate_bool($run_in_noop_bool)
- if type($run_at_boot) == 'String' {
+ if is_string($run_at_boot) {
$run_at_boot_bool = str2bool($run_at_boot)
} else {
$run_at_boot_bool = $run_at_boot
}
validate_bool($run_at_boot_bool)
- if type($is_puppet_master) == 'String' {
+ if is_string($is_puppet_master) {
$is_puppet_master_bool = str2bool($is_puppet_master)
} else {
$is_puppet_master_bool = $is_puppet_master
}
validate_bool($is_puppet_master_bool)
# env must be set, else fail, since we use it in the puppet_config template
if ! $env {
fail('puppet::agent::env must be set')
}
if $puppet_masterport != 'UNSET' and is_integer($puppet_masterport) == false {
fail("puppet::agent::puppet_masterport is set to <${puppet_masterport}>. It should be an integer.")
}
- if type($stringify_facts) == 'string' {
+ if is_string($stringify_facts) {
$stringify_facts_bool = str2bool($stringify_facts)
} else {
$stringify_facts_bool = $stringify_facts
}
validate_bool($stringify_facts_bool)
- if type($etckeeper_hooks) == 'String' {
+ if is_string($etckeeper_hooks) {
$etckeeper_hooks_bool = str2bool($etckeeper_hooks)
} else {
$etckeeper_hooks_bool = $etckeeper_hooks
}
validate_bool($etckeeper_hooks_bool)
if $http_proxy_host != 'UNSET' and (is_domain_name($http_proxy_host) == false and is_ip_address($http_proxy_host) == false){
fail("puppet::agent::http_proxy_host is set to <${http_proxy_host}>. It should be a fqdn or an ip-address.")
}
if $http_proxy_port != 'UNSET' and is_integer($http_proxy_port) == false {
fail("puppet::agent::http_proxy_port is set to <${http_proxy_port}>. It should be an Integer.")
}
case $::osfamily {
'Debian': {
$default_agent_sysconfig = '/etc/default/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'RedHat': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'Solaris': {
$default_agent_sysconfig = undef
$default_agent_sysconfig_ensure = 'absent'
}
'Suse': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
default: {
fail("puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <${::osfamily}>.")
}
}
if $agent_sysconfig == 'USE_DEFAULTS' {
$agent_sysconfig_real = $default_agent_sysconfig
} else {
$agent_sysconfig_real = $agent_sysconfig
}
if $agent_sysconfig_ensure == 'USE_DEFAULTS' {
$agent_sysconfig_ensure_real = $default_agent_sysconfig_ensure
} else {
$agent_sysconfig_ensure_real = $agent_sysconfig_ensure
}
if $is_puppet_master_bool == false {
$config_content = template('puppet/puppetagent.conf.erb')
} else {
$config_content = undef
}
case $run_method {
'service': {
$daemon_ensure = 'running'
$daemon_enable = true
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
'cron': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_run_one = fqdn_rand($run_interval)
$cron_run_two = fqdn_rand($run_interval) + 30
$cron_ensure = 'present'
$cron_user = 'root'
$cron_hour = '*'
if $run_interval > 30 {
$cron_minute = $cron_run_one
} else {
$cron_minute = [$cron_run_one, $cron_run_two]
}
if $run_in_noop_bool == true {
$my_cron_command = "${cron_command} --noop"
} else {
$my_cron_command = $cron_command
}
}
'disable': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
default: {
fail("puppet::agent::run_method is ${run_method} and must be 'disable', 'service' or 'cron'.")
}
}
if $run_at_boot_bool == true {
$at_boot_ensure = 'present'
} else {
$at_boot_ensure = 'absent'
}
- if type($symlink_puppet_binary) == 'string' {
+ if is_string($symlink_puppet_binary) {
$symlink_puppet_binary_bool = str2bool($symlink_puppet_binary)
} else {
$symlink_puppet_binary_bool = $symlink_puppet_binary
}
validate_bool($symlink_puppet_binary_bool)
validate_absolute_path($puppet_binary)
validate_absolute_path($symlink_puppet_binary_target)
# optionally create symlinks to puppet binary
if $symlink_puppet_binary_bool == true {
file { 'puppet_symlink':
ensure => link,
path => $symlink_puppet_binary_target,
target => $puppet_binary,
}
}
file { 'puppet_config':
path => $config_path,
content => $config_content,
owner => $config_owner,
group => $config_group,
mode => $config_mode,
}
if ($etckeeper_hooks_bool) {
file { 'etckeeper_pre':
path => '/etc/puppet/etckeeper-commit-pre',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/puppet/etckeeper-commit-pre'
}
file { 'etckeeper_post':
path => '/etc/puppet/etckeeper-commit-post',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/puppet/etckeeper-commit-post'
}
}
if $default_agent_sysconfig_ensure =~ /(present)|(file)/ {
file { 'puppet_agent_sysconfig':
ensure => $agent_sysconfig_ensure_real,
path => $agent_sysconfig_real,
content => template('puppet/agent_sysconfig.erb'),
owner => 'root',
group => 'root',
mode => '0644',
}
}
service { 'puppet_agent_daemon':
# GH: This service will always show as being running while an agent run is
# taking place, so we no longer ensure its status. Before doing this, there
# would *always* be a logged change and the Console could never be green.
#ensure => $daemon_ensure,
name => $daemon_name,
enable => $daemon_enable,
}
cron { 'puppet_agent':
ensure => $cron_ensure,
command => $my_cron_command,
user => $cron_user,
hour => $cron_hour,
minute => $cron_minute,
}
if $run_method == 'cron' {
cron { 'puppet_agent_once_at_boot':
ensure => $at_boot_ensure,
command => $my_cron_command,
user => $cron_user,
special => 'reboot',
}
}
}
diff --git a/manifests/dashboard.pp b/manifests/dashboard.pp
index 2e19396..d74735d 100644
--- a/manifests/dashboard.pp
+++ b/manifests/dashboard.pp
@@ -1,89 +1,89 @@
# == Class: puppet::dashboard
#
class puppet::dashboard (
$dashboard_package = 'puppet-dashboard',
$dashboard_user = 'USE_DEFAULTS',
$dashboard_group = 'USE_DEFAULTS',
$sysconfig_path = 'USE_DEFAULTS',
$external_node_script_path = '/usr/share/puppet-dashboard/bin/external_node',
$dashboard_fqdn = "puppet.${::domain}",
$port = '3000',
) {
validate_absolute_path($external_node_script_path)
- if type($dashboard_package) != 'String' and type($dashboard_package) != 'Array' {
+ if !is_string($dashboard_package) and !is_array($dashboard_package) {
fail('puppet::dashboard::dashboard_package must be a string or an array.')
}
case $::osfamily {
'RedHat': {
$default_sysconfig_path = '/etc/sysconfig/puppet-dashboard'
$sysconfig_template = 'dashboard_sysconfig.erb'
$default_dashboard_user = 'puppet-dashboard'
$default_dashboard_group = 'puppet-dashboard'
}
'Debian': {
$default_sysconfig_path = '/etc/default/puppet-dashboard'
$sysconfig_template = 'dashboard_default.erb'
$default_dashboard_user = 'puppet'
$default_dashboard_group = 'puppet'
}
default: {
fail("puppet::dashboard supports osfamilies Debian and RedHat. Detected osfamily is <${::osfamily}>.")
}
}
if $sysconfig_path == 'USE_DEFAULTS' {
$sysconfig_path_real = $default_sysconfig_path
} else {
$sysconfig_path_real = $sysconfig_path
}
validate_absolute_path($sysconfig_path_real)
if $dashboard_user == 'USE_DEFAULTS' {
$dashboard_user_real = $default_dashboard_user
} else {
$dashboard_user_real = $dashboard_user
}
if $dashboard_group == 'USE_DEFAULTS' {
$dashboard_group_real = $default_dashboard_group
} else {
$dashboard_group_real = $dashboard_group
}
package { $dashboard_package:
ensure => present,
}
file { 'external_node_script':
ensure => file,
content => template('puppet/external_node.erb'),
path => $external_node_script_path,
owner => $dashboard_user_real,
group => $dashboard_group_real,
mode => '0755',
require => Package[$dashboard_package],
}
file { 'dashboard_sysconfig':
ensure => file,
path => $sysconfig_path_real,
content => template("puppet/${sysconfig_template}"),
owner => 'root',
group => 'root',
mode => '0644',
}
# Dashboard is ran under Passenger with Apache
service { 'puppet-dashboard':
ensure => stopped,
enable => false,
subscribe => File['dashboard_sysconfig'],
}
service { 'puppet-dashboard-workers':
ensure => stopped,
enable => false,
}
}
diff --git a/manifests/dashboard/maintenance.pp b/manifests/dashboard/maintenance.pp
index a0c832f..6ce7fb9 100644
--- a/manifests/dashboard/maintenance.pp
+++ b/manifests/dashboard/maintenance.pp
@@ -1,109 +1,109 @@
# == Class: puppet::dashboard::maintenance
#
class puppet::dashboard::maintenance (
$db_optimization_command = '/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log',
$db_optimization_user = 'root',
$db_optimization_hour = '0',
$db_optimization_minute = '0',
$db_optimization_monthday = '1',
$reports_days_to_keep = '30',
$purge_old_reports_command = 'USE_DEFAULTS',
$purge_old_reports_user = 'root',
$purge_old_reports_hour = '0',
$purge_old_reports_minute = '30',
$remove_old_reports_spool = true,
$reports_spool_dir = '/usr/share/puppet-dashboard/spool',
$reports_spool_days_to_keep = '7',
$remove_reports_spool_user = 'root',
$remove_reports_spool_hour = '0',
$remove_reports_spool_minute = '45',
$dump_dir = '/var/local',
$dump_database_command = 'USE_DEFAULTS',
$dump_database_user = 'root',
$dump_database_hour = '1',
$dump_database_minute = '0',
$days_to_keep_backups = '7',
$purge_old_db_backups_user = 'root',
$purge_old_db_backups_hour = '2',
$purge_old_db_backups_minute = '0',
) {
include common
require 'puppet::dashboard'
validate_absolute_path($reports_spool_dir)
validate_absolute_path($dump_dir)
validate_string($dump_database_command)
validate_integer($reports_days_to_keep)
$purge_old_reports_command_real = $purge_old_reports_command ? {
'USE_DEFAULTS' => "/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=${reports_days_to_keep} unit=day >> /var/log/puppet/dashboard_maintenance.log",
default => $purge_old_reports_command
}
$dump_database_command_real = $dump_database_command ? {
'USE_DEFAULTS' => "cd ~puppet-dashboard && sudo -u ${puppet::dashboard::dashboard_user_real} /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=${dump_dir}/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 ${dump_dir}/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1",
default => $dump_database_command
}
common::mkdir_p { $dump_dir: }
file { $dump_dir:
ensure => directory,
group => $puppet::dashboard::dashboard_group_real,
mode => '0775',
require => Common::Mkdir_p[$dump_dir],
}
cron { 'monthly_dashboard_database_optimization':
ensure => present,
command => $db_optimization_command,
user => $db_optimization_user,
hour => $db_optimization_hour,
minute => $db_optimization_minute,
monthday => $db_optimization_monthday,
}
cron { 'purge_old_reports':
ensure => present,
command => $purge_old_reports_command_real,
user => $purge_old_reports_user,
hour => $purge_old_reports_hour,
minute => $purge_old_reports_minute,
}
- if type($remove_old_reports_spool) == 'string' {
+ if is_string($remove_old_reports_spool) {
$enable_remove_old_reports_spool = str2bool($remove_old_reports_spool)
} else {
$enable_remove_old_reports_spool = $remove_old_reports_spool
}
validate_bool($enable_remove_old_reports_spool)
if $enable_remove_old_reports_spool == true {
$remove_old_reports_spool_enable = 'present'
} else {
$remove_old_reports_spool_enable = 'absent'
}
cron { 'remove_old_reports_spool':
ensure => $remove_old_reports_spool_enable,
command => "/bin/find ${reports_spool_dir} -type f -name \"*.yaml\" -mtime +${$reports_spool_days_to_keep } -exec /bin/rm -f {} \\;",
user => $remove_reports_spool_user,
hour => $remove_reports_spool_hour,
minute => $remove_reports_spool_minute,
}
cron { 'dump_dashboard_database':
command => $dump_database_command_real,
user => $dump_database_user,
hour => $dump_database_hour,
minute => $dump_database_minute,
}
cron { 'purge_old_db_backups':
command => "/bin/find ${dump_dir} -type f -mtime +${days_to_keep_backups} -exec /bin/rm -f {} \\;",
user => $purge_old_db_backups_user,
hour => $purge_old_db_backups_hour,
minute => $purge_old_db_backups_minute,
}
}
diff --git a/manifests/dashboard/server.pp b/manifests/dashboard/server.pp
index 0a7ca36..b209076 100644
--- a/manifests/dashboard/server.pp
+++ b/manifests/dashboard/server.pp
@@ -1,175 +1,172 @@
# == Class: puppet::dashboard::server
#
class puppet::dashboard::server (
$dashboard_workers = $::processorcount,
$database_config_path = '/usr/share/puppet-dashboard/config/database.yml',
$database_config_owner = 'USE_DEFAULTS',
$database_config_group = 'USE_DEFAULTS',
$database_config_mode = '0640',
$htpasswd = undef,
$htpasswd_path = '/etc/puppet/dashboard.htpasswd',
$htpasswd_owner = 'root',
$htpasswd_group = 'USE_DEFAULTS',
$htpasswd_mode = '0640',
$log_dir = '/var/log/puppet',
$manage_mysql_options = true,
$mysql_user = 'dashboard',
$mysql_password = 'puppet',
$mysql_max_packet_size = '32M',
$security = 'none',
$vhost_path = 'USE_DEFAULTS',
) inherits puppet::dashboard {
validate_re($dashboard_workers, '^\d+$',
"puppet::dashboard::server::dashboard_workers must be a digit. Detected value is <${dashboard_workers}>."
)
validate_absolute_path($htpasswd_path)
validate_re($security, '^(none|htpasswd)$',
"Security is <${security}> which does not match regex. Valid values are none and htpasswd."
)
case $::osfamily {
'RedHat': {
$default_database_config_group = $puppet::dashboard::dashboard_group_real
$default_htpasswd_group = 'apache'
$default_vhost_path = '/etc/httpd/conf.d/dashboard.conf'
}
'Debian': {
$default_database_config_group = 'www-data'
$default_htpasswd_group = 'www-data'
$default_vhost_path = '/etc/apache2/sites-enabled/puppetdashboard'
file { 'dashboard_workers_default':
ensure => file,
path => '/etc/default/puppet-dashboard-workers',
content => template('puppet/puppet-dashboard-workers.erb'),
owner => 'root',
group => 'root',
mode => '0644',
notify => Service['puppet-dashboard-workers'],
}
}
default: {
fail("puppet::dashboard::server supports osfamilies Debian and RedHat. Detected osfamily is <${::osfamily}>.")
}
}
if $database_config_owner == 'USE_DEFAULTS' {
$database_config_owner_real = $puppet::dashboard::dashboard_user_real
} else {
$database_config_owner_real = $database_config_owner
}
if $database_config_group == 'USE_DEFAULTS' {
$database_config_group_real = $default_database_config_group
} else {
$database_config_group_real = $database_config_group
}
if $htpasswd_group == 'USE_DEFAULTS' {
$htpasswd_group_real = $default_htpasswd_group
} else {
$htpasswd_group_real = $htpasswd_group
}
if $vhost_path == 'USE_DEFAULTS' {
$vhost_path_real = $default_vhost_path
} else {
$vhost_path_real = $vhost_path
}
validate_absolute_path($vhost_path_real)
require 'passenger'
include puppet::dashboard::maintenance
- case type($manage_mysql_options) {
- 'boolean': {
+ if is_bool($manage_mysql_options) {
$manage_mysql_options_real = $manage_mysql_options
- }
- 'string': {
+ } elsif is_string($manage_mysql_options) {
$manage_mysql_options_real = str2bool($manage_mysql_options)
- }
- default: {
+ } else {
fail("puppet::dashboard::server::manage_mysql_options supports booleans only and is <${manage_mysql_options}>.")
- }
}
+
if $manage_mysql_options_real == true {
class { 'mysql::server':
override_options => {
'mysqld' => {
'max_allowed_packet' => $mysql_max_packet_size,
}
}
}
} else {
include mysql::server
}
if $security == 'htpasswd' and $htpasswd != undef {
Htpasswd {
target => $htpasswd_path,
}
Htpasswd <||> -> File['dashboard_htpasswd_path']
create_resources('htpasswd',$htpasswd)
file { 'dashboard_htpasswd_path':
ensure => file,
path => $htpasswd_path,
owner => $htpasswd_owner,
group => $htpasswd_group_real,
mode => $htpasswd_mode,
}
}
file { 'database_config':
ensure => file,
content => template('puppet/database.yml.erb'),
path => $database_config_path,
owner => $database_config_owner_real,
group => $database_config_group_real,
mode => $database_config_mode,
require => Package[$puppet::dashboard::dashboard_package],
}
file { 'dashboard_vhost':
ensure => file,
path => $vhost_path_real,
content => template('puppet/dashboard-vhost.conf.erb'),
owner => 'root',
group => 'root',
mode => '0644',
require => [ File['httpd_vdir'], # apache
# Exec['compile-passenger'], # passenger
],
notify => Service['httpd'], # apache
}
mysql::db { 'dashboard':
user => $mysql_user,
password => $mysql_password,
host => 'localhost',
grant => ['ALL'],
require => [ Class['mysql::server'],
File['database_config'],
],
}
exec { 'migrate_dashboard_database':
command => 'rake RAILS_ENV=production db:migrate',
onlyif => 'rake RAILS_ENV=production db:version 2>/dev/null|grep ^\'Current version\' | awk -F : \'{print $2}\' | awk \'{print $1}\'|grep ^0$',
path => '/bin:/usr/bin:/sbin:/usr/sbin',
cwd => '/usr/share/puppet-dashboard',
refreshonly => true,
subscribe => Mysql::Db['dashboard'],
}
Service['puppet-dashboard-workers'] {
ensure => running,
enable => true,
subscribe => File['dashboard_sysconfig'],
}
}
diff --git a/metadata.json b/metadata.json
index 5d286e0..1f1f494 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
"version": "2.16.0",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
- {"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"},
+ {"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
]
}
diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb
index d738261..fd70408 100644
--- a/spec/classes/agent_spec.rb
+++ b/spec/classes/agent_spec.rb
@@ -81,663 +81,663 @@ describe 'puppet::agent' do
it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['true',true].each do |value|
context "with is_puppet_master set to #{value}" do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) do
{ :env => 'production',
:is_puppet_master => value,
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'content' => nil,
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should_not contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should_not contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should_not contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
end
describe 'with run_interval' do
['29','30',30,'45',56].each do |value|
context "set to #{value}" do
let(:facts) do
{
:osfamily => 'RedHat',
:fqdn => 'agent.learnpuppet.com',
}
end
let(:params) do
{
:run_method => 'cron',
:run_interval => value,
:env => 'production',
}
end
# Values here are from trial and error based on the fqdn above. Not
# sure if it is possible to stub fqdn_rand()
if value.to_s > '30'
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'minute' => 39,
})
}
else
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'minute' => ['7', 37],
})
}
end
end
end
[true,false,{ 'k' => 'v'},['1','2']].each do |value|
context "set to invalid value #{value}" do
let(:facts) do
{
:osfamily => 'RedHat',
:fqdn => 'agent.learnpuppet.com',
}
end
let(:params) do
{
:run_method => 'cron',
:run_interval => value,
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/^undefined method `to_i'/)
end
end
end
end
describe 'with stringify_facts' do
['true',true].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['false',false].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = false$/) }
end
end
context 'set to an invalid setting' do
let(:params) do
{
:stringify_facts => 'invalid',
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean given/)
end
end
end
describe 'sysconfig file' do
context 'Puppet agent sysconfig file on osfamily RedHat' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Debian',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on Ubuntu' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Solaris' do
let(:facts) { { :osfamily => 'Solaris' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should_not contain_file('puppet_agent_sysconfig') }
end
context 'Puppet agent sysconfig file on osfamily Suse' do
let(:facts) { { :osfamily => 'Suse' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on invalid osfamily' do
let(:facts) { { :osfamily => 'invalid' } }
let(:params) { { :env => 'production' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <invalid>./)
end
end
end
describe 'with symlink_puppet_binary' do
['true',true].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/usr/local/bin/puppet',
'target' => '/usr/bin/puppet',
'ensure' => 'link',
})
}
end
end
['false',false].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it { should_not contain_file('puppet_symlink') }
end
end
context 'enabled with all params specified' do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => '/bar',
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/bar',
'target' => '/foo/bar',
'ensure' => 'link',
})
}
end
context 'enabled with invalid puppet_binary' do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => 'invalid/path',
:symlink_puppet_binary_target => '/bar' } }
it 'should fail' do
expect {
should contain_class('puppet::master')
}.to raise_error(Puppet::Error,/^"invalid\/path" is not an absolute path./)
end
end
context 'enabled with invalid symlink_puppet_binary_target' do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => 'invalid/path' } }
it 'should fail' do
expect {
should contain_class('puppet::master')
}.to raise_error(Puppet::Error,/^"invalid\/path" is not an absolute path./)
end
end
end
describe 'with run_method' do
context 'set to disable' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'disable',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => false,
})
}
end
context 'set to service' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'service',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => true,
})
}
end
context 'set to cron' do
context 'with run_in_noop set to non-string and non-boolean' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => ['invalid_type','not_a_string','not_a_boolean'],
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/^\["invalid_type", "not_a_string", "not_a_boolean"\] is not a boolean./)
end
end
context 'with run_in_noop set to invalid string' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => 'invalid_string',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean given/)
end
end
cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
# iterate through a matrix of setting true and false as booleans and
# strings for both run_in_noop and run_at_boot.
['true',true,'false',false].each do |rin_value|
context "with run_in_noop => #{rin_value}" do
['true',true,'false',false].each do |rab_value|
context "and run_at_boot => #{rab_value}" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => rin_value,
:run_at_boot => rab_value,
}
end
if rin_value == true or rin_value == 'true' then
command = "#{cron_command} --noop"
else
command = cron_command
end
if rab_value == true or rab_value == 'true' then
at_boot_ensure = 'present'
else
at_boot_ensure = 'absent'
end
it { should contain_class('puppet::agent') }
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'user' => 'root',
'command' => command,
})
}
it { should contain_cron('puppet_agent_once_at_boot').with({
'ensure' => at_boot_ensure,
'user' => 'root',
'command' => command,
'special' => 'reboot',
})
}
end
end
end
end
end
end
describe 'with puppet_masterport' do
context 'set to integer' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => '8888',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with_content(/^\s*masterport = 8888$/) }
end
context 'set to a string that is not an integer (foo)' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => 'foo',
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::puppet_masterport is set to <foo>. It should be an integer./)
end
end
context 'set to an invalid type (non-string)' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => ['invalid','type'],
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/^puppet::agent::puppet_masterport is set to <invalidtype>. It should be an integer./)
+ }.to raise_error(Puppet::Error,/puppet::agent::puppet_masterport is set to <invalidtype>\. It should be an integer\./)
end
end
end
describe 'with etckeeper_hooks' do
['true',true].each do |value|
context "set to #{value}" do
let(:params) do
{
:etckeeper_hooks => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('etckeeper_pre') }
it { should contain_file('etckeeper_post') }
it { should contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
it { should contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
end
['false',false].each do |value|
context "set to #{value}" do
let(:params) do
{
:etckeeper_hooks => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should_not contain_file('etckeeper_pre') }
it { should_not contain_file('etckeeper_post') }
it { should_not contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
it { should_not contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
end
context 'set to an invalid setting' do
let(:params) do
{
:etckeeper_hooks => 'invalid',
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean given/)
end
end
end
describe 'with http_proxy_host' do
context 'set to a valid domain' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_host => 'proxy.host.local.domain',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it {should contain_file('puppet_config').with_content(/^\s*http_proxy_host = proxy\.host\.local\.domain$/) }
end
['8.8.8.8','2a00:1450:400f:804::1011'].each do |ip_address|
context "set to #{ip_address} (ip-address)" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :env => 'production',
:http_proxy_host => ip_address,
}
end
it { should contain_file('puppet_config').with_content(/\s*http_proxy_host = #{Regexp.escape(ip_address)}$/) }
end
end
['8.8.8.8.#','".#.%.!','foo..bar'].each do |invalid_value|
context "set to #{invalid_value} (invalid value)" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :env => 'production',
:http_proxy_host => invalid_value,
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::http_proxy_host is set to <#{Regexp.escape(invalid_value)}>. It should be a fqdn or an ip-address./)
end
end
end
context 'set to an invalid type' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_host => ['invalid','type'],
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/^puppet::agent::http_proxy_host is set to <invalidtype>. It should be a fqdn or an ip-address./)
+ }.to raise_error(Puppet::Error,/puppet::agent::http_proxy_host is set to <invalidtype>\. It should be a fqdn or an ip-address\./)
end
end
end
describe 'with http_proxy_port' do
context 'set to integer' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_port => '8888',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with_content(/^\s*http_proxy_port = 8888$/) }
end
context 'set to an invalid type' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_port => ['invalid','type'],
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/^puppet::agent::http_proxy_port is set to <invalidtype>. It should be an Integer./)
+ }.to raise_error(Puppet::Error,/puppet::agent::http_proxy_port is set to <invalidtype>\. It should be an Integer\./)
end
end
context 'set to an invalid value' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_port => 'foo',
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::http_proxy_port is set to <foo>. It should be an Integer./)
end
end
end
end
|
ghoneycutt/puppet-module-puppet
|
5b585e258f5ce2e62b085c7eb64ce374fd84f5b5
|
Release v2.16.0 - Add configurability to Dashboard maint tasks
|
diff --git a/metadata.json b/metadata.json
index b580125..5d286e0 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.15.0",
+ "version": "2.16.0",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
c6dcc642d7622629d20b6e6d23d7fb1b8bab1569
|
parameterize hardcoded maintenance commands
|
diff --git a/.fixtures.yml b/.fixtures.yml
index 4859aa8..f65dff1 100644
--- a/.fixtures.yml
+++ b/.fixtures.yml
@@ -1,26 +1,26 @@
fixtures:
repositories:
firewall:
repo: 'git://github.com/puppetlabs/puppetlabs-firewall.git'
ref: '0.2.1'
stdlib:
repo: 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
- ref: '3.2.0'
+ ref: '4.6.0'
mysql:
repo: 'git://github.com/puppetlabs/puppetlabs-mysql.git'
ref: '2.0.1-rc1'
passenger:
repo: 'git://github.com/puppetlabs/puppetlabs-passenger.git'
ref: '0.0.4'
apache:
repo: 'git://github.com/puppetlabs/puppetlabs-apache.git'
ref: '0.5.0-rc1'
concat:
repo: 'git://github.com/puppetlabs/puppetlabs-concat.git'
ref: '1.0.0'
common:
repo: 'git://github.com/ghoneycutt/puppet-module-common.git'
htpasswd:
repo: 'git://github.com/leinaddm/puppet-htpasswd.git'
symlinks:
puppet: "#{source_dir}"
diff --git a/Gemfile b/Gemfile
index 9a14f04..5d80055 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,11 +1,16 @@
source 'https://rubygems.org'
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'puppet-lint', '>= 1.0.0'
gem 'facter', '>= 1.7.0'
+
+# rspec must be v2 for ruby 1.8.7
+if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
+ gem 'rspec', '~> 2.0'
+end
diff --git a/README.md b/README.md
index 3038185..4b2b21f 100644
--- a/README.md
+++ b/README.md
@@ -1,753 +1,758 @@
# puppet-module-puppet #
===
[](https://travis-ci.org/ghoneycutt/puppet-module-puppet)
This module handles the various parts of puppet on a given machine.
Dependencies for this module are: apache, common, mysql and passenger
## Components ##
### Agent
---------
- Manages the puppet agent on a client
- Setup of configuration files
- Setup of service or crontask to run the agent periodically
- Ensure puppet agent is run at boottime
### Master
----------
- Manages apache with passenger
- Setup of config files needed to run master
- Calls the `puppet::lint` class
- Calls the `puppet::master::maintenance` class
- Manages firewall rule for puppet if needed
- Maintenance to purge filebucket and reports
### Dashboard
-------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This installation is used by puppet systems, that need access to the dashboard
### Dashboard Server
--------------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This is the actual server running the Dashboard
- Configures the Dashboard MySQL settings
- Creates database for puppet with mysql module
- Calls the `puppet::dashboard::maintenance` class
- Maintenance to clean up old reports, optimize database and dump database
- For the maintenance cron jobs, you should have the following line in your `/etc/sudoers` which is not managed with this module.
<pre>
Defaults:root !requiretty
</pre>
### Lint
--------
- Manages [puppet-lint](http://github.com/rodjek/puppet-lint)
## Compatibility ##
-------------------
Ruby versions 1.8.7, 1.9.3, 2.0.0 and 2.1.0 on Puppet v3.
### Puppet Master
-----------------
* Debian 6
* Debian 7
* EL 6
* Ubuntu 12.04 LTS
### Puppet Agent
----------------
* Debian 6
* Debian 7
* EL 6
* EL 7
* Solaris
* Suse 11
* Ubuntu 12.04 LTS
===
## Class `puppet::agent` ##
### Parameters ###
certname
--------
The certificate name for the client.
- *Default*: $::fqdn
config_path
-----------
The location of the puppet config file.
- *Default*: /etc/puppet/puppet.conf
config_owner
------------
The owner of the config file.
- *Default*: root
config_group
------------
The group for the config file.
- *Default*: root
config_mode
-----------
The mode for the config file.
- *Default*: 0644
env
---
The selected environment for the client.
- *Default*: $::env
puppet_server
-------------
The puppet server the client should connect to.
- *Default*: puppet
puppet_masterport
-----------------
The masterport setting in puppet.conf. By default this line is not set.
- *Default*: UNSET
puppet_ca_server
----------------
The puppet CA server the client should use
- *Default*: UNSET
http_proxy_host
---------------
The http-proxy the client should use
- *Default*: UNSET
http_proxy_port
----------------
The http-proxy port the client should use
- *Default*: UNSET
is_puppet_master
----------------
Whether the machine is a puppet master or not.
- *Default*: false
run_method
----------
Whether to run as a service or in cron mode. Valid values are `disable`, `cron`, and `service`. The value `disable` disables automatic puppet runs and assumes you are running as a service.
- *Default*: service
run_interval
------------
The interval, in minutes, with which the client should run. If greater than 30, the agent will only run once per hour.
- *Default*: 30
run_in_noop
-----------
Whether the client should run in noop mode or not.
- *Default*: false
cron_command
------------
The command that should be added to the crontab (in cron mode)
- *Default*: /usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay
run_at_boot
-----------
Whether the client should run right after boot
- *Default*: true
puppet_binary
-------------
Path to puppet binary to create symlink from
- *Default*: '/usr/bin/puppet'
symlink_puppet_binary_target
----------------------------
Path to where the symlink should be created
- *Default*: '/usr/local/bin/puppet'
symlink_puppet_binary
---------------------
Boolean for ensuring a symlink for puppet_binary to symlink_puppet_binary_target. This is useful if you install puppet in a non-standard location that is not in your $PATH.
- *Default*: false
agent_sysconfig
---------------
The location of puppet agent sysconfig file.
- *Default*: use defaults based on osfamily
agent_sysconfig_ensure
----------------------
String for 'file' or 'present'. Allows you to not manage the sysconfig file.
- *Default*: use defaults based on osfamily
daemon_name
-----------
The name the puppet agent daemon should run as.
- *Default*: puppet
stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
- *Default*: true
etckeeper_hooks
---------------
Boolean to include pre- and postrun hooks for etckeeper in the main section of the puppet agent's config.
- *Default*: false
===
## Class `puppet::dashboard` ##
### Parameters ###
dashboard_package
-----------------
String or Array of the dashboard package(s) name.
- *Default*: 'puppet-dashboard'
dashboard_user
--------------
The user for dashboard installation.
- *Default*: use defaults based on osfamily
dashboard_group
--------------
The group for dashboard installation.
- *Default*: use defaults based on osfamily
sysconfig_path
-------------------
The location of puppet dashboard sysconfig file.
- *Default*: use defaults based on osfamily
external_node_script_path
-------------------------
The script to call from puppet to get manifests from dashboard.
- *Default*: /usr/share/puppet-dashboard/bin/external_node
dashboard_fqdn
--------------
The dashboard server FQDN.
- *Default*: puppet.${::domain}
port
----
The port the web server will respond to.
- *Default*: 3000
manage_mysql_options
--------------------
Boolean to use modules default mysql::server settings (mysql_max_packet_size).
For specific mysql::server settings you can use hiera now:
<pre>
puppet::dashboard::server::manage_mysql_options: false
mysql::server::override_options:
mysqld:
max_allowed_packet: '32M'
innodb_buffer_pool_size: '64M'
</pre>
- *Default*: true
===
## Class `puppet::dashboard::server` ##
### Usage ###
You can optionally specify a hash of htpasswd entries in Hiera.
<pre>
---
puppet::dashboard::htpasswd:
admin:
cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
puppet:
cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
</pre>
### Parameters ###
dashboard_workers
-----------------
Number of dashboard workers to start. Only used on osfamily Debian.
- *Default*: $::processorcount
database_config_path
--------------------
The path to the database config file.
- *Default*: /usr/share/puppet-dashboard/config/database.yml
database_config_owner
---------------------
The owner of the database config file.
- *Default*: puppet-dashboard
database_config_group
---------------------
The database config file group.
- *Default*: puppet-dashboard
database_config_mode
--------------------
The database config file mode.
- *Default*: 0640
htpasswd
--------
Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
- *Default*: undef
htpasswd_path
-------------
String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
- *Default*: `/etc/puppet/dashboard.htpasswd`
htpasswd_owner
--------------
Owner of htpasswd file.
- *Default*: root
htpasswd_group
--------------
Group of htpasswd file.
- *Default*: use defaults based on osfamily
htpasswd_mode
-------------
Mode of htpasswd file.
- *Default*: 0640
log_dir
-------
The location for the puppet log files.
- *Default*: /var/log/puppet
mysql_user
----------
The user for the mysql connection.
- *Default*: dashboard
mysql_password
--------------
The password for the mysql connection.
- *Default*: puppet
mysql_max_packet_size
---------------------
The mysql max packet size.
- *Default*: 32M
security
--------
String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
- *Default*: 'none'
vhost_path
----------
The location of puppet dashboard vhost file for apache.
- *Default*: use defaults based on osfamily
===
## Class `puppet::dashboard::maintenance` ##
### Parameters ###
db_optimization_command
-----------------------
The command to run to optimize the db.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
db_optimization_user
--------------------
The user to run db optimization.
- *Default*: root
db_optimization_hour
--------------------
The hour on which to run db optimization.
- *Default*: 0
db_optimization_minute
----------------------
The minute at which to run db optimization.
- *Default*: 0
db_optimization_monthday
------------------------
The day of the month on which to run db optimization.
- *Default*: 1
reports_days_to_keep
--------------------
How many days to keep the reports.
- *Default*: 30
purge_old_reports_command
-------------------------
Which command to run to purge old reports.
+Defaults to: '/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=${reports_days_to_keep} unit=day >> /var/log/puppet/dashboard_maintenance.log'
+If using a specific command here, please keep in mind you need to align it with $reports_days_to_keep yourself.
+
+- *Default*: 'USE_DEFAULTS'
-- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=30 unit=day >> /var/log/puppet/dashboard_maintenance.log
purge_old_reports_user
----------------------
User to purge reports as.
- *Default*: root
purge_old_reports_hour
----------------------
On which hour to purge old reports.
- *Default*: 0
purge_old_reports_minute
------------------------
At which minute to purge old reports.
- *Default*: 30
remove_old_reports_spool
------------------------
Whether we should remove old dashboard reports that have not been imported
- *Default*: 'True'
reports_spool_dir
-----------------
Path to reports in dashboard spool
- *Default*: '/usr/share/puppet-dashboard/spool'
reports_spool_days_to_keep
--------------------------
How many days to keep the unimported reports.
remove_reports_spool_user
-------------------------
User to remove unimported reports.
- *Default*: root
remove_reports_spool_hour
-------------------------
On which hour to remove unimported reports.
- *Default*: 0
remove_reports_spool_minute
---------------------------
At which minute to remove unimported reports
- *Default*: 45
dump_dir
--------
The directory to use for dumps.
- *Default*: /var/local
dump_database_command
---------------------
The command to run to dump the database.
+Defaults to: 'cd ~puppet-dashboard && sudo -u ${puppet::dashboard::dashboard_user_real} /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=${dump_dir}/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 ${dump_dir}/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1'
+If using a specific command here, please keep in mind you need to align it with $puppet::dashboard::dashboard_user & $dump_dir yourself.
-- *Default*: sudo -u puppet-dashboard /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log
+- *Default*: 'USE_DEFAULTS'
dump_database_user
------------------
User to dump database as.
- *Default*: root
dump_database_hour
------------------
On which hour to dump database.
- *Default*: 1
dump_database_minute
--------------------
At which minute to purge old reports.
- *Default*: 0
days_to_keep_backups
--------------------
Number of days to keep database backups.
- *Default*: 7
purge_old_db_backups_user
-------------------------
User to purge old database dumps as.
- *Default*: root
purge_old_db_backups_hour
-------------------------
On which hour to purge old database dumps.
- *Default*: 2
purge_old_db_backups_minute
---------------------------
At which minute to purge old database dumps.
- *Default*: 0
===
## Class `puppet::lint` ##
### Parameters ###
ensure
------
Whether to install lint.
- *Default*: present
provider
--------
Which provider should supply lint.
- *Default*: gem
version
-------
If you do not want to use the default version of lint, specify which version you want to use here.
- *Default*: undef
lint_args
---------
Which args should be added to the .puppet-lint.rc file
- *Default*: --no-80chars-check
lintrc_path
-----------
The full path to the lint config file.
- *Default*: ${::root_home}/.puppet-lint.rc
lintrc_owner
------------
The owner of the lint config file.
- *Default*: root
lintrc_group
------------
The group of the lint config file.
- *Default*: root
lintrc_mode
-----------
The mode of the lint config file.
- *Default*: 0644
===
## Class `puppet::master` ##
### Usage ###
In Hiera you will need to specify the following.
<pre>
puppet::agent::is_puppet_master: 'true'
</pre>
### Parameters ###
sysconfig_path
--------------
The location of puppet master sysconfig file.
- *Default*: use defaults based on osfamily
vhost_path
----------
The location of puppet master vhost file for apache.
- *Default*: use defaults based on osfamily
rack_dir
--------
The rack directory path.
- *Default*: /usr/share/puppet/rack/puppetmasterd
puppet_user
-----------
The user the puppet master should run as.
- *Default*: puppet
manage_firewall
---------------
Whether to manage the firewall settings on the client
- *Default*: undef
===
## Class `puppet::master::maintenance` ##
If you have a cluster of puppet masters mounting the same data, you should
disable these cronjobs on all systems except for one to ensure they are not all
cleaning up the same data.
```
puppet::master::maintenance::clientbucket_cleanup_ensure: 'absent'
puppet::master::maintenance::reportdir_purge_ensure: 'absent'
```
### Parameters ###
clientbucket_cleanup_ensure
---------------------------
String for ensure parameter for filebucket_cleanup cron job.
- *Default*: 'present'
clientbucket_path
-----------------
Path to where the clientbucket files are stored.
- *Default*: /var/lib/puppet/clientbucket
clientbucket_days_to_keep
-------------------------
The number of days to keep clientbuckets
- *Default*: 30
filebucket_cleanup_command
--------------------------
Command used to cleanup the clientbuckets.
- *Default*: /usr/bin/find ${clientbucket_path} -type f -mtime +30 -exec /bin/rm -fr {} \;
filebucket_cleanup_user
-----------------------
User to run the clientbucket cleanup as.
- *Default*: root
filebucket_cleanup_hour
-----------------------
Hour on which to run the filebucket cleanup.
- *Default*: 0
filebucket_cleanup_minute
-------------------------
Minute at which to run the filebucket cleanup.
- *Default*: 0
reportdir_purge_ensure
----------------------
String for ensure parameter for purge_old_puppet_reports cron job.
- *Default*: 'present'
reportdir
---------
Directory that holds the reports. `$::puppet_reportdir` is a custom fact that reads the `reportdir` setting from Puppet's configuration. This is likely `/var/lib/puppet/reports/`.
- *Default*: $::puppet_reportdir
reportdir_days_to_key
---------------------
String for number of days of reports to keep. Must be a positive integer > 0.
- *Default*: '30'
reportdir_purge_command
-----------------------
Command ran by cron to purge old reports.
- *Default*: /usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;'
reportdir_purge_user
--------------------
User for the crontab entry to run the reportdir_purge_command.
- *Default*: root
reportdir_purge_hour
--------------------
Hour at which to run the reportdir_purge_command.
- *Default*: 0
reportdir_purge_minute
----------------------
Minute past the hour in which to run the reportdir_purge_command.
- *Default*: 15
diff --git a/manifests/dashboard/maintenance.pp b/manifests/dashboard/maintenance.pp
old mode 100755
new mode 100644
index 702cf02..a0c832f
--- a/manifests/dashboard/maintenance.pp
+++ b/manifests/dashboard/maintenance.pp
@@ -1,109 +1,109 @@
# == Class: puppet::dashboard::maintenance
#
class puppet::dashboard::maintenance (
$db_optimization_command = '/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log',
$db_optimization_user = 'root',
$db_optimization_hour = '0',
$db_optimization_minute = '0',
$db_optimization_monthday = '1',
$reports_days_to_keep = '30',
- $purge_old_reports_command = '/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=30 unit=day >> /var/log/puppet/dashboard_maintenance.log',
+ $purge_old_reports_command = 'USE_DEFAULTS',
$purge_old_reports_user = 'root',
$purge_old_reports_hour = '0',
$purge_old_reports_minute = '30',
$remove_old_reports_spool = true,
$reports_spool_dir = '/usr/share/puppet-dashboard/spool',
$reports_spool_days_to_keep = '7',
$remove_reports_spool_user = 'root',
$remove_reports_spool_hour = '0',
$remove_reports_spool_minute = '45',
$dump_dir = '/var/local',
- $dump_database_command = 'cd ~puppet-dashboard && sudo -u puppet-dashboard /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1',
+ $dump_database_command = 'USE_DEFAULTS',
$dump_database_user = 'root',
$dump_database_hour = '1',
$dump_database_minute = '0',
$days_to_keep_backups = '7',
$purge_old_db_backups_user = 'root',
$purge_old_db_backups_hour = '2',
$purge_old_db_backups_minute = '0',
) {
include common
require 'puppet::dashboard'
validate_absolute_path($reports_spool_dir)
validate_absolute_path($dump_dir)
+ validate_string($dump_database_command)
+ validate_integer($reports_days_to_keep)
- if $reports_days_to_keep == '30' {
- $my_purge_old_reports_command = $purge_old_reports_command
- } else {
- $my_purge_old_reports_command = "/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=${reports_days_to_keep} unit=day >> /var/log/puppet/dashboard_maintenance.log"
+ $purge_old_reports_command_real = $purge_old_reports_command ? {
+ 'USE_DEFAULTS' => "/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=${reports_days_to_keep} unit=day >> /var/log/puppet/dashboard_maintenance.log",
+ default => $purge_old_reports_command
}
- if $dump_dir == '/var/local' and $::osfamily == 'RedHat' {
- $my_dump_database_command = $dump_database_command
- } else {
- $my_dump_database_command = "cd ~puppet-dashboard && sudo -u ${puppet::dashboard::dashboard_user_real} /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=${dump_dir}/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 ${dump_dir}/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1"
+ $dump_database_command_real = $dump_database_command ? {
+ 'USE_DEFAULTS' => "cd ~puppet-dashboard && sudo -u ${puppet::dashboard::dashboard_user_real} /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=${dump_dir}/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 ${dump_dir}/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1",
+ default => $dump_database_command
}
common::mkdir_p { $dump_dir: }
file { $dump_dir:
ensure => directory,
group => $puppet::dashboard::dashboard_group_real,
mode => '0775',
require => Common::Mkdir_p[$dump_dir],
}
cron { 'monthly_dashboard_database_optimization':
ensure => present,
command => $db_optimization_command,
user => $db_optimization_user,
hour => $db_optimization_hour,
minute => $db_optimization_minute,
monthday => $db_optimization_monthday,
}
cron { 'purge_old_reports':
ensure => present,
- command => $my_purge_old_reports_command,
+ command => $purge_old_reports_command_real,
user => $purge_old_reports_user,
hour => $purge_old_reports_hour,
minute => $purge_old_reports_minute,
}
if type($remove_old_reports_spool) == 'string' {
$enable_remove_old_reports_spool = str2bool($remove_old_reports_spool)
} else {
$enable_remove_old_reports_spool = $remove_old_reports_spool
}
validate_bool($enable_remove_old_reports_spool)
if $enable_remove_old_reports_spool == true {
$remove_old_reports_spool_enable = 'present'
} else {
$remove_old_reports_spool_enable = 'absent'
}
cron { 'remove_old_reports_spool':
ensure => $remove_old_reports_spool_enable,
command => "/bin/find ${reports_spool_dir} -type f -name \"*.yaml\" -mtime +${$reports_spool_days_to_keep } -exec /bin/rm -f {} \\;",
user => $remove_reports_spool_user,
hour => $remove_reports_spool_hour,
minute => $remove_reports_spool_minute,
}
cron { 'dump_dashboard_database':
- command => $my_dump_database_command,
+ command => $dump_database_command_real,
user => $dump_database_user,
hour => $dump_database_hour,
minute => $dump_database_minute,
}
cron { 'purge_old_db_backups':
command => "/bin/find ${dump_dir} -type f -mtime +${days_to_keep_backups} -exec /bin/rm -f {} \\;",
user => $purge_old_db_backups_user,
hour => $purge_old_db_backups_hour,
minute => $purge_old_db_backups_minute,
}
}
diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb
index 6b10983..d738261 100644
--- a/spec/classes/agent_spec.rb
+++ b/spec/classes/agent_spec.rb
@@ -81,663 +81,663 @@ describe 'puppet::agent' do
it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['true',true].each do |value|
context "with is_puppet_master set to #{value}" do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) do
{ :env => 'production',
:is_puppet_master => value,
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'content' => nil,
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should_not contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should_not contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should_not contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
end
describe 'with run_interval' do
['29','30',30,'45',56].each do |value|
context "set to #{value}" do
let(:facts) do
{
:osfamily => 'RedHat',
:fqdn => 'agent.learnpuppet.com',
}
end
let(:params) do
{
:run_method => 'cron',
:run_interval => value,
:env => 'production',
}
end
# Values here are from trial and error based on the fqdn above. Not
# sure if it is possible to stub fqdn_rand()
if value.to_s > '30'
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'minute' => 39,
})
}
else
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'minute' => ['7', 37],
})
}
end
end
end
[true,false,{ 'k' => 'v'},['1','2']].each do |value|
context "set to invalid value #{value}" do
let(:facts) do
{
:osfamily => 'RedHat',
:fqdn => 'agent.learnpuppet.com',
}
end
let(:params) do
{
:run_method => 'cron',
:run_interval => value,
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/^undefined method `to_i'/)
end
end
end
end
describe 'with stringify_facts' do
['true',true].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['false',false].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = false$/) }
end
end
context 'set to an invalid setting' do
let(:params) do
{
:stringify_facts => 'invalid',
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean given/)
end
end
end
describe 'sysconfig file' do
context 'Puppet agent sysconfig file on osfamily RedHat' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Debian',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on Ubuntu' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Solaris' do
let(:facts) { { :osfamily => 'Solaris' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should_not contain_file('puppet_agent_sysconfig') }
end
context 'Puppet agent sysconfig file on osfamily Suse' do
let(:facts) { { :osfamily => 'Suse' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on invalid osfamily' do
let(:facts) { { :osfamily => 'invalid' } }
let(:params) { { :env => 'production' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <invalid>./)
end
end
end
describe 'with symlink_puppet_binary' do
['true',true].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/usr/local/bin/puppet',
'target' => '/usr/bin/puppet',
'ensure' => 'link',
})
}
end
end
['false',false].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it { should_not contain_file('puppet_symlink') }
end
end
context 'enabled with all params specified' do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => '/bar',
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/bar',
'target' => '/foo/bar',
'ensure' => 'link',
})
}
end
context 'enabled with invalid puppet_binary' do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => 'invalid/path',
:symlink_puppet_binary_target => '/bar' } }
it 'should fail' do
expect {
should contain_class('puppet::master')
}.to raise_error(Puppet::Error,/^"invalid\/path" is not an absolute path./)
end
end
context 'enabled with invalid symlink_puppet_binary_target' do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => 'invalid/path' } }
it 'should fail' do
expect {
should contain_class('puppet::master')
}.to raise_error(Puppet::Error,/^"invalid\/path" is not an absolute path./)
end
end
end
describe 'with run_method' do
context 'set to disable' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'disable',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => false,
})
}
end
context 'set to service' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'service',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => true,
})
}
end
context 'set to cron' do
context 'with run_in_noop set to non-string and non-boolean' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => ['invalid_type','not_a_string','not_a_boolean'],
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/^\["invalid_type", "not_a_string", "not_a_boolean"\] is not a boolean./)
end
end
context 'with run_in_noop set to invalid string' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => 'invalid_string',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean given/)
end
end
cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
# iterate through a matrix of setting true and false as booleans and
# strings for both run_in_noop and run_at_boot.
['true',true,'false',false].each do |rin_value|
context "with run_in_noop => #{rin_value}" do
['true',true,'false',false].each do |rab_value|
context "and run_at_boot => #{rab_value}" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => rin_value,
:run_at_boot => rab_value,
}
end
if rin_value == true or rin_value == 'true' then
command = "#{cron_command} --noop"
else
command = cron_command
end
if rab_value == true or rab_value == 'true' then
at_boot_ensure = 'present'
else
at_boot_ensure = 'absent'
end
it { should contain_class('puppet::agent') }
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'user' => 'root',
'command' => command,
})
}
it { should contain_cron('puppet_agent_once_at_boot').with({
'ensure' => at_boot_ensure,
'user' => 'root',
'command' => command,
'special' => 'reboot',
})
}
end
end
end
end
end
end
describe 'with puppet_masterport' do
context 'set to integer' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => '8888',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with_content(/^\s*masterport = 8888$/) }
end
context 'set to a string that is not an integer (foo)' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => 'foo',
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::puppet_masterport is set to <foo>. It should be an integer./)
end
end
context 'set to an invalid type (non-string)' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => ['invalid','type'],
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/^undefined method `to_i'/)
+ }.to raise_error(Puppet::Error,/^puppet::agent::puppet_masterport is set to <invalidtype>. It should be an integer./)
end
end
end
describe 'with etckeeper_hooks' do
['true',true].each do |value|
context "set to #{value}" do
let(:params) do
{
:etckeeper_hooks => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('etckeeper_pre') }
it { should contain_file('etckeeper_post') }
it { should contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
it { should contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
end
['false',false].each do |value|
context "set to #{value}" do
let(:params) do
{
:etckeeper_hooks => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should_not contain_file('etckeeper_pre') }
it { should_not contain_file('etckeeper_post') }
it { should_not contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
it { should_not contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
end
context 'set to an invalid setting' do
let(:params) do
{
:etckeeper_hooks => 'invalid',
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean given/)
end
end
end
describe 'with http_proxy_host' do
context 'set to a valid domain' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_host => 'proxy.host.local.domain',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it {should contain_file('puppet_config').with_content(/^\s*http_proxy_host = proxy\.host\.local\.domain$/) }
end
['8.8.8.8','2a00:1450:400f:804::1011'].each do |ip_address|
context "set to #{ip_address} (ip-address)" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :env => 'production',
:http_proxy_host => ip_address,
}
end
it { should contain_file('puppet_config').with_content(/\s*http_proxy_host = #{Regexp.escape(ip_address)}$/) }
end
end
['8.8.8.8.#','".#.%.!','foo..bar'].each do |invalid_value|
context "set to #{invalid_value} (invalid value)" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :env => 'production',
:http_proxy_host => invalid_value,
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::http_proxy_host is set to <#{Regexp.escape(invalid_value)}>. It should be a fqdn or an ip-address./)
end
end
end
context 'set to an invalid type' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_host => ['invalid','type'],
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/chomp/)
+ }.to raise_error(Puppet::Error,/^puppet::agent::http_proxy_host is set to <invalidtype>. It should be a fqdn or an ip-address./)
end
end
end
describe 'with http_proxy_port' do
context 'set to integer' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_port => '8888',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with_content(/^\s*http_proxy_port = 8888$/) }
end
context 'set to an invalid type' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_port => ['invalid','type'],
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/^undefined method `to_i'/)
+ }.to raise_error(Puppet::Error,/^puppet::agent::http_proxy_port is set to <invalidtype>. It should be an Integer./)
end
end
context 'set to an invalid value' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_port => 'foo',
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::http_proxy_port is set to <foo>. It should be an Integer./)
end
end
end
end
diff --git a/spec/classes/dashboard_maintenance_spec.rb b/spec/classes/dashboard_maintenance_spec.rb
index 289989f..a8772ed 100644
--- a/spec/classes/dashboard_maintenance_spec.rb
+++ b/spec/classes/dashboard_maintenance_spec.rb
@@ -1,324 +1,377 @@
require 'spec_helper'
describe 'puppet::dashboard::maintenance' do
describe 'class puppet::dashboard::maintenance' do
context 'with database dump dir as default value on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_file('/var/local').with({
'ensure' => 'directory',
'group' => 'puppet-dashboard',
'mode' => '0775',
})
}
end
context 'with database dump dir as default value on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_file('/var/local').with({
'ensure' => 'directory',
'group' => 'puppet',
'mode' => '0775',
})
}
end
context 'with database dump dir specified' do
let(:params) { {:dump_dir => '/foo/bar'} }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_file('/foo/bar').with({
'ensure' => 'directory',
'mode' => '0775',
})
}
end
context 'with database dump dir specified as invalid value' do
let(:params) { {:dump_dir => 'invalid/path/statement'} }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
}
end
it do
expect {
should contain_class('puppet::dashboard::maintenance')
}.to raise_error(Puppet::Error,/^"invalid\/path\/statement" is not an absolute path./)
end
end
context 'Dashboard database optimization' do
let(:params) { {:db_optimization_command => '/foo/bar' } }
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('monthly_dashboard_database_optimization').with({
'command' => '/foo/bar',
'user' => 'root',
'hour' => '0',
'minute' => '0',
'monthday' => '1',
})
}
end
context 'Dashboard database purge reports' do
let(:params) { {:purge_old_reports_command => '/foo/bar' }}
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('purge_old_reports').with({
'command' => '/foo/bar',
'user' => 'root',
'hour' => '0',
'minute' => '30',
})
}
end
context 'Dashboard spool remove reports with remove_old_reports_spool set to invalid string' do
let(:params) { {:remove_old_reports_spool => 'invalid_string' } }
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it do
expect {
should contain_class('puppet::dashboard::maintenance')
}.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean/)
end
end
context 'Dashboard spool remove reports with remove_old_reports_spool set to invalid type - non-boolean and non-string' do
let(:params) { {:remove_old_reports_spool => ['invalid_type','not_a_string','not_a_boolean'] } }
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it do
expect {
should contain_class('puppet::dashboard::maintenance')
}.to raise_error(Puppet::Error,/^\["invalid_type", "not_a_string", "not_a_boolean"\] is not a boolean./)
end
end
[true,'true'].each do |value|
context "Dashboard spool remove reports with remove_old_reports_spool set to #{value}" do
let(:params) { {:remove_old_reports_spool => value } }
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('remove_old_reports_spool').with({
'command' => '/bin/find /usr/share/puppet-dashboard/spool -type f -name "*.yaml" -mtime +7 -exec /bin/rm -f {} \;',
'ensure' => 'present',
'user' => 'root',
'hour' => '0',
'minute' => '45',
})
}
end
end
context 'Dashboard spool remove reports with params set' do
let(:params) { {:remove_old_reports_spool => 'true',
:remove_reports_spool_user => 'user',
:remove_reports_spool_hour => '5',
:remove_reports_spool_minute => '6',
:reports_spool_dir => '/tmp/foo',
:reports_spool_days_to_keep => '10' } }
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('remove_old_reports_spool').with({
'ensure' => 'present',
'command' => '/bin/find /tmp/foo -type f -name "*.yaml" -mtime +10 -exec /bin/rm -f {} \;',
'user' => 'user',
'hour' => '5',
'minute' => '6',
})
}
end
[false,'false'].each do |value|
context "Dashboard spool remove reports with remove_old_reports_spool set to #{value}" do
let(:params) { {:remove_old_reports_spool => value } }
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('remove_old_reports_spool').with({
'ensure' => 'absent',
})
}
end
end
context 'with reports_spool_dir set to an invalid path' do
let(:params) { {:reports_spool_dir=> 'invalid/path/statement' } }
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it do
expect {
should contain_class('puppet::dashboard::maintenance')
}.to raise_error(Puppet::Error,/^"invalid\/path\/statement" is not an absolute path./)
end
end
context 'with dump_database_command set to default value on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('dump_dashboard_database').with({
'command' => 'cd ~puppet-dashboard && sudo -u puppet-dashboard /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1',
'user' => 'root',
'hour' => '1',
'minute' => '0',
})
}
end
context 'with dump_database_command set to default value on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.0.8',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('dump_dashboard_database').with({
'command' => 'cd ~puppet-dashboard && sudo -u puppet /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1',
'user' => 'root',
'hour' => '1',
'minute' => '0',
})
}
end
- context 'with dump_database_command specified' do
- let(:params) { {:dump_database_command => '/foo/bar' } }
+ describe 'with dump_database_command specified' do
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
- it { should contain_class('puppet::dashboard::maintenance') }
+ ['/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=12 unit=hours','/foo/bar'].each do |value|
+ context "to valid #{value} (as #{value.class})" do
+ let (:params) {{'dump_database_command' => value }}
+
+ it { should contain_cron('dump_dashboard_database').with({
+ 'command' => "#{value}",
+ 'user' => 'root',
+ 'hour' => '1',
+ 'minute' => '0',
+ })
+ }
+ end
+ end
+
+ [true,['array'],a = { 'ha' => 'sh' }].each do |value|
+ context "to invalid #{value} (as #{value.class})" do
+ let (:params) {{'dump_database_command' => value }}
+
+ it 'should fail' do
+ expect {
+ should contain_class('puppet::dashboard::maintenance')
+ }.to raise_error(Puppet::Error,/is not a string. It looks to be a/)
+ end
+ end
+ end
+
+ end
+
+ describe 'with reports_days_to_keep specified' do
+ let(:facts) do
+ { :osfamily => 'RedHat',
+ :concat_basedir => '/tmp',
+ :max_allowed_packet => 32,
+ :operatingsystemrelease => '6.4',
+ }
+ end
+
+ [242,'42'].each do |value|
+ context "to valid #{value} (as #{value.class})" do
+ let (:params) {{'reports_days_to_keep' => value }}
+
+ it { should contain_cron('purge_old_reports').with({
+ 'command' => "/usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=#{value} unit=day >> /var/log/puppet/dashboard_maintenance.log",
+ 'user' => 'root',
+ 'hour' => '0',
+ 'minute' => '30',
+ })
+ }
+ end
+ end
+
+ [2.42,true,'string',['array'],a = { 'ha' => 'sh' }].each do |value|
+ context "to invalid #{value} (as #{value.class})" do
+ let (:params) {{'reports_days_to_keep' => value }}
+
+ it 'should fail' do
+ expect {
+ should contain_class('puppet::dashboard::maintenance')
+ }.to raise_error(Puppet::Error,/validate_integer\(\)/)
+ end
+ end
+ end
- it { should contain_cron('dump_dashboard_database').with({
- 'command' => '/foo/bar',
- 'user' => 'root',
- 'hour' => '1',
- 'minute' => '0',
- })
- }
end
context 'Dashboard database backup cleanup' do
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('purge_old_db_backups').with({
'user' => 'root',
'hour' => '2',
'minute' => '0',
})
}
end
end
end
|
ghoneycutt/puppet-module-puppet
|
87003764b174f2d2511b6805570c55883607c31a
|
Release v2.15.0 - Ability to disable maintenance cronjobs on masters
|
diff --git a/Modulefile b/Modulefile
index bd765f7..30c7281 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,17 +1,17 @@
name 'ghoneycutt-puppet'
-version '2.14.4'
+version '2.15.0'
source 'git://github.com/ghoneycutt/puppet-module-puppet.git'
author 'ghoneycutt'
license 'Apache-2.0'
summary 'Manage Puppet'
description 'Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.'
project_page 'https://github.com/ghoneycutt/puppet-module-puppet'
dependency 'ghoneycutt/common', '>= 1.0.3'
dependency 'leinaddm/htpasswd', '>= 0.0.1'
dependency 'puppetlabs/stdlib', '>= 3.2.0'
dependency 'puppetlabs/mysql', '>= 2.0.0'
dependency 'puppetlabs/passenger', '>= 0.0.4'
dependency 'puppetlabs/apache', '>= 0.5.0'
dependency 'puppetlabs/firewall', '>= 0.2.1'
dependency 'puppetlabs/concat', '>= 1.0.0'
diff --git a/metadata.json b/metadata.json
index 25b2805..b580125 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.14.4",
+ "version": "2.15.0",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
432eb107af733ea6292b3075150fdd13a6fced56
|
Release v2.14.4 - Add support for Ruby v2.1.0
|
diff --git a/Modulefile b/Modulefile
index 40470cd..bd765f7 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,17 +1,17 @@
name 'ghoneycutt-puppet'
-version '2.14.3'
+version '2.14.4'
source 'git://github.com/ghoneycutt/puppet-module-puppet.git'
author 'ghoneycutt'
license 'Apache-2.0'
summary 'Manage Puppet'
description 'Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.'
project_page 'https://github.com/ghoneycutt/puppet-module-puppet'
dependency 'ghoneycutt/common', '>= 1.0.3'
dependency 'leinaddm/htpasswd', '>= 0.0.1'
dependency 'puppetlabs/stdlib', '>= 3.2.0'
dependency 'puppetlabs/mysql', '>= 2.0.0'
dependency 'puppetlabs/passenger', '>= 0.0.4'
dependency 'puppetlabs/apache', '>= 0.5.0'
dependency 'puppetlabs/firewall', '>= 0.2.1'
dependency 'puppetlabs/concat', '>= 1.0.0'
diff --git a/metadata.json b/metadata.json
index 6129030..25b2805 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.14.3",
+ "version": "2.14.4",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
cb0c92795aaadc2a93039d1573b3f61c88389e0f
|
Bump year in LICENSE to 2015
|
diff --git a/LICENSE b/LICENSE
index b1b251c..00f0e3f 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,13 +1,13 @@
-Copyright (C) 2010-2013 Garrett Honeycutt <[email protected]>
+Copyright (C) 2010-2015 Garrett Honeycutt <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
ghoneycutt/puppet-module-puppet
|
4908eb4afbc5345820a45244871e5b29882c69aa
|
Support Ruby v2.1.0
|
diff --git a/.travis.yml b/.travis.yml
index 7abce12..0059273 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,30 +1,39 @@
---
language: ruby
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
+ - 2.1.0
env:
matrix:
- PUPPET_GEM_VERSION="~> 3.1.0"
- PUPPET_GEM_VERSION="~> 3.2.0"
- PUPPET_GEM_VERSION="~> 3.3.0"
- PUPPET_GEM_VERSION="~> 3.4.0"
- PUPPET_GEM_VERSION="~> 3.5.1"
- PUPPET_GEM_VERSION="~> 3.6.0"
- PUPPET_GEM_VERSION="~> 3.7.0"
sudo: false
script: 'bundle exec rake validate && bundle exec rake lint && SPEC_OPTS="--format documentation" bundle exec rake spec'
matrix:
fast_finish: true
exclude:
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.1.0"
+ - rvm: 2.1.0
+ env: PUPPET_GEM_VERSION="~> 3.1.0"
+ - rvm: 2.1.0
+ env: PUPPET_GEM_VERSION="~> 3.2.0"
+ - rvm: 2.1.0
+ env: PUPPET_GEM_VERSION="~> 3.3.0"
+ - rvm: 2.1.0
+ env: PUPPET_GEM_VERSION="~> 3.4.0"
notifications:
email: false
diff --git a/README.md b/README.md
index 6823d67..c379df2 100644
--- a/README.md
+++ b/README.md
@@ -1,565 +1,565 @@
# puppet-module-puppet #
===
[](https://travis-ci.org/ghoneycutt/puppet-module-puppet)
This module handles the various parts of puppet on a given machine.
Dependencies for this module are: apache, common, mysql and passenger
## Components ##
### Agent
---------
- Manages the puppet agent on a client
- Setup of configuration files
- Setup of service or crontask to run the agent periodically
- Ensure puppet agent is run at boottime
### Master
----------
- Manages apache with passenger
- Setup of config files needed to run master
- Calls the `puppet::lint` class
- Calls the `puppet::master::maintenance` class
- Manages firewall rule for puppet if needed
- Maintenance to purge filebucket and reports
### Dashboard
-------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This installation is used by puppet systems, that need access to the dashboard
### Dashboard Server
--------------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This is the actual server running the Dashboard
- Configures the Dashboard MySQL settings
- Creates database for puppet with mysql module
- Calls the `puppet::dashboard::maintenance` class
- Maintenance to clean up old reports, optimize database and dump database
- For the maintenance cron jobs, you should have the following line in your `/etc/sudoers` which is not managed with this module.
<pre>
Defaults:root !requiretty
</pre>
### Lint
--------
- Manages [puppet-lint](http://github.com/rodjek/puppet-lint)
## Compatibility ##
-------------------
-Ruby versions 1.8.7, 1.9.3, and 2.0.0 on Puppet 3.x
+Ruby versions 1.8.7, 1.9.3, 2.0.0 and 2.1.0 on Puppet v3.
### Puppet Master
-----------------
* Debian 6
* Debian 7
* EL 6
* Ubuntu 12.04 LTS
### Puppet Agent
----------------
* Debian 6
* Debian 7
* EL 6
* EL 7
* Solaris
* Suse 11
* Ubuntu 12.04 LTS
===
## Class `puppet::agent` ##
### Parameters ###
certname
--------
The certificate name for the client.
- *Default*: $::fqdn
config_path
-----------
The location of the puppet config file.
- *Default*: /etc/puppet/puppet.conf
config_owner
------------
The owner of the config file.
- *Default*: root
config_group
------------
The group for the config file.
- *Default*: root
config_mode
-----------
The mode for the config file.
- *Default*: 0644
env
---
The selected environment for the client.
- *Default*: $::env
puppet_server
-------------
The puppet server the client should connect to.
- *Default*: puppet
puppet_masterport
-----------------
The masterport setting in puppet.conf. By default this line is not set.
- *Default*: UNSET
puppet_ca_server
----------------
The puppet CA server the client should use
- *Default*: UNSET
http_proxy_host
---------------
The http-proxy the client should use
- *Default*: UNSET
http_proxy_port
----------------
The http-proxy port the client should use
- *Default*: UNSET
is_puppet_master
----------------
Whether the machine is a puppet master or not.
- *Default*: false
run_method
----------
Whether to run as a service or in cron mode. Valid values are `disable`, `cron`, and `service`. The value `disable` disables automatic puppet runs and assumes you are running as a service.
- *Default*: service
run_interval
------------
The interval, in minutes, with which the client should run. If greater than 30, the agent will only run once per hour.
- *Default*: 30
run_in_noop
-----------
Whether the client should run in noop mode or not.
- *Default*: false
cron_command
------------
The command that should be added to the crontab (in cron mode)
- *Default*: /usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay
run_at_boot
-----------
Whether the client should run right after boot
- *Default*: true
puppet_binary
-------------
Path to puppet binary to create symlink from
- *Default*: '/usr/bin/puppet'
symlink_puppet_binary_target
----------------------------
Path to where the symlink should be created
- *Default*: '/usr/local/bin/puppet'
symlink_puppet_binary
---------------------
Boolean for ensuring a symlink for puppet_binary to symlink_puppet_binary_target. This is useful if you install puppet in a non-standard location that is not in your $PATH.
- *Default*: false
agent_sysconfig
---------------
The location of puppet agent sysconfig file.
- *Default*: use defaults based on osfamily
agent_sysconfig_ensure
----------------------
String for 'file' or 'present'. Allows you to not manage the sysconfig file.
- *Default*: use defaults based on osfamily
daemon_name
-----------
The name the puppet agent daemon should run as.
- *Default*: puppet
stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
- *Default*: true
etckeeper_hooks
---------------
Boolean to include pre- and postrun hooks for etckeeper in the main section of the puppet agent's config.
- *Default*: false
===
## Class `puppet::dashboard` ##
### Parameters ###
dashboard_package
-----------------
String or Array of the dashboard package(s) name.
- *Default*: 'puppet-dashboard'
dashboard_user
--------------
The user for dashboard installation.
- *Default*: use defaults based on osfamily
dashboard_group
--------------
The group for dashboard installation.
- *Default*: use defaults based on osfamily
sysconfig_path
-------------------
The location of puppet dashboard sysconfig file.
- *Default*: use defaults based on osfamily
external_node_script_path
-------------------------
The script to call from puppet to get manifests from dashboard.
- *Default*: /usr/share/puppet-dashboard/bin/external_node
dashboard_fqdn
--------------
The dashboard server FQDN.
- *Default*: puppet.${::domain}
port
----
The port the web server will respond to.
- *Default*: 3000
manage_mysql_options
--------------------
Boolean to use modules default mysql::server settings (mysql_max_packet_size).
For specific mysql::server settings you can use hiera now:
<pre>
puppet::dashboard::server::manage_mysql_options: false
mysql::server::override_options:
mysqld:
max_allowed_packet: '32M'
innodb_buffer_pool_size: '64M'
</pre>
- *Default*: true
===
## Class `puppet::dashboard::server` ##
### Usage ###
You can optionally specify a hash of htpasswd entries in Hiera.
<pre>
---
puppet::dashboard::htpasswd:
admin:
cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
puppet:
cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
</pre>
### Parameters ###
dashboard_workers
-----------------
Number of dashboard workers to start. Only used on osfamily Debian.
- *Default*: $::processorcount
database_config_path
--------------------
The path to the database config file.
- *Default*: /usr/share/puppet-dashboard/config/database.yml
database_config_owner
---------------------
The owner of the database config file.
- *Default*: puppet-dashboard
database_config_group
---------------------
The database config file group.
- *Default*: puppet-dashboard
database_config_mode
--------------------
The database config file mode.
- *Default*: 0640
htpasswd
--------
Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
- *Default*: undef
htpasswd_path
-------------
String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
- *Default*: `/etc/puppet/dashboard.htpasswd`
htpasswd_owner
--------------
Owner of htpasswd file.
- *Default*: root
htpasswd_group
--------------
Group of htpasswd file.
- *Default*: use defaults based on osfamily
htpasswd_mode
-------------
Mode of htpasswd file.
- *Default*: 0640
log_dir
-------
The location for the puppet log files.
- *Default*: /var/log/puppet
mysql_user
----------
The user for the mysql connection.
- *Default*: dashboard
mysql_password
--------------
The password for the mysql connection.
- *Default*: puppet
mysql_max_packet_size
---------------------
The mysql max packet size.
- *Default*: 32M
security
--------
String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
- *Default*: 'none'
vhost_path
----------
The location of puppet dashboard vhost file for apache.
- *Default*: use defaults based on osfamily
===
## Class `puppet::dashboard::maintenance` ##
### Parameters ###
db_optimization_command
-----------------------
The command to run to optimize the db.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
db_optimization_user
--------------------
The user to run db optimization.
- *Default*: root
db_optimization_hour
--------------------
The hour on which to run db optimization.
- *Default*: 0
db_optimization_minute
----------------------
The minute at which to run db optimization.
- *Default*: 0
db_optimization_monthday
------------------------
The day of the month on which to run db optimization.
- *Default*: 1
reports_days_to_keep
--------------------
How many days to keep the reports.
- *Default*: 30
purge_old_reports_command
-------------------------
Which command to run to purge old reports.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=30 unit=day >> /var/log/puppet/dashboard_maintenance.log
purge_old_reports_user
----------------------
User to purge reports as.
- *Default*: root
purge_old_reports_hour
----------------------
On which hour to purge old reports.
- *Default*: 0
purge_old_reports_minute
------------------------
At which minute to purge old reports.
- *Default*: 30
remove_old_reports_spool
------------------------
Whether we should remove old dashboard reports that have not been imported
- *Default*: 'True'
reports_spool_dir
-----------------
Path to reports in dashboard spool
- *Default*: '/usr/share/puppet-dashboard/spool'
reports_spool_days_to_keep
--------------------------
How many days to keep the unimported reports.
remove_reports_spool_user
-------------------------
User to remove unimported reports.
- *Default*: root
remove_reports_spool_hour
-------------------------
On which hour to remove unimported reports.
- *Default*: 0
remove_reports_spool_minute
---------------------------
At which minute to remove unimported reports
- *Default*: 45
dump_dir
--------
The directory to use for dumps.
- *Default*: /var/local
dump_database_command
---------------------
The command to run to dump the database.
- *Default*: sudo -u puppet-dashboard /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log
dump_database_user
------------------
User to dump database as.
- *Default*: root
dump_database_hour
------------------
On which hour to dump database.
- *Default*: 1
dump_database_minute
--------------------
At which minute to purge old reports.
- *Default*: 0
days_to_keep_backups
--------------------
Number of days to keep database backups.
- *Default*: 7
purge_old_db_backups_user
-------------------------
User to purge old database dumps as.
- *Default*: root
purge_old_db_backups_hour
-------------------------
On which hour to purge old database dumps.
- *Default*: 2
purge_old_db_backups_minute
---------------------------
At which minute to purge old database dumps.
- *Default*: 0
===
## Class `puppet::lint` ##
### Parameters ###
ensure
------
|
ghoneycutt/puppet-module-puppet
|
97ff900433703867c0a359c7673bc466a9639ea4
|
Cleanup README for disabling puppet master maintenance cronjobs
|
diff --git a/README.md b/README.md
index 177f0bf..23ff599 100644
--- a/README.md
+++ b/README.md
@@ -148,593 +148,606 @@ Whether the machine is a puppet master or not.
- *Default*: false
run_method
----------
Whether to run as a service or in cron mode. Valid values are `disable`, `cron`, and `service`. The value `disable` disables automatic puppet runs and assumes you are running as a service.
- *Default*: service
run_interval
------------
The interval, in minutes, with which the client should run. If greater than 30, the agent will only run once per hour.
- *Default*: 30
run_in_noop
-----------
Whether the client should run in noop mode or not.
- *Default*: false
cron_command
------------
The command that should be added to the crontab (in cron mode)
- *Default*: /usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay
run_at_boot
-----------
Whether the client should run right after boot
- *Default*: true
puppet_binary
-------------
Path to puppet binary to create symlink from
- *Default*: '/usr/bin/puppet'
symlink_puppet_binary_target
----------------------------
Path to where the symlink should be created
- *Default*: '/usr/local/bin/puppet'
symlink_puppet_binary
---------------------
Boolean for ensuring a symlink for puppet_binary to symlink_puppet_binary_target. This is useful if you install puppet in a non-standard location that is not in your $PATH.
- *Default*: false
agent_sysconfig
---------------
The location of puppet agent sysconfig file.
- *Default*: use defaults based on osfamily
agent_sysconfig_ensure
----------------------
String for 'file' or 'present'. Allows you to not manage the sysconfig file.
- *Default*: use defaults based on osfamily
daemon_name
-----------
The name the puppet agent daemon should run as.
- *Default*: puppet
stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
- *Default*: true
etckeeper_hooks
---------------
Boolean to include pre- and postrun hooks for etckeeper in the main section of the puppet agent's config.
- *Default*: false
===
## Class `puppet::dashboard` ##
### Parameters ###
dashboard_package
-----------------
String or Array of the dashboard package(s) name.
- *Default*: 'puppet-dashboard'
dashboard_user
--------------
The user for dashboard installation.
- *Default*: use defaults based on osfamily
dashboard_group
--------------
The group for dashboard installation.
- *Default*: use defaults based on osfamily
sysconfig_path
-------------------
The location of puppet dashboard sysconfig file.
- *Default*: use defaults based on osfamily
external_node_script_path
-------------------------
The script to call from puppet to get manifests from dashboard.
- *Default*: /usr/share/puppet-dashboard/bin/external_node
dashboard_fqdn
--------------
The dashboard server FQDN.
- *Default*: puppet.${::domain}
port
----
The port the web server will respond to.
- *Default*: 3000
manage_mysql_options
--------------------
Boolean to use modules default mysql::server settings (mysql_max_packet_size).
For specific mysql::server settings you can use hiera now:
<pre>
puppet::dashboard::server::manage_mysql_options: false
mysql::server::override_options:
mysqld:
max_allowed_packet: '32M'
innodb_buffer_pool_size: '64M'
</pre>
- *Default*: true
===
## Class `puppet::dashboard::server` ##
### Usage ###
You can optionally specify a hash of htpasswd entries in Hiera.
<pre>
---
puppet::dashboard::htpasswd:
admin:
cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
puppet:
cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
</pre>
### Parameters ###
dashboard_workers
-----------------
Number of dashboard workers to start. Only used on osfamily Debian.
- *Default*: $::processorcount
database_config_path
--------------------
The path to the database config file.
- *Default*: /usr/share/puppet-dashboard/config/database.yml
database_config_owner
---------------------
The owner of the database config file.
- *Default*: puppet-dashboard
database_config_group
---------------------
The database config file group.
- *Default*: puppet-dashboard
database_config_mode
--------------------
The database config file mode.
- *Default*: 0640
htpasswd
--------
Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
- *Default*: undef
htpasswd_path
-------------
String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
- *Default*: `/etc/puppet/dashboard.htpasswd`
htpasswd_owner
--------------
Owner of htpasswd file.
- *Default*: root
htpasswd_group
--------------
Group of htpasswd file.
- *Default*: use defaults based on osfamily
htpasswd_mode
-------------
Mode of htpasswd file.
- *Default*: 0640
log_dir
-------
The location for the puppet log files.
- *Default*: /var/log/puppet
mysql_user
----------
The user for the mysql connection.
- *Default*: dashboard
mysql_password
--------------
The password for the mysql connection.
- *Default*: puppet
mysql_max_packet_size
---------------------
The mysql max packet size.
- *Default*: 32M
security
--------
String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
- *Default*: 'none'
vhost_path
----------
The location of puppet dashboard vhost file for apache.
- *Default*: use defaults based on osfamily
===
## Class `puppet::dashboard::maintenance` ##
### Parameters ###
db_optimization_command
-----------------------
The command to run to optimize the db.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
db_optimization_user
--------------------
The user to run db optimization.
- *Default*: root
db_optimization_hour
--------------------
The hour on which to run db optimization.
- *Default*: 0
db_optimization_minute
----------------------
The minute at which to run db optimization.
- *Default*: 0
db_optimization_monthday
------------------------
The day of the month on which to run db optimization.
- *Default*: 1
reports_days_to_keep
--------------------
How many days to keep the reports.
- *Default*: 30
purge_old_reports_command
-------------------------
Which command to run to purge old reports.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=30 unit=day >> /var/log/puppet/dashboard_maintenance.log
purge_old_reports_user
----------------------
User to purge reports as.
- *Default*: root
purge_old_reports_hour
----------------------
On which hour to purge old reports.
- *Default*: 0
purge_old_reports_minute
------------------------
At which minute to purge old reports.
- *Default*: 30
remove_old_reports_spool
------------------------
Whether we should remove old dashboard reports that have not been imported
- *Default*: 'True'
reports_spool_dir
-----------------
Path to reports in dashboard spool
- *Default*: '/usr/share/puppet-dashboard/spool'
reports_spool_days_to_keep
--------------------------
How many days to keep the unimported reports.
remove_reports_spool_user
-------------------------
User to remove unimported reports.
- *Default*: root
remove_reports_spool_hour
-------------------------
On which hour to remove unimported reports.
- *Default*: 0
remove_reports_spool_minute
---------------------------
At which minute to remove unimported reports
- *Default*: 45
dump_dir
--------
The directory to use for dumps.
- *Default*: /var/local
dump_database_command
---------------------
The command to run to dump the database.
- *Default*: sudo -u puppet-dashboard /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log
dump_database_user
------------------
User to dump database as.
- *Default*: root
dump_database_hour
------------------
On which hour to dump database.
- *Default*: 1
dump_database_minute
--------------------
At which minute to purge old reports.
- *Default*: 0
days_to_keep_backups
--------------------
Number of days to keep database backups.
- *Default*: 7
purge_old_db_backups_user
-------------------------
User to purge old database dumps as.
- *Default*: root
purge_old_db_backups_hour
-------------------------
On which hour to purge old database dumps.
- *Default*: 2
purge_old_db_backups_minute
---------------------------
At which minute to purge old database dumps.
- *Default*: 0
===
## Class `puppet::lint` ##
### Parameters ###
ensure
------
Whether to install lint.
- *Default*: present
provider
--------
Which provider should supply lint.
- *Default*: gem
version
-------
If you do not want to use the default version of lint, specify which version you want to use here.
- *Default*: undef
lint_args
---------
Which args should be added to the .puppet-lint.rc file
- *Default*: --no-80chars-check
lintrc_path
-----------
The full path to the lint config file.
- *Default*: ${::root_home}/.puppet-lint.rc
lintrc_owner
------------
The owner of the lint config file.
- *Default*: root
lintrc_group
------------
The group of the lint config file.
- *Default*: root
lintrc_mode
-----------
The mode of the lint config file.
- *Default*: 0644
===
## Class `puppet::master` ##
### Usage ###
In Hiera you will need to specify the following.
<pre>
puppet::agent::is_puppet_master: 'true'
</pre>
### Parameters ###
sysconfig_path
--------------
The location of puppet master sysconfig file.
- *Default*: use defaults based on osfamily
vhost_path
----------
The location of puppet master vhost file for apache.
- *Default*: use defaults based on osfamily
rack_dir
--------
The rack directory path.
- *Default*: /usr/share/puppet/rack/puppetmasterd
puppet_user
-----------
The user the puppet master should run as.
- *Default*: puppet
manage_firewall
---------------
Whether to manage the firewall settings on the client
- *Default*: undef
===
## Class `puppet::master::maintenance` ##
+If you have a cluster of puppet masters mounting the same data, you should
+disable these cronjobs on all systems except for one to ensure they are not all
+cleaning up the same data.
+
+```
+puppet::master::maintenance::clientbucket_cleanup_ensure: 'absent'
+puppet::master::maintenance::reportdir_purge_ensure: 'absent'
+```
+
### Parameters ###
clientbucket_cleanup_ensure
---------------------------
-String for ensure parameter for filebucket_cleanup cron job
+String for ensure parameter for filebucket_cleanup cron job.
+
+- *Default*: 'present'
clientbucket_path
-----------------
Path to where the clientbucket files are stored.
- *Default*: /var/lib/puppet/clientbucket
clientbucket_days_to_keep
-------------------------
The number of days to keep clientbuckets
- *Default*: 30
filebucket_cleanup_command
--------------------------
Command used to cleanup the clientbuckets.
- *Default*: /usr/bin/find ${clientbucket_path} -type f -mtime +30 -exec /bin/rm -fr {} \;
filebucket_cleanup_user
-----------------------
User to run the clientbucket cleanup as.
- *Default*: root
filebucket_cleanup_hour
-----------------------
Hour on which to run the filebucket cleanup.
- *Default*: 0
filebucket_cleanup_minute
-------------------------
Minute at which to run the filebucket cleanup.
- *Default*: 0
reportdir_purge_ensure
----------------------------
-String for ensure parameter for purge_old_puppet_reports cron job
+----------------------
+String for ensure parameter for purge_old_puppet_reports cron job.
+
+- *Default*: 'present'
reportdir
---------
Directory that holds the reports. `$::puppet_reportdir` is a custom fact that reads the `reportdir` setting from Puppet's configuration. This is likely `/var/lib/puppet/reports/`.
- *Default*: $::puppet_reportdir
reportdir_days_to_key
---------------------
String for number of days of reports to keep. Must be a positive integer > 0.
- *Default*: '30'
reportdir_purge_command
-----------------------
Command ran by cron to purge old reports.
- *Default*: /usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;'
reportdir_purge_user
--------------------
User for the crontab entry to run the reportdir_purge_command.
- *Default*: root
reportdir_purge_hour
--------------------
Hour at which to run the reportdir_purge_command.
- *Default*: 0
reportdir_purge_minute
----------------------
Minute past the hour in which to run the reportdir_purge_command.
- *Default*: 15
|
ghoneycutt/puppet-module-puppet
|
49ec4ee2e81d0b85ed519d702f07637473b73345
|
Support disabling cron jobs
|
diff --git a/README.md b/README.md
index 6823d67..177f0bf 100644
--- a/README.md
+++ b/README.md
@@ -150,583 +150,591 @@ Whether the machine is a puppet master or not.
run_method
----------
Whether to run as a service or in cron mode. Valid values are `disable`, `cron`, and `service`. The value `disable` disables automatic puppet runs and assumes you are running as a service.
- *Default*: service
run_interval
------------
The interval, in minutes, with which the client should run. If greater than 30, the agent will only run once per hour.
- *Default*: 30
run_in_noop
-----------
Whether the client should run in noop mode or not.
- *Default*: false
cron_command
------------
The command that should be added to the crontab (in cron mode)
- *Default*: /usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay
run_at_boot
-----------
Whether the client should run right after boot
- *Default*: true
puppet_binary
-------------
Path to puppet binary to create symlink from
- *Default*: '/usr/bin/puppet'
symlink_puppet_binary_target
----------------------------
Path to where the symlink should be created
- *Default*: '/usr/local/bin/puppet'
symlink_puppet_binary
---------------------
Boolean for ensuring a symlink for puppet_binary to symlink_puppet_binary_target. This is useful if you install puppet in a non-standard location that is not in your $PATH.
- *Default*: false
agent_sysconfig
---------------
The location of puppet agent sysconfig file.
- *Default*: use defaults based on osfamily
agent_sysconfig_ensure
----------------------
String for 'file' or 'present'. Allows you to not manage the sysconfig file.
- *Default*: use defaults based on osfamily
daemon_name
-----------
The name the puppet agent daemon should run as.
- *Default*: puppet
stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
- *Default*: true
etckeeper_hooks
---------------
Boolean to include pre- and postrun hooks for etckeeper in the main section of the puppet agent's config.
- *Default*: false
===
## Class `puppet::dashboard` ##
### Parameters ###
dashboard_package
-----------------
String or Array of the dashboard package(s) name.
- *Default*: 'puppet-dashboard'
dashboard_user
--------------
The user for dashboard installation.
- *Default*: use defaults based on osfamily
dashboard_group
--------------
The group for dashboard installation.
- *Default*: use defaults based on osfamily
sysconfig_path
-------------------
The location of puppet dashboard sysconfig file.
- *Default*: use defaults based on osfamily
external_node_script_path
-------------------------
The script to call from puppet to get manifests from dashboard.
- *Default*: /usr/share/puppet-dashboard/bin/external_node
dashboard_fqdn
--------------
The dashboard server FQDN.
- *Default*: puppet.${::domain}
port
----
The port the web server will respond to.
- *Default*: 3000
manage_mysql_options
--------------------
Boolean to use modules default mysql::server settings (mysql_max_packet_size).
For specific mysql::server settings you can use hiera now:
<pre>
puppet::dashboard::server::manage_mysql_options: false
mysql::server::override_options:
mysqld:
max_allowed_packet: '32M'
innodb_buffer_pool_size: '64M'
</pre>
- *Default*: true
===
## Class `puppet::dashboard::server` ##
### Usage ###
You can optionally specify a hash of htpasswd entries in Hiera.
<pre>
---
puppet::dashboard::htpasswd:
admin:
cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
puppet:
cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
</pre>
### Parameters ###
dashboard_workers
-----------------
Number of dashboard workers to start. Only used on osfamily Debian.
- *Default*: $::processorcount
database_config_path
--------------------
The path to the database config file.
- *Default*: /usr/share/puppet-dashboard/config/database.yml
database_config_owner
---------------------
The owner of the database config file.
- *Default*: puppet-dashboard
database_config_group
---------------------
The database config file group.
- *Default*: puppet-dashboard
database_config_mode
--------------------
The database config file mode.
- *Default*: 0640
htpasswd
--------
Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
- *Default*: undef
htpasswd_path
-------------
String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
- *Default*: `/etc/puppet/dashboard.htpasswd`
htpasswd_owner
--------------
Owner of htpasswd file.
- *Default*: root
htpasswd_group
--------------
Group of htpasswd file.
- *Default*: use defaults based on osfamily
htpasswd_mode
-------------
Mode of htpasswd file.
- *Default*: 0640
log_dir
-------
The location for the puppet log files.
- *Default*: /var/log/puppet
mysql_user
----------
The user for the mysql connection.
- *Default*: dashboard
mysql_password
--------------
The password for the mysql connection.
- *Default*: puppet
mysql_max_packet_size
---------------------
The mysql max packet size.
- *Default*: 32M
security
--------
String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
- *Default*: 'none'
vhost_path
----------
The location of puppet dashboard vhost file for apache.
- *Default*: use defaults based on osfamily
===
## Class `puppet::dashboard::maintenance` ##
### Parameters ###
db_optimization_command
-----------------------
The command to run to optimize the db.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
db_optimization_user
--------------------
The user to run db optimization.
- *Default*: root
db_optimization_hour
--------------------
The hour on which to run db optimization.
- *Default*: 0
db_optimization_minute
----------------------
The minute at which to run db optimization.
- *Default*: 0
db_optimization_monthday
------------------------
The day of the month on which to run db optimization.
- *Default*: 1
reports_days_to_keep
--------------------
How many days to keep the reports.
- *Default*: 30
purge_old_reports_command
-------------------------
Which command to run to purge old reports.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=30 unit=day >> /var/log/puppet/dashboard_maintenance.log
purge_old_reports_user
----------------------
User to purge reports as.
- *Default*: root
purge_old_reports_hour
----------------------
On which hour to purge old reports.
- *Default*: 0
purge_old_reports_minute
------------------------
At which minute to purge old reports.
- *Default*: 30
remove_old_reports_spool
------------------------
Whether we should remove old dashboard reports that have not been imported
- *Default*: 'True'
reports_spool_dir
-----------------
Path to reports in dashboard spool
- *Default*: '/usr/share/puppet-dashboard/spool'
reports_spool_days_to_keep
--------------------------
How many days to keep the unimported reports.
remove_reports_spool_user
-------------------------
User to remove unimported reports.
- *Default*: root
remove_reports_spool_hour
-------------------------
On which hour to remove unimported reports.
- *Default*: 0
remove_reports_spool_minute
---------------------------
At which minute to remove unimported reports
- *Default*: 45
dump_dir
--------
The directory to use for dumps.
- *Default*: /var/local
dump_database_command
---------------------
The command to run to dump the database.
- *Default*: sudo -u puppet-dashboard /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log
dump_database_user
------------------
User to dump database as.
- *Default*: root
dump_database_hour
------------------
On which hour to dump database.
- *Default*: 1
dump_database_minute
--------------------
At which minute to purge old reports.
- *Default*: 0
days_to_keep_backups
--------------------
Number of days to keep database backups.
- *Default*: 7
purge_old_db_backups_user
-------------------------
User to purge old database dumps as.
- *Default*: root
purge_old_db_backups_hour
-------------------------
On which hour to purge old database dumps.
- *Default*: 2
purge_old_db_backups_minute
---------------------------
At which minute to purge old database dumps.
- *Default*: 0
===
## Class `puppet::lint` ##
### Parameters ###
ensure
------
Whether to install lint.
- *Default*: present
provider
--------
Which provider should supply lint.
- *Default*: gem
version
-------
If you do not want to use the default version of lint, specify which version you want to use here.
- *Default*: undef
lint_args
---------
Which args should be added to the .puppet-lint.rc file
- *Default*: --no-80chars-check
lintrc_path
-----------
The full path to the lint config file.
- *Default*: ${::root_home}/.puppet-lint.rc
lintrc_owner
------------
The owner of the lint config file.
- *Default*: root
lintrc_group
------------
The group of the lint config file.
- *Default*: root
lintrc_mode
-----------
The mode of the lint config file.
- *Default*: 0644
===
## Class `puppet::master` ##
### Usage ###
In Hiera you will need to specify the following.
<pre>
puppet::agent::is_puppet_master: 'true'
</pre>
### Parameters ###
sysconfig_path
--------------
The location of puppet master sysconfig file.
- *Default*: use defaults based on osfamily
vhost_path
----------
The location of puppet master vhost file for apache.
- *Default*: use defaults based on osfamily
rack_dir
--------
The rack directory path.
- *Default*: /usr/share/puppet/rack/puppetmasterd
puppet_user
-----------
The user the puppet master should run as.
- *Default*: puppet
manage_firewall
---------------
Whether to manage the firewall settings on the client
- *Default*: undef
===
## Class `puppet::master::maintenance` ##
### Parameters ###
+clientbucket_cleanup_ensure
+---------------------------
+String for ensure parameter for filebucket_cleanup cron job
+
clientbucket_path
-----------------
Path to where the clientbucket files are stored.
- *Default*: /var/lib/puppet/clientbucket
clientbucket_days_to_keep
-------------------------
The number of days to keep clientbuckets
- *Default*: 30
filebucket_cleanup_command
--------------------------
Command used to cleanup the clientbuckets.
- *Default*: /usr/bin/find ${clientbucket_path} -type f -mtime +30 -exec /bin/rm -fr {} \;
filebucket_cleanup_user
-----------------------
User to run the clientbucket cleanup as.
- *Default*: root
filebucket_cleanup_hour
-----------------------
Hour on which to run the filebucket cleanup.
- *Default*: 0
filebucket_cleanup_minute
-------------------------
Minute at which to run the filebucket cleanup.
- *Default*: 0
+reportdir_purge_ensure
+---------------------------
+String for ensure parameter for purge_old_puppet_reports cron job
+
reportdir
---------
Directory that holds the reports. `$::puppet_reportdir` is a custom fact that reads the `reportdir` setting from Puppet's configuration. This is likely `/var/lib/puppet/reports/`.
- *Default*: $::puppet_reportdir
reportdir_days_to_key
---------------------
String for number of days of reports to keep. Must be a positive integer > 0.
- *Default*: '30'
reportdir_purge_command
-----------------------
Command ran by cron to purge old reports.
- *Default*: /usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;'
reportdir_purge_user
--------------------
User for the crontab entry to run the reportdir_purge_command.
- *Default*: root
reportdir_purge_hour
--------------------
Hour at which to run the reportdir_purge_command.
- *Default*: 0
reportdir_purge_minute
----------------------
Minute past the hour in which to run the reportdir_purge_command.
- *Default*: 15
diff --git a/manifests/master/maintenance.pp b/manifests/master/maintenance.pp
index 28f890b..b9f7676 100755
--- a/manifests/master/maintenance.pp
+++ b/manifests/master/maintenance.pp
@@ -1,53 +1,60 @@
# == Class: puppet::master::maintenance
#
class puppet::master::maintenance (
- $clientbucket_path = '/var/lib/puppet/clientbucket/',
- $clientbucket_days_to_keep = '30',
- $filebucket_cleanup_command = '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
- $filebucket_cleanup_user = 'root',
- $filebucket_cleanup_hour = '0',
- $filebucket_cleanup_minute = '0',
- $reportdir = $::puppet_reportdir,
- $reportdir_days_to_keep = '30',
- $reportdir_purge_command = '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
- $reportdir_purge_user = 'root',
- $reportdir_purge_hour = '0',
- $reportdir_purge_minute = '15',
+ $clientbucket_cleanup_ensure = 'present',
+ $clientbucket_path = '/var/lib/puppet/clientbucket/',
+ $clientbucket_days_to_keep = '30',
+ $filebucket_cleanup_command = '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ $filebucket_cleanup_user = 'root',
+ $filebucket_cleanup_hour = '0',
+ $filebucket_cleanup_minute = '0',
+ $reportdir_purge_ensure = 'present',
+ $reportdir = $::puppet_reportdir,
+ $reportdir_days_to_keep = '30',
+ $reportdir_purge_command = '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ $reportdir_purge_user = 'root',
+ $reportdir_purge_hour = '0',
+ $reportdir_purge_minute = '15',
) {
validate_absolute_path($reportdir)
+ validate_re($clientbucket_cleanup_ensure, '^(present|absent)$', "clientbucket_cleanup_ensure must be 'present' or 'absent'. Detected value is <${clientbucket_cleanup_ensure}>")
+
+ validate_re($reportdir_purge_ensure, '^(present|absent)$', "reportdir_purge_ensure must be 'present' or 'absent'. Detected value is <${reportdir_purge_ensure}>")
+
# if not using the defaults, then construct the command with variables, else
# use the default command
if ( $clientbucket_days_to_keep != 30 ) or ( $clientbucket_path != '/var/lib/puppet/clientbucket/' ) {
$my_filebucket_cleanup_command = "/usr/bin/find ${clientbucket_path} -type f -mtime +${clientbucket_days_to_keep} -exec /bin/rm -fr {} \\;"
} else {
$my_filebucket_cleanup_command = $filebucket_cleanup_command
}
cron { 'filebucket_cleanup':
- ensure => present,
+ ensure => $clientbucket_cleanup_ensure,
command => $my_filebucket_cleanup_command,
user => $filebucket_cleanup_user,
hour => $filebucket_cleanup_hour,
minute => $filebucket_cleanup_minute,
}
if $reportdir_days_to_keep <= '0' {
fail("puppet::master::maintenance::reportdir_days_to_keep must be a positive integer greater than zero. Detected value is <${reportdir_days_to_keep}>.")
}
if ( $reportdir_days_to_keep != 30 ) or ( $reportdir != '/var/lib/puppet/reports' ) {
$my_reportdir_purge_command = "/usr/bin/find -L ${reportdir} -type f -mtime +${reportdir_days_to_keep} -exec /bin/rm -fr {} \\;"
} else {
$my_reportdir_purge_command = $reportdir_purge_command
}
cron { 'purge_old_puppet_reports':
- ensure => present,
+ ensure => $reportdir_purge_ensure,
command => $my_reportdir_purge_command,
user => $reportdir_purge_user,
hour => $reportdir_purge_hour,
minute => $reportdir_purge_minute,
}
+
}
diff --git a/spec/classes/master_maintenance_spec.rb b/spec/classes/master_maintenance_spec.rb
index 49655ce..6a69858 100644
--- a/spec/classes/master_maintenance_spec.rb
+++ b/spec/classes/master_maintenance_spec.rb
@@ -1,267 +1,325 @@
require 'spec_helper'
describe 'puppet::master::maintenance' do
describe 'class puppet::master::maintenance' do
context 'Puppetmaster maintenance cron' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'user' => 'root',
'hour' => '0',
'minute' => '0',
})
}
end
+
+ context 'with reportdir_purge_ensure set to invalid value' do
+ let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports', } }
+ let(:params) { { :reportdir_purge_ensure => 'installed', } }
+
+ it 'should fail' do
+ expect {
+ should contain_class('puppet::master::maintenance')
+ }.to raise_error(Puppet::Error,/^reportdir_purge_ensure must be 'present' or 'absent'. Detected value is <installed>/)
+ end
+ end
+
+ context 'with clientbucket_cleanup_ensure set to invalid value' do
+ let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports', } }
+ let(:params) { { :clientbucket_cleanup_ensure => 'installed', } }
+
+ it 'should fail' do
+ expect {
+ should contain_class('puppet::master::maintenance')
+ }.to raise_error(Puppet::Error,/^clientbucket_cleanup_ensure must be 'present' or 'absent'. Detected value is <installed>/)
+ end
+ end
+
end
describe 'clientbucket cleanup' do
context 'with default settings' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'ensure' => 'present',
'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '0',
})
}
end
context 'with non-default user' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
let(:params) do
{ :filebucket_cleanup_user => 'gh', }
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'ensure' => 'present',
'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'gh',
'hour' => '0',
'minute' => '0',
})
}
end
context 'with non-default path' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
let(:params) do
{ :clientbucket_path => '/var/lib/puppet/filebucket/', }
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'ensure' => 'present',
'command' => '/usr/bin/find /var/lib/puppet/filebucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '0',
})
}
end
context 'with non-default number of days to keep' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
let(:params) do
{
:clientbucket_days_to_keep => '20',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'ensure' => 'present',
'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +20 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '0',
})
}
end
context 'with non-default hour and minute set' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
let(:params) do
{
:filebucket_cleanup_hour => '2',
:filebucket_cleanup_minute => '30',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'ensure' => 'present',
'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '2',
'minute' => '30',
})
}
end
+
+ context 'with clientbucket_cleanup_ensure set to absent' do
+ let(:facts) do
+ { :puppet_reportdir => '/var/lib/puppet/reports', }
+ end
+ let(:params) do
+ { :clientbucket_cleanup_ensure => 'absent', }
+ end
+
+ it { should contain_class('puppet::master::maintenance') }
+
+ it { should contain_cron('filebucket_cleanup').with({
+ 'ensure' => 'absent'
+ })
+ }
+ end
+
end
describe 'purge reportdir' do
context 'with default settings for params' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
context 'with reportdir_purge_user, reportdir_purge_hour, and reportdir_purge_minute set' do
let(:params) do
{ :reportdir_purge_user => 'gh',
:reportdir_purge_hour => '23',
:reportdir_purge_minute => '42',
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'gh',
'hour' => '23',
'minute' => '42',
})
}
end
describe 'with reportdir_days_to_keep specified' do
context 'as a valid integer greater than zero' do
let(:params) { { :reportdir_days_to_keep => '42' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +42 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
['0','-23'].each do |value|
context "as #{value}" do
let(:params) { { :reportdir_days_to_keep => value } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it do
expect {
should contain_class('puppet::master::maintenance')
}.to raise_error(Puppet::Error,/puppet::master::maintenance::reportdir_days_to_keep must be a positive integer greater than zero. Detected value is <#{value}>./)
end
end
end
end
describe 'with reportdir specified' do
context 'as a valid directory' do
let(:params) { { :reportdir => '/etc/puppet/reports' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
'command' => '/usr/bin/find -L /etc/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
context 'as an invalid directory' do
let(:params) { { :reportdir => 'invalid/path' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it do
expect {
should contain_class('puppet::master::maintenance')
}.to raise_error(Puppet::Error,/^"invalid\/path" is not an absolute path./)
end
end
end
context 'with reportdir and reportdir_days_to_keep specified' do
let(:params) do
{ :reportdir => '/etc/puppet/reports',
:reportdir_days_to_keep => '42',
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
'command' => '/usr/bin/find -L /etc/puppet/reports -type f -mtime +42 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
+
+ context 'with purge_old_puppet_reports set to absent' do
+ let(:facts) do
+ { :puppet_reportdir => '/var/lib/puppet/reports', }
+ end
+ let(:params) do
+ { :reportdir_purge_ensure => 'absent', }
+ end
+
+ it { should contain_class('puppet::master::maintenance') }
+
+ it { should contain_cron('purge_old_puppet_reports').with({
+ 'ensure' => 'absent'
+ })
+ }
+
+ end
+
end
end
|
ghoneycutt/puppet-module-puppet
|
6b2cda46627d1bbf27bf739a4dce6063799873fb
|
Release v2.14.3 - Enhance testing
|
diff --git a/Modulefile b/Modulefile
index 75f4906..40470cd 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,17 +1,17 @@
name 'ghoneycutt-puppet'
-version '2.14.2'
+version '2.14.3'
source 'git://github.com/ghoneycutt/puppet-module-puppet.git'
author 'ghoneycutt'
license 'Apache-2.0'
summary 'Manage Puppet'
description 'Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.'
project_page 'https://github.com/ghoneycutt/puppet-module-puppet'
dependency 'ghoneycutt/common', '>= 1.0.3'
dependency 'leinaddm/htpasswd', '>= 0.0.1'
dependency 'puppetlabs/stdlib', '>= 3.2.0'
dependency 'puppetlabs/mysql', '>= 2.0.0'
dependency 'puppetlabs/passenger', '>= 0.0.4'
dependency 'puppetlabs/apache', '>= 0.5.0'
dependency 'puppetlabs/firewall', '>= 0.2.1'
dependency 'puppetlabs/concat', '>= 1.0.0'
diff --git a/metadata.json b/metadata.json
index c91812b..6129030 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.14.2",
+ "version": "2.14.3",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
1fbbb4d2d98e61bbd7ceeb78a25b51a371c4ef14
|
modernize travis-ci configs
|
diff --git a/.travis.yml b/.travis.yml
index a6fdc3b..5f23c23 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,18 +1,28 @@
---
+language: ruby
+
+rvm:
+ - 1.8.7
+ - 1.9.3
+ - 2.0.0
+
env:
-- PUPPET_VERSION=3.3.2
-- PUPPET_VERSION=3.4.2
-- PUPPET_VERSION=3.5.1
-- PUPPET_VERSION=3.6.0
-- PUPPET_VERSION=3.7.0
+ matrix:
+ - PUPPET_GEM_VERSION="~> 3.3.0"
+ - PUPPET_GEM_VERSION="~> 3.4.0"
+ - PUPPET_GEM_VERSION="~> 3.5.1"
+ - PUPPET_GEM_VERSION="~> 3.6.0"
+ - PUPPET_GEM_VERSION="~> 3.7.0"
+
sudo: false
-notifications:
-email: false
-rvm:
-- 1.8.7
-- 1.9.3
-- 2.0.0
-language: ruby
-before_script: 'gem install --no-ri --no-rdoc bundler'
+
script: 'bundle exec rake validate && bundle exec rake lint && SPEC_OPTS="--format documentation" bundle exec rake spec'
-gemfile: Gemfile
+
+matrix:
+ fast_finish: true
+ exclude:
+ - rvm: 2.0.0
+ env: PUPPET_GEM_VERSION="~> 3.1.0"
+
+notifications:
+ email: false
diff --git a/Gemfile b/Gemfile
index 3b888ac..9a14f04 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,7 +1,11 @@
source 'https://rubygems.org'
-puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3']
-gem 'puppet', puppetversion
+if puppetversion = ENV['PUPPET_GEM_VERSION']
+ gem 'puppet', puppetversion, :require => false
+else
+ gem 'puppet', :require => false
+end
+
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'puppet-lint', '>= 1.0.0'
gem 'facter', '>= 1.7.0'
|
ghoneycutt/puppet-module-puppet
|
342374db3a20ff6ed9aae7b8e76a3eebc48c02f6
|
Support facter v2
|
diff --git a/Gemfile b/Gemfile
index f367f3b..3b888ac 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,7 +1,7 @@
source 'https://rubygems.org'
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'puppet-lint', '>= 1.0.0'
-gem 'facter', '>= 1.7.0', "< 1.8.0"
+gem 'facter', '>= 1.7.0'
|
ghoneycutt/puppet-module-puppet
|
ae7f7bbbb30ba706279819346fa7f2181dc337e1
|
Support puppet-lint v1
|
diff --git a/Gemfile b/Gemfile
index e7a7d4b..f367f3b 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,7 +1,7 @@
source 'https://rubygems.org'
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.1.0'
-gem 'puppet-lint', '>= 0.3.2'
+gem 'puppet-lint', '>= 1.0.0'
gem 'facter', '>= 1.7.0', "< 1.8.0"
diff --git a/Rakefile b/Rakefile
index d5ccdb0..e2c6d52 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,17 +1,18 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.send('disable_80chars')
+PuppetLint.configuration.relative = true
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
-desc "Run puppet in noop mode and check for syntax errors."
+desc 'Validate manifests, templates, and ruby files'
task :validate do
Dir['manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}"
end
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
end
Dir['templates/**/*.erb'].each do |template|
sh "erb -P -x -T '-' #{template} | ruby -c"
end
end
|
ghoneycutt/puppet-module-puppet
|
a03863103cafb4195322091f17b78f1b54482099
|
Validate paths always
|
diff --git a/manifests/agent.pp b/manifests/agent.pp
index d4bea78..1910214 100755
--- a/manifests/agent.pp
+++ b/manifests/agent.pp
@@ -1,262 +1,261 @@
# == Class: puppet::agent
#
# Manage Puppet agents
#
# We also run puppet once at boot via cron, regardless of if you normally run
# puppet from cron or as a daemon.
#
class puppet::agent (
$certname = $::fqdn,
$config_path = '/etc/puppet/puppet.conf',
$config_owner = 'root',
$config_group = 'root',
$config_mode = '0644',
$env = $::env,
$puppet_server = 'puppet',
$puppet_masterport = 'UNSET',
$puppet_ca_server = 'UNSET',
$http_proxy_host = 'UNSET',
$http_proxy_port = 'UNSET',
$is_puppet_master = false,
$run_method = 'service',
$run_interval = '30',
$run_in_noop = false,
$cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay',
$run_at_boot = true,
$puppet_binary = '/usr/bin/puppet',
$symlink_puppet_binary_target = '/usr/local/bin/puppet',
$symlink_puppet_binary = false,
$agent_sysconfig = 'USE_DEFAULTS',
$agent_sysconfig_ensure = 'USE_DEFAULTS',
$daemon_name = 'puppet',
$stringify_facts = true,
$etckeeper_hooks = false,
) {
if type($run_in_noop) == 'String' {
$run_in_noop_bool = str2bool($run_in_noop)
} else {
$run_in_noop_bool = $run_in_noop
}
validate_bool($run_in_noop_bool)
if type($run_at_boot) == 'String' {
$run_at_boot_bool = str2bool($run_at_boot)
} else {
$run_at_boot_bool = $run_at_boot
}
validate_bool($run_at_boot_bool)
if type($is_puppet_master) == 'String' {
$is_puppet_master_bool = str2bool($is_puppet_master)
} else {
$is_puppet_master_bool = $is_puppet_master
}
validate_bool($is_puppet_master_bool)
# env must be set, else fail, since we use it in the puppet_config template
if ! $env {
fail('puppet::agent::env must be set')
}
if $puppet_masterport != 'UNSET' and is_integer($puppet_masterport) == false {
fail("puppet::agent::puppet_masterport is set to <${puppet_masterport}>. It should be an integer.")
}
if type($stringify_facts) == 'string' {
$stringify_facts_bool = str2bool($stringify_facts)
} else {
$stringify_facts_bool = $stringify_facts
}
validate_bool($stringify_facts_bool)
if type($etckeeper_hooks) == 'String' {
$etckeeper_hooks_bool = str2bool($etckeeper_hooks)
} else {
$etckeeper_hooks_bool = $etckeeper_hooks
}
validate_bool($etckeeper_hooks_bool)
if $http_proxy_host != 'UNSET' and (is_domain_name($http_proxy_host) == false and is_ip_address($http_proxy_host) == false){
fail("puppet::agent::http_proxy_host is set to <${http_proxy_host}>. It should be a fqdn or an ip-address.")
}
if $http_proxy_port != 'UNSET' and is_integer($http_proxy_port) == false {
fail("puppet::agent::http_proxy_port is set to <${http_proxy_port}>. It should be an Integer.")
}
case $::osfamily {
'Debian': {
$default_agent_sysconfig = '/etc/default/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'RedHat': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'Solaris': {
$default_agent_sysconfig = undef
$default_agent_sysconfig_ensure = 'absent'
}
'Suse': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
default: {
fail("puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <${::osfamily}>.")
}
}
if $agent_sysconfig == 'USE_DEFAULTS' {
$agent_sysconfig_real = $default_agent_sysconfig
} else {
$agent_sysconfig_real = $agent_sysconfig
}
if $agent_sysconfig_ensure == 'USE_DEFAULTS' {
$agent_sysconfig_ensure_real = $default_agent_sysconfig_ensure
} else {
$agent_sysconfig_ensure_real = $agent_sysconfig_ensure
}
if $is_puppet_master_bool == false {
$config_content = template('puppet/puppetagent.conf.erb')
} else {
$config_content = undef
}
case $run_method {
'service': {
$daemon_ensure = 'running'
$daemon_enable = true
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
'cron': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_run_one = fqdn_rand($run_interval)
$cron_run_two = fqdn_rand($run_interval) + 30
$cron_ensure = 'present'
$cron_user = 'root'
$cron_hour = '*'
if $run_interval > 30 {
$cron_minute = $cron_run_one
} else {
$cron_minute = [$cron_run_one, $cron_run_two]
}
if $run_in_noop_bool == true {
$my_cron_command = "${cron_command} --noop"
} else {
$my_cron_command = $cron_command
}
}
'disable': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
default: {
fail("puppet::agent::run_method is ${run_method} and must be 'disable', 'service' or 'cron'.")
}
}
if $run_at_boot_bool == true {
$at_boot_ensure = 'present'
} else {
$at_boot_ensure = 'absent'
}
if type($symlink_puppet_binary) == 'string' {
$symlink_puppet_binary_bool = str2bool($symlink_puppet_binary)
} else {
$symlink_puppet_binary_bool = $symlink_puppet_binary
}
validate_bool($symlink_puppet_binary_bool)
+ validate_absolute_path($puppet_binary)
+ validate_absolute_path($symlink_puppet_binary_target)
+
# optionally create symlinks to puppet binary
if $symlink_puppet_binary_bool == true {
- # validate params
- validate_absolute_path($symlink_puppet_binary_target)
- validate_absolute_path($puppet_binary)
-
file { 'puppet_symlink':
ensure => link,
path => $symlink_puppet_binary_target,
target => $puppet_binary,
}
}
file { 'puppet_config':
path => $config_path,
content => $config_content,
owner => $config_owner,
group => $config_group,
mode => $config_mode,
}
if ($etckeeper_hooks_bool) {
file { 'etckeeper_pre':
path => '/etc/puppet/etckeeper-commit-pre',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/puppet/etckeeper-commit-pre'
}
file { 'etckeeper_post':
path => '/etc/puppet/etckeeper-commit-post',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/puppet/etckeeper-commit-post'
}
}
if $default_agent_sysconfig_ensure =~ /(present)|(file)/ {
file { 'puppet_agent_sysconfig':
ensure => $agent_sysconfig_ensure_real,
path => $agent_sysconfig_real,
content => template('puppet/agent_sysconfig.erb'),
owner => 'root',
group => 'root',
mode => '0644',
}
}
service { 'puppet_agent_daemon':
# GH: This service will always show as being running while an agent run is
# taking place, so we no longer ensure its status. Before doing this, there
# would *always* be a logged change and the Console could never be green.
#ensure => $daemon_ensure,
name => $daemon_name,
enable => $daemon_enable,
}
cron { 'puppet_agent':
ensure => $cron_ensure,
command => $my_cron_command,
user => $cron_user,
hour => $cron_hour,
minute => $cron_minute,
}
if $run_method == 'cron' {
cron { 'puppet_agent_once_at_boot':
ensure => $at_boot_ensure,
command => $my_cron_command,
user => $cron_user,
special => 'reboot',
}
}
}
|
ghoneycutt/puppet-module-puppet
|
3c150cb79ab546f51c4d02901fc971f329871a7d
|
Check for explicit error messages in spec tests.
|
diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb
index 42f41ef..6b10983 100644
--- a/spec/classes/agent_spec.rb
+++ b/spec/classes/agent_spec.rb
@@ -1,735 +1,743 @@
require 'spec_helper'
describe 'puppet::agent' do
describe 'config file' do
context 'with default settings' do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/masterport =/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should_not contain_file('puppet_config').with_content(/^\s*http_proxy_host =/) }
it { should_not contain_file('puppet_config').with_content(/^\s*http_proxy_port =/) }
it { should contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
it { should_not contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
['false',false].each do |value|
context "with is_puppet_master set to #{value} (default)" do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) do
{ :env => 'production',
:is_puppet_master => value,
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['true',true].each do |value|
context "with is_puppet_master set to #{value}" do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) do
{ :env => 'production',
:is_puppet_master => value,
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'content' => nil,
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should_not contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should_not contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should_not contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
end
describe 'with run_interval' do
['29','30',30,'45',56].each do |value|
context "set to #{value}" do
let(:facts) do
{
:osfamily => 'RedHat',
:fqdn => 'agent.learnpuppet.com',
}
end
let(:params) do
{
:run_method => 'cron',
:run_interval => value,
:env => 'production',
}
end
# Values here are from trial and error based on the fqdn above. Not
# sure if it is possible to stub fqdn_rand()
if value.to_s > '30'
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'minute' => 39,
})
}
else
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'minute' => ['7', 37],
})
}
end
end
end
[true,false,{ 'k' => 'v'},['1','2']].each do |value|
context "set to invalid value #{value}" do
let(:facts) do
{
:osfamily => 'RedHat',
:fqdn => 'agent.learnpuppet.com',
}
end
let(:params) do
{
:run_method => 'cron',
:run_interval => value,
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^undefined method `to_i'/)
end
end
end
end
describe 'with stringify_facts' do
['true',true].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['false',false].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = false$/) }
end
end
context 'set to an invalid setting' do
let(:params) do
{
:stringify_facts => 'invalid',
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean given/)
end
end
end
describe 'sysconfig file' do
context 'Puppet agent sysconfig file on osfamily RedHat' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Debian',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on Ubuntu' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Solaris' do
let(:facts) { { :osfamily => 'Solaris' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should_not contain_file('puppet_agent_sysconfig') }
end
context 'Puppet agent sysconfig file on osfamily Suse' do
let(:facts) { { :osfamily => 'Suse' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on invalid osfamily' do
let(:facts) { { :osfamily => 'invalid' } }
let(:params) { { :env => 'production' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <invalid>./)
end
end
end
describe 'with symlink_puppet_binary' do
['true',true].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/usr/local/bin/puppet',
'target' => '/usr/bin/puppet',
'ensure' => 'link',
})
}
end
end
['false',false].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it { should_not contain_file('puppet_symlink') }
end
end
context 'enabled with all params specified' do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => '/bar',
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/bar',
'target' => '/foo/bar',
'ensure' => 'link',
})
}
end
context 'enabled with invalid puppet_binary' do
+ let(:facts) { { :osfamily => 'Debian' } }
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
- :puppet_binary => 'true',
+ :puppet_binary => 'invalid/path',
:symlink_puppet_binary_target => '/bar' } }
- it do
- expect { should }.to raise_error(Puppet::Error)
+
+ it 'should fail' do
+ expect {
+ should contain_class('puppet::master')
+ }.to raise_error(Puppet::Error,/^"invalid\/path" is not an absolute path./)
end
end
context 'enabled with invalid symlink_puppet_binary_target' do
+ let(:facts) { { :osfamily => 'Debian' } }
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
- :symlink_puppet_binary_target => 'undef' } }
- it do
- expect { should }.to raise_error(Puppet::Error)
+ :symlink_puppet_binary_target => 'invalid/path' } }
+
+ it 'should fail' do
+ expect {
+ should contain_class('puppet::master')
+ }.to raise_error(Puppet::Error,/^"invalid\/path" is not an absolute path./)
end
end
end
describe 'with run_method' do
context 'set to disable' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'disable',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => false,
})
}
end
context 'set to service' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'service',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => true,
})
}
end
context 'set to cron' do
context 'with run_in_noop set to non-string and non-boolean' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => ['invalid_type','not_a_string','not_a_boolean'],
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^\["invalid_type", "not_a_string", "not_a_boolean"\] is not a boolean./)
end
end
context 'with run_in_noop set to invalid string' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => 'invalid_string',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean given/)
end
end
cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
# iterate through a matrix of setting true and false as booleans and
# strings for both run_in_noop and run_at_boot.
['true',true,'false',false].each do |rin_value|
context "with run_in_noop => #{rin_value}" do
['true',true,'false',false].each do |rab_value|
context "and run_at_boot => #{rab_value}" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => rin_value,
:run_at_boot => rab_value,
}
end
if rin_value == true or rin_value == 'true' then
command = "#{cron_command} --noop"
else
command = cron_command
end
if rab_value == true or rab_value == 'true' then
at_boot_ensure = 'present'
else
at_boot_ensure = 'absent'
end
it { should contain_class('puppet::agent') }
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'user' => 'root',
'command' => command,
})
}
it { should contain_cron('puppet_agent_once_at_boot').with({
'ensure' => at_boot_ensure,
'user' => 'root',
'command' => command,
'special' => 'reboot',
})
}
end
end
end
end
end
end
describe 'with puppet_masterport' do
context 'set to integer' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => '8888',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with_content(/^\s*masterport = 8888$/) }
end
context 'set to a string that is not an integer (foo)' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => 'foo',
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::puppet_masterport is set to <foo>. It should be an integer./)
end
end
context 'set to an invalid type (non-string)' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => ['invalid','type'],
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^undefined method `to_i'/)
end
end
end
describe 'with etckeeper_hooks' do
['true',true].each do |value|
context "set to #{value}" do
let(:params) do
{
:etckeeper_hooks => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('etckeeper_pre') }
it { should contain_file('etckeeper_post') }
it { should contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
it { should contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
end
['false',false].each do |value|
context "set to #{value}" do
let(:params) do
{
:etckeeper_hooks => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should_not contain_file('etckeeper_pre') }
it { should_not contain_file('etckeeper_post') }
it { should_not contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
it { should_not contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
end
context 'set to an invalid setting' do
let(:params) do
{
:etckeeper_hooks => 'invalid',
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean given/)
end
end
end
describe 'with http_proxy_host' do
context 'set to a valid domain' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_host => 'proxy.host.local.domain',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it {should contain_file('puppet_config').with_content(/^\s*http_proxy_host = proxy\.host\.local\.domain$/) }
end
['8.8.8.8','2a00:1450:400f:804::1011'].each do |ip_address|
context "set to #{ip_address} (ip-address)" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :env => 'production',
:http_proxy_host => ip_address,
}
end
it { should contain_file('puppet_config').with_content(/\s*http_proxy_host = #{Regexp.escape(ip_address)}$/) }
end
end
['8.8.8.8.#','".#.%.!','foo..bar'].each do |invalid_value|
context "set to #{invalid_value} (invalid value)" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :env => 'production',
:http_proxy_host => invalid_value,
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::http_proxy_host is set to <#{Regexp.escape(invalid_value)}>. It should be a fqdn or an ip-address./)
end
end
end
context 'set to an invalid type' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_host => ['invalid','type'],
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/chomp/)
end
end
end
describe 'with http_proxy_port' do
context 'set to integer' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_port => '8888',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with_content(/^\s*http_proxy_port = 8888$/) }
end
context 'set to an invalid type' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_port => ['invalid','type'],
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^undefined method `to_i'/)
end
end
context 'set to an invalid value' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_port => 'foo',
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::http_proxy_port is set to <foo>. It should be an Integer./)
end
end
end
end
diff --git a/spec/classes/dashboard_maintenance_spec.rb b/spec/classes/dashboard_maintenance_spec.rb
index 11dbbc6..289989f 100644
--- a/spec/classes/dashboard_maintenance_spec.rb
+++ b/spec/classes/dashboard_maintenance_spec.rb
@@ -1,324 +1,324 @@
require 'spec_helper'
describe 'puppet::dashboard::maintenance' do
describe 'class puppet::dashboard::maintenance' do
context 'with database dump dir as default value on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_file('/var/local').with({
'ensure' => 'directory',
'group' => 'puppet-dashboard',
'mode' => '0775',
})
}
end
context 'with database dump dir as default value on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_file('/var/local').with({
'ensure' => 'directory',
'group' => 'puppet',
'mode' => '0775',
})
}
end
context 'with database dump dir specified' do
let(:params) { {:dump_dir => '/foo/bar'} }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_file('/foo/bar').with({
'ensure' => 'directory',
'mode' => '0775',
})
}
end
context 'with database dump dir specified as invalid value' do
let(:params) { {:dump_dir => 'invalid/path/statement'} }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
}
end
it do
expect {
should contain_class('puppet::dashboard::maintenance')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^"invalid\/path\/statement" is not an absolute path./)
end
end
context 'Dashboard database optimization' do
let(:params) { {:db_optimization_command => '/foo/bar' } }
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('monthly_dashboard_database_optimization').with({
'command' => '/foo/bar',
'user' => 'root',
'hour' => '0',
'minute' => '0',
'monthday' => '1',
})
}
end
context 'Dashboard database purge reports' do
let(:params) { {:purge_old_reports_command => '/foo/bar' }}
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('purge_old_reports').with({
'command' => '/foo/bar',
'user' => 'root',
'hour' => '0',
'minute' => '30',
})
}
end
context 'Dashboard spool remove reports with remove_old_reports_spool set to invalid string' do
let(:params) { {:remove_old_reports_spool => 'invalid_string' } }
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it do
expect {
should contain_class('puppet::dashboard::maintenance')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean/)
end
end
context 'Dashboard spool remove reports with remove_old_reports_spool set to invalid type - non-boolean and non-string' do
let(:params) { {:remove_old_reports_spool => ['invalid_type','not_a_string','not_a_boolean'] } }
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it do
expect {
should contain_class('puppet::dashboard::maintenance')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^\["invalid_type", "not_a_string", "not_a_boolean"\] is not a boolean./)
end
end
[true,'true'].each do |value|
context "Dashboard spool remove reports with remove_old_reports_spool set to #{value}" do
let(:params) { {:remove_old_reports_spool => value } }
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('remove_old_reports_spool').with({
'command' => '/bin/find /usr/share/puppet-dashboard/spool -type f -name "*.yaml" -mtime +7 -exec /bin/rm -f {} \;',
'ensure' => 'present',
'user' => 'root',
'hour' => '0',
'minute' => '45',
})
}
end
end
context 'Dashboard spool remove reports with params set' do
let(:params) { {:remove_old_reports_spool => 'true',
:remove_reports_spool_user => 'user',
:remove_reports_spool_hour => '5',
:remove_reports_spool_minute => '6',
:reports_spool_dir => '/tmp/foo',
:reports_spool_days_to_keep => '10' } }
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('remove_old_reports_spool').with({
'ensure' => 'present',
'command' => '/bin/find /tmp/foo -type f -name "*.yaml" -mtime +10 -exec /bin/rm -f {} \;',
'user' => 'user',
'hour' => '5',
'minute' => '6',
})
}
end
[false,'false'].each do |value|
context "Dashboard spool remove reports with remove_old_reports_spool set to #{value}" do
let(:params) { {:remove_old_reports_spool => value } }
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('remove_old_reports_spool').with({
'ensure' => 'absent',
})
}
end
end
context 'with reports_spool_dir set to an invalid path' do
- let(:params) { {:reports_spool_dir=> 'invalid/path/param' }}
+ let(:params) { {:reports_spool_dir=> 'invalid/path/statement' } }
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it do
expect {
should contain_class('puppet::dashboard::maintenance')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^"invalid\/path\/statement" is not an absolute path./)
end
end
context 'with dump_database_command set to default value on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('dump_dashboard_database').with({
'command' => 'cd ~puppet-dashboard && sudo -u puppet-dashboard /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1',
'user' => 'root',
'hour' => '1',
'minute' => '0',
})
}
end
context 'with dump_database_command set to default value on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.0.8',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('dump_dashboard_database').with({
'command' => 'cd ~puppet-dashboard && sudo -u puppet /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log 2>&1 && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log 2>&1',
'user' => 'root',
'hour' => '1',
'minute' => '0',
})
}
end
context 'with dump_database_command specified' do
let(:params) { {:dump_database_command => '/foo/bar' } }
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('dump_dashboard_database').with({
'command' => '/foo/bar',
'user' => 'root',
'hour' => '1',
'minute' => '0',
})
}
end
context 'Dashboard database backup cleanup' do
let(:facts) do
{ :osfamily => 'RedHat',
:concat_basedir => '/tmp',
:max_allowed_packet => 32,
:operatingsystemrelease => '6.4',
}
end
it { should contain_class('puppet::dashboard::maintenance') }
it { should contain_cron('purge_old_db_backups').with({
'user' => 'root',
'hour' => '2',
'minute' => '0',
})
}
end
end
end
diff --git a/spec/classes/dashboard_server_spec.rb b/spec/classes/dashboard_server_spec.rb
index 89c44de..e8e8d49 100644
--- a/spec/classes/dashboard_server_spec.rb
+++ b/spec/classes/dashboard_server_spec.rb
@@ -1,523 +1,523 @@
require 'spec_helper'
describe 'puppet::dashboard::server' do
context 'with default dashboard_workers on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should_not contain_file('dashboard_workers_default') }
end
context 'with default dashboard_workers on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_workers_default').with({
'ensure' => 'file',
'path' => '/etc/default/puppet-dashboard-workers',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('dashboard_workers_default').with_content(/^START=yes$/) }
it { should contain_file('dashboard_workers_default').with_content(/^NUM_DELAYED_JOB_WORKERS=8$/) }
end
context 'with default dashboard_workers set to non-digit' do
let(:params) { { :dashboard_workers => '8invalid' } }
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:concat_basedir => '/tmp',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error,/puppet::dashboard::server::dashboard_workers must be a digit. Detected value is <8invalid>./)
end
end
context 'with default htpasswd path on osfamily RedHat' do
let(:params) do
{ :security => 'htpasswd',
:htpasswd => {
'gh' => {
'cryptpasswd' => 'password',
},
}
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_htpasswd_path').with({
'ensure' => 'file',
'path' => '/etc/puppet/dashboard.htpasswd',
'owner' => 'root',
'group' => 'apache',
'mode' => '0640',
})
}
end
context 'with default htpasswd path on osfamily Debian' do
let(:params) do
{ :security => 'htpasswd',
:htpasswd => {
'gh' => {
'cryptpasswd' => 'password',
},
}
}
end
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_htpasswd_path').with({
'ensure' => 'file',
'path' => '/etc/puppet/dashboard.htpasswd',
'owner' => 'root',
'group' => 'www-data',
'mode' => '0640',
})
}
end
context 'with htpasswd_path set by user' do
let(:params) do
{ :htpasswd_path => '/var/www/html/dashboard_passwd',
:security => 'htpasswd',
:htpasswd => {
'gh' => {
'cryptpasswd' => 'password',
},
}
}
end
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_htpasswd_path').with({
'ensure' => 'file',
'path' => '/var/www/html/dashboard_passwd',
'owner' => 'root',
'group' => 'www-data',
'mode' => '0640',
})
}
end
context 'with invalid value for htpasswd_path' do
let(:params) do
{ :htpasswd_path => 'not/a/valid/path',
:security => 'htpasswd',
:htpasswd => {
'gh' => {
'cryptpasswd' => 'password',
},
}
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it do
expect {
should contain_class('puppet::dashboard')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^"not\/a\/valid\/path" is not an absolute path./)
end
end
[false,'false'].each do |value|
context "with manage_mysql_options set to <#{value}>" do
let(:params) { { :manage_mysql_options => "#{value}" } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:processorcount => '8',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_class('mysql::server').with({'override_options' => {},}) }
it { should_not contain_file('/etc/my.cnf').with_content(/^max_allowed_packet = 32M$/) }
end
end
[true,'true'].each do |value|
context "with manage_mysql_options set to <#{value}>" do
let(:params) { { :manage_mysql_options => "#{value}" } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:processorcount => '8',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('/etc/my.cnf').with_content(/^max_allowed_packet = 32M$/) }
it {
should contain_class('mysql::server').with({
'override_options' => {
'mysqld' => {
'max_allowed_packet' => '32M',
},
},
})
}
end
end
['invalid',[ 'dont', 'like', 'arrays', ], { 'nor' => 'hashes', }, ].each do |value|
context "with manage_mysql_options set to invalid value <#{value}>" do
let(:params) { { :manage_mysql_options => "#{value}" } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:processorcount => '8',
}
end
it do
expect {
should contain_class('puppet::dashboard')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^str2bool\(\): Unknown type of boolean/)
end
end
end
describe 'Dashboard vhost configuration file content' do
context 'when vhost_path is invalid it should fail' do
let(:params) { { :vhost_path => 'not/a/valid/path' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it do
expect {
should contain_class('puppet::dashboard')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^"not\/a\/valid\/path" is not an absolute path./)
end
end
context 'when htpasswd_path is invalid it should fail' do
let(:params) { { :htpasswd_path => 'not/a/valid/path' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it do
expect {
should contain_class('puppet::dashboard')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^"not\/a\/valid\/path" is not an absolute path./)
end
end
context 'when security is invalid it should fail' do
let(:params) { { :security => 'invalid' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error,/Security is <invalid> which does not match regex. Valid values are none and htpasswd./)
end
end
context 'with default settings' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost').with_content(/^\s*ServerName puppet.example.com$/) }
end
context 'with security set to none' do
let(:params) { { :security => 'none' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost') }
it { should_not contain_file('dashboard_vhost').with_content(/(\s+|)AuthType(\s+)basic(\s*)/) }
end
context 'with security set to htpasswd' do
let(:params) { { :security => 'htpasswd' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost').with_content(/(\s+|)AuthType(\s+)basic(\s*)/) }
end
end
context 'with database configuration file on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('database_config').with({
'path' => '/usr/share/puppet-dashboard/config/database.yml',
'owner' => 'puppet-dashboard',
'group' => 'puppet-dashboard',
'mode' => '0640',
'require' => 'Package[puppet-dashboard]',
})
}
end
context 'with database configuration file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('database_config').with({
'path' => '/usr/share/puppet-dashboard/config/database.yml',
'owner' => 'puppet',
'group' => 'www-data',
'mode' => '0640',
'require' => 'Package[puppet-dashboard]',
})
}
end
context 'Dashboard database configuration file content' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('database_config').with_content(/^\s*username: dashboard$/) }
end
context 'Dashboard vhost configuration file on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost').with({
'ensure' => 'file',
'path' => '/etc/httpd/conf.d/dashboard.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
context 'Dashboard vhost configuration file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost').with({
'ensure' => 'file',
'path' => '/etc/apache2/sites-enabled/puppetdashboard',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
context 'Dashboard Mysql Database' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_mysql__db('dashboard').with({
'user' => 'dashboard',
'password' => 'puppet',
'host' => 'localhost',
})
}
end
context 'Dashboard database migration' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_exec('migrate_dashboard_database').with({
'command' => 'rake RAILS_ENV=production db:migrate',
'path' => '/bin:/usr/bin:/sbin:/usr/sbin',
'cwd' => '/usr/share/puppet-dashboard',
'refreshonly' => true,
})
}
end
context 'Dashboard workers service' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_service('puppet-dashboard-workers').with({
'ensure' => 'running',
'enable' => true,
})
}
end
end
diff --git a/spec/classes/dashboard_spec.rb b/spec/classes/dashboard_spec.rb
index 1e8fd4b..bd89421 100644
--- a/spec/classes/dashboard_spec.rb
+++ b/spec/classes/dashboard_spec.rb
@@ -1,256 +1,256 @@
require 'spec_helper'
describe 'puppet::dashboard' do
describe 'class puppet::dashboard' do
describe 'with dashboard_package set' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:concat_basedir => '/tmp',
}
end
context 'to a string' do
let(:params) { {:dashboard_package => 'puppet-dashboard' } }
it { should contain_class('puppet::dashboard') }
it { should contain_package('puppet-dashboard').with({
'ensure' => 'present',
})
}
end
context 'to an array' do
let(:params) { {:dashboard_package => ['puppet-dashboard','pdb-somethingelse'] } }
it { should contain_class('puppet::dashboard') }
it { should contain_package('puppet-dashboard').with({
'ensure' => 'present',
})
}
it { should contain_package('pdb-somethingelse').with({
'ensure' => 'present',
})
}
end
context 'to an invalid type (boolean)' do
let(:params) { {:dashboard_package => true } }
it 'should fail' do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error,/puppet::dashboard::dashboard_package must be a string or an array./)
end
end
end
context 'external_node_script on osfamily RedHat with default options' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard') }
it { should contain_file('external_node_script').with({
'ensure' => 'file',
'path' => '/usr/share/puppet-dashboard/bin/external_node',
'owner' => 'puppet-dashboard',
'group' => 'puppet-dashboard',
'mode' => '0755',
'require' => 'Package[puppet-dashboard]',
})
}
end
context 'external_node_script on osfamily Debian with default options' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard') }
it { should contain_file('external_node_script').with({
'ensure' => 'file',
'path' => '/usr/share/puppet-dashboard/bin/external_node',
'owner' => 'puppet',
'group' => 'puppet',
'mode' => '0755',
'require' => 'Package[puppet-dashboard]',
})
}
end
context 'external_node_script with non-default external_node_script specified' do
let(:params) { { :external_node_script_path => '/opt/local/puppet-dashboard/bin/external_node' } }
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard') }
it { should contain_file('external_node_script').with({
'ensure' => 'file',
'path' => '/opt/local/puppet-dashboard/bin/external_node',
'owner' => 'puppet',
'group' => 'puppet',
'mode' => '0755',
'require' => 'Package[puppet-dashboard]',
})
}
end
context 'external_node_script with invalid path specified' do
let(:params) { { :external_node_script_path => 'invalid/path/statement' } }
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:concat_basedir => '/tmp',
}
end
it 'should fail' do
expect {
should contain_class('puppet::dashboard')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^"invalid\/path\/statement" is not an absolute path./)
end
end
context 'Dashboard sysconfig file on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard') }
it { should contain_file('dashboard_sysconfig').with({
'ensure' => 'file',
'path' => '/etc/sysconfig/puppet-dashboard',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('dashboard_sysconfig').with_content(/^DASHBOARD_PORT=3000$/) }
end
context 'Dashboard sysconfig file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '7',
:ports_file => '/etc/httpd/ports.conf"',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard') }
it { should contain_file('dashboard_sysconfig').with({
'ensure' => 'file',
'path' => '/etc/default/puppet-dashboard',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should_not contain_file('dashboard_sysconfig').with_content(/^START=yes$/) }
it { should contain_file('dashboard_sysconfig').with_content(/^DASHBOARD_HOME=\/usr\/share\/puppet-dashboard$/) }
it { should contain_file('dashboard_sysconfig').with_content(/^DASHBOARD_USER=www-data$/) }
it { should contain_file('dashboard_sysconfig').with_content(/^DASHBOARD_RUBY=\/usr\/bin\/ruby$/) }
it { should contain_file('dashboard_sysconfig').with_content(/^DASHBOARD_ENVIRONMENT=production$/) }
it { should contain_file('dashboard_sysconfig').with_content(/^DASHBOARD_IFACE=0.0.0.0$/) }
it { should contain_file('dashboard_sysconfig').with_content(/^DASHBOARD_PORT=3000$/) }
end
context 'Dashboard sysconfig file on invalid osfamily' do
let(:facts) do
{ :osfamily => 'invalid',
:operatingsystemrelease => '7',
:ports_file => '/etc/httpd/ports.conf"',
:concat_basedir => '/tmp',
}
end
it 'should fail' do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error,/puppet::dashboard supports osfamilies Debian and RedHat. Detected osfamily is <invalid>./)
end
end
context 'Dashboard sysconfig specified with invalid path' do
let(:params) { { :sysconfig_path => 'invalid/path/statement' } }
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '7',
:ports_file => '/etc/httpd/ports.conf"',
:concat_basedir => '/tmp',
}
end
it 'should fail' do
expect {
should contain_class('puppet::dashboard')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^"invalid\/path\/statement" is not an absolute path./)
end
end
context 'Dashboard service' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard') }
it { should contain_service('puppet-dashboard').with({
'ensure' => 'stopped',
'enable' => false,
})
}
end
context 'Dashboard workers service' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard') }
it { should contain_service('puppet-dashboard-workers').with({
'ensure' => 'stopped',
'enable' => false,
})
}
end
end
end
diff --git a/spec/classes/master_maintenance_spec.rb b/spec/classes/master_maintenance_spec.rb
index 8598320..49655ce 100644
--- a/spec/classes/master_maintenance_spec.rb
+++ b/spec/classes/master_maintenance_spec.rb
@@ -1,267 +1,267 @@
require 'spec_helper'
describe 'puppet::master::maintenance' do
describe 'class puppet::master::maintenance' do
context 'Puppetmaster maintenance cron' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'user' => 'root',
'hour' => '0',
'minute' => '0',
})
}
end
end
describe 'clientbucket cleanup' do
context 'with default settings' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'ensure' => 'present',
'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '0',
})
}
end
context 'with non-default user' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
let(:params) do
{ :filebucket_cleanup_user => 'gh', }
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'ensure' => 'present',
'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'gh',
'hour' => '0',
'minute' => '0',
})
}
end
context 'with non-default path' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
let(:params) do
{ :clientbucket_path => '/var/lib/puppet/filebucket/', }
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'ensure' => 'present',
'command' => '/usr/bin/find /var/lib/puppet/filebucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '0',
})
}
end
context 'with non-default number of days to keep' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
let(:params) do
{
:clientbucket_days_to_keep => '20',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'ensure' => 'present',
'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +20 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '0',
})
}
end
context 'with non-default hour and minute set' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
let(:params) do
{
:filebucket_cleanup_hour => '2',
:filebucket_cleanup_minute => '30',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'ensure' => 'present',
'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '2',
'minute' => '30',
})
}
end
end
describe 'purge reportdir' do
context 'with default settings for params' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
context 'with reportdir_purge_user, reportdir_purge_hour, and reportdir_purge_minute set' do
let(:params) do
{ :reportdir_purge_user => 'gh',
:reportdir_purge_hour => '23',
:reportdir_purge_minute => '42',
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'gh',
'hour' => '23',
'minute' => '42',
})
}
end
describe 'with reportdir_days_to_keep specified' do
context 'as a valid integer greater than zero' do
let(:params) { { :reportdir_days_to_keep => '42' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +42 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
['0','-23'].each do |value|
context "as #{value}" do
let(:params) { { :reportdir_days_to_keep => value } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it do
expect {
should contain_class('puppet::master::maintenance')
}.to raise_error(Puppet::Error,/puppet::master::maintenance::reportdir_days_to_keep must be a positive integer greater than zero. Detected value is <#{value}>./)
end
end
end
end
describe 'with reportdir specified' do
context 'as a valid directory' do
let(:params) { { :reportdir => '/etc/puppet/reports' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
'command' => '/usr/bin/find -L /etc/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
context 'as an invalid directory' do
let(:params) { { :reportdir => 'invalid/path' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it do
expect {
should contain_class('puppet::master::maintenance')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^"invalid\/path" is not an absolute path./)
end
end
end
context 'with reportdir and reportdir_days_to_keep specified' do
let(:params) do
{ :reportdir => '/etc/puppet/reports',
:reportdir_days_to_keep => '42',
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
'command' => '/usr/bin/find -L /etc/puppet/reports -type f -mtime +42 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
end
end
diff --git a/spec/classes/master_spec.rb b/spec/classes/master_spec.rb
index 61084a2..2b69e88 100644
--- a/spec/classes/master_spec.rb
+++ b/spec/classes/master_spec.rb
@@ -1,236 +1,236 @@
require 'spec_helper'
describe 'puppet::master' do
describe 'class puppet::master' do
context 'Puppetmaster auth.conf configuration file' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('/etc/puppet/auth.conf').with({
'owner' => 'root',
})
}
end
context 'Puppetmaster fileserver.conf configuration file' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('/etc/puppet/fileserver.conf').with({
'owner' => 'root',
})
}
end
context 'Puppetmaster sysconfig file on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('puppetmaster_sysconfig').with_content(/^#PUPPETMASTER_LOG=syslog$/) }
end
context 'Puppetmaster sysconfig file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '7',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('puppetmaster_sysconfig').with_content(/^START=no$/) }
it { should contain_file('puppetmaster_sysconfig').with_content(/^DAEMON_OPTS=""$/) }
it { should contain_file('puppetmaster_sysconfig').with_content(/^PORT=8140$/) }
end
context 'Puppetmaster sysconfig file on invalid osfmaily' do
let(:facts) do
{ :osfamily => 'invalid',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it 'should fail' do
expect {
should contain_class('puppet::master')
}.to raise_error(Puppet::Error,/puppet::master supports osfamilies Debian and RedHat. Detected osfamily is <invalid>./)
end
end
context 'Puppetmaster sysconfig file specified as invalid path' do
let(:params) { { :sysconfig_path => 'invalid/path/statement' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it 'should fail' do
expect {
should contain_class('puppet::master')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^"invalid\/path\/statement" is not an absolute path./)
end
end
context 'Puppetmaster rack directory' do
let(:params) { {:rack_dir => '/foo/bar' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('/foo/bar').with({
'ensure' => 'directory',
})
}
end
context 'Puppetmaster rack configuration file' do
let(:params) { {:rack_dir => '/foo/bar' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('/foo/bar/config.ru').with({
'owner' => 'puppet',
'group' => 'root',
'mode' => '0644',
})
}
end
context 'Puppetmaster vhost configuration file on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('puppetmaster_vhost').with({
'ensure' => 'file',
'path' => '/etc/httpd/conf.d/puppetmaster.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
context 'Puppetmaster vhost configuration file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('puppetmaster_vhost').with({
'ensure' => 'file',
'path' => '/etc/apache2/sites-enabled/puppetmaster',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
context 'Puppetmaster vhost configuration file specified as param' do
let(:params) { { :vhost_path => '/usr/local/apache/conf.d/puppetmaster.conf' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('puppetmaster_vhost').with({
'ensure' => 'file',
'path' => '/usr/local/apache/conf.d/puppetmaster.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
context 'Puppetmaster vhost configuration file specified as invalid path' do
let(:params) { { :vhost_path => 'invalid/path/statement' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it 'should fail' do
expect {
should contain_class('puppet::master')
- }.to raise_error(Puppet::Error)
+ }.to raise_error(Puppet::Error,/^"invalid\/path\/statement" is not an absolute path./)
end
end
context 'Puppetmaster vhost configuration file content' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:concat_basedir => '/tmp',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master') }
it { should contain_file('puppetmaster_vhost').with_content(/^\s*<Directory \/usr\/share\/puppet\/rack\/puppetmasterd\/>$/) }
end
end
end
|
ghoneycutt/puppet-module-puppet
|
71f0afc63372d4e06a3c934284b6cf8de7581dcc
|
Improve spec tests for maintenance class
|
diff --git a/spec/classes/master_maintenance_spec.rb b/spec/classes/master_maintenance_spec.rb
index cccaafc..8598320 100644
--- a/spec/classes/master_maintenance_spec.rb
+++ b/spec/classes/master_maintenance_spec.rb
@@ -1,173 +1,267 @@
require 'spec_helper'
describe 'puppet::master::maintenance' do
describe 'class puppet::master::maintenance' do
context 'Puppetmaster maintenance cron' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'user' => 'root',
'hour' => '0',
'minute' => '0',
})
}
end
end
+ describe 'clientbucket cleanup' do
+ context 'with default settings' do
+ let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
+
+ it { should contain_class('puppet::master::maintenance') }
+
+ it { should contain_cron('filebucket_cleanup').with({
+ 'ensure' => 'present',
+ 'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ 'user' => 'root',
+ 'hour' => '0',
+ 'minute' => '0',
+ })
+ }
+ end
+
+ context 'with non-default user' do
+ let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
+ let(:params) do
+ { :filebucket_cleanup_user => 'gh', }
+ end
+
+ it { should contain_class('puppet::master::maintenance') }
+
+ it { should contain_cron('filebucket_cleanup').with({
+ 'ensure' => 'present',
+ 'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ 'user' => 'gh',
+ 'hour' => '0',
+ 'minute' => '0',
+ })
+ }
+ end
+
+ context 'with non-default path' do
+ let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
+ let(:params) do
+ { :clientbucket_path => '/var/lib/puppet/filebucket/', }
+ end
+
+ it { should contain_class('puppet::master::maintenance') }
+
+ it { should contain_cron('filebucket_cleanup').with({
+ 'ensure' => 'present',
+ 'command' => '/usr/bin/find /var/lib/puppet/filebucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ 'user' => 'root',
+ 'hour' => '0',
+ 'minute' => '0',
+ })
+ }
+ end
+
+ context 'with non-default number of days to keep' do
+ let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
+ let(:params) do
+ {
+ :clientbucket_days_to_keep => '20',
+ }
+ end
+
+ it { should contain_class('puppet::master::maintenance') }
+
+ it { should contain_cron('filebucket_cleanup').with({
+ 'ensure' => 'present',
+ 'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +20 -exec /bin/rm -fr {} \;',
+ 'user' => 'root',
+ 'hour' => '0',
+ 'minute' => '0',
+ })
+ }
+ end
+
+ context 'with non-default hour and minute set' do
+ let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
+ let(:params) do
+ {
+ :filebucket_cleanup_hour => '2',
+ :filebucket_cleanup_minute => '30',
+ }
+ end
+
+ it { should contain_class('puppet::master::maintenance') }
+
+ it { should contain_cron('filebucket_cleanup').with({
+ 'ensure' => 'present',
+ 'command' => '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ 'user' => 'root',
+ 'hour' => '2',
+ 'minute' => '30',
+ })
+ }
+ end
+ end
+
describe 'purge reportdir' do
context 'with default settings for params' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
context 'with reportdir_purge_user, reportdir_purge_hour, and reportdir_purge_minute set' do
let(:params) do
{ :reportdir_purge_user => 'gh',
:reportdir_purge_hour => '23',
:reportdir_purge_minute => '42',
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'gh',
'hour' => '23',
'minute' => '42',
})
}
end
describe 'with reportdir_days_to_keep specified' do
context 'as a valid integer greater than zero' do
let(:params) { { :reportdir_days_to_keep => '42' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +42 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
['0','-23'].each do |value|
context "as #{value}" do
let(:params) { { :reportdir_days_to_keep => value } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it do
expect {
should contain_class('puppet::master::maintenance')
}.to raise_error(Puppet::Error,/puppet::master::maintenance::reportdir_days_to_keep must be a positive integer greater than zero. Detected value is <#{value}>./)
end
end
end
end
describe 'with reportdir specified' do
context 'as a valid directory' do
let(:params) { { :reportdir => '/etc/puppet/reports' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
'command' => '/usr/bin/find -L /etc/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
context 'as an invalid directory' do
let(:params) { { :reportdir => 'invalid/path' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it do
expect {
should contain_class('puppet::master::maintenance')
}.to raise_error(Puppet::Error)
end
end
end
context 'with reportdir and reportdir_days_to_keep specified' do
let(:params) do
{ :reportdir => '/etc/puppet/reports',
:reportdir_days_to_keep => '42',
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
'command' => '/usr/bin/find -L /etc/puppet/reports -type f -mtime +42 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
end
end
|
ghoneycutt/puppet-module-puppet
|
5669902e755c54051e6d661959ad1793a1e906ea
|
Release v2.14.2 - Support agent run_interval of once an hour
|
diff --git a/Modulefile b/Modulefile
index cc06fa5..75f4906 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,17 +1,17 @@
name 'ghoneycutt-puppet'
-version '2.14.1'
+version '2.14.2'
source 'git://github.com/ghoneycutt/puppet-module-puppet.git'
author 'ghoneycutt'
license 'Apache-2.0'
summary 'Manage Puppet'
description 'Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.'
project_page 'https://github.com/ghoneycutt/puppet-module-puppet'
dependency 'ghoneycutt/common', '>= 1.0.3'
dependency 'leinaddm/htpasswd', '>= 0.0.1'
dependency 'puppetlabs/stdlib', '>= 3.2.0'
dependency 'puppetlabs/mysql', '>= 2.0.0'
dependency 'puppetlabs/passenger', '>= 0.0.4'
dependency 'puppetlabs/apache', '>= 0.5.0'
dependency 'puppetlabs/firewall', '>= 0.2.1'
dependency 'puppetlabs/concat', '>= 1.0.0'
diff --git a/metadata.json b/metadata.json
index adb598f..c91812b 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.14.1",
+ "version": "2.14.2",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
bd67ba211b52c9892dee92837bd63481779400cb
|
Travis-ci use containers for faster builds
|
diff --git a/.travis.yml b/.travis.yml
index 00d4941..a6fdc3b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,17 +1,18 @@
---
env:
- PUPPET_VERSION=3.3.2
- PUPPET_VERSION=3.4.2
- PUPPET_VERSION=3.5.1
- PUPPET_VERSION=3.6.0
- PUPPET_VERSION=3.7.0
+sudo: false
notifications:
email: false
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
language: ruby
before_script: 'gem install --no-ri --no-rdoc bundler'
script: 'bundle exec rake validate && bundle exec rake lint && SPEC_OPTS="--format documentation" bundle exec rake spec'
gemfile: Gemfile
|
ghoneycutt/puppet-module-puppet
|
5f99d303d23cf8a772b153bbe83d04b057d3de97
|
Add tests and documentation around pupet::agent::run_interval
|
diff --git a/README.md b/README.md
index eab22c6..68e76ea 100644
--- a/README.md
+++ b/README.md
@@ -1,670 +1,670 @@
# puppet-module-puppet #
===
[](https://travis-ci.org/ghoneycutt/puppet-module-puppet)
This module handles the various parts of puppet on a given machine.
Dependencies for this module are: apache, common, mysql and passenger
## Components ##
### Agent
---------
- Manages the puppet agent on a client
- Setup of configuration files
- Setup of service or crontask to run the agent periodically
- Ensure puppet agent is run at boottime
### Master
----------
- Manages apache with passenger
- Setup of config files needed to run master
- Calls the `puppet::lint` class
- Calls the `puppet::master::maintenance` class
- Manages firewall rule for puppet if needed
- Maintenance to purge filebucket and reports
### Dashboard
-------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This installation is used by puppet systems, that need access to the dashboard
### Dashboard Server
--------------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This is the actual server running the Dashboard
- Configures the Dashboard MySQL settings
- Creates database for puppet with mysql module
- Calls the `puppet::dashboard::maintenance` class
- Maintenance to clean up old reports, optimize database and dump database
- For the maintenance cron jobs, you should have the following line in your `/etc/sudoers` which is not managed with this module.
<pre>
Defaults:root !requiretty
</pre>
### Lint
--------
- Manages [puppet-lint](http://github.com/rodjek/puppet-lint)
## Compatibility ##
-------------------
Ruby versions 1.8.7, 1.9.3, and 2.0.0 on Puppet 3.x
### Puppet Master
-----------------
* Debian 6
* Debian 7
* EL 6
* Ubuntu 12.04 LTS
### Puppet Agent
----------------
* Debian 6
* Debian 7
* EL 6
* EL 7
* Solaris
* Suse 11
* Ubuntu 12.04 LTS
===
## Class `puppet::agent` ##
### Parameters ###
certname
--------
The certificate name for the client.
- *Default*: $::fqdn
config_path
-----------
The location of the puppet config file.
- *Default*: /etc/puppet/puppet.conf
config_owner
------------
The owner of the config file.
- *Default*: root
config_group
------------
The group for the config file.
- *Default*: root
config_mode
-----------
The mode for the config file.
- *Default*: 0644
env
---
The selected environment for the client.
- *Default*: $::env
puppet_server
-------------
The puppet server the client should connect to.
- *Default*: puppet
puppet_masterport
-----------------
The masterport setting in puppet.conf. By default this line is not set.
- *Default*: UNSET
puppet_ca_server
----------------
The puppet CA server the client should use
- *Default*: UNSET
http_proxy_host
---------------
The http-proxy the client should use
- *Default*: UNSET
http_proxy_port
----------------
The http-proxy port the client should use
- *Default*: UNSET
is_puppet_master
----------------
Whether the machine is a puppet master or not.
- *Default*: false
run_method
----------
Whether to run as a service or in cron mode. Valid values are `disable`, `cron`, and `service`. The value `disable` disables automatic puppet runs and assumes you are running as a service.
- *Default*: service
run_interval
------------
-The interval with which the client should run (in minutes)
+The interval, in minutes, with which the client should run. If greater than 30, the agent will only run once per hour.
- *Default*: 30
run_in_noop
-----------
Whether the client should run in noop mode or not.
- *Default*: false
cron_command
------------
The command that should be added to the crontab (in cron mode)
- *Default*: /usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay
run_at_boot
-----------
Whether the client should run right after boot
- *Default*: true
puppet_binary
-------------
Path to puppet binary to create symlink from
- *Default*: '/usr/bin/puppet'
symlink_puppet_binary_target
----------------------------
Path to where the symlink should be created
- *Default*: '/usr/local/bin/puppet'
symlink_puppet_binary
---------------------
Boolean for ensuring a symlink for puppet_binary to symlink_puppet_binary_target. This is useful if you install puppet in a non-standard location that is not in your $PATH.
- *Default*: false
agent_sysconfig
---------------
The location of puppet agent sysconfig file.
- *Default*: use defaults based on osfamily
agent_sysconfig_ensure
----------------------
String for 'file' or 'present'. Allows you to not manage the sysconfig file.
- *Default*: use defaults based on osfamily
daemon_name
-----------
The name the puppet agent daemon should run as.
- *Default*: puppet
stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
- *Default*: true
etckeeper_hooks
---------------
Boolean to include pre- and postrun hooks for etckeeper in the main section of the puppet agent's config.
- *Default*: false
===
## Class `puppet::dashboard` ##
### Parameters ###
dashboard_package
-----------------
String or Array of the dashboard package(s) name.
- *Default*: 'puppet-dashboard'
dashboard_user
--------------
The user for dashboard installation.
- *Default*: use defaults based on osfamily
dashboard_group
--------------
The group for dashboard installation.
- *Default*: use defaults based on osfamily
sysconfig_path
-------------------
The location of puppet dashboard sysconfig file.
- *Default*: use defaults based on osfamily
external_node_script_path
-------------------------
The script to call from puppet to get manifests from dashboard.
- *Default*: /usr/share/puppet-dashboard/bin/external_node
dashboard_fqdn
--------------
The dashboard server FQDN.
- *Default*: puppet.${::domain}
port
----
The port the web server will respond to.
- *Default*: 3000
manage_mysql_options
--------------------
Boolean to use modules default mysql::server settings (mysql_max_packet_size).
For specific mysql::server settings you can use hiera now:
<pre>
puppet::dashboard::server::manage_mysql_options: false
mysql::server::override_options:
mysqld:
max_allowed_packet: '32M'
innodb_buffer_pool_size: '64M'
</pre>
- *Default*: true
===
## Class `puppet::dashboard::server` ##
### Usage ###
You can optionally specify a hash of htpasswd entries in Hiera.
<pre>
---
puppet::dashboard::htpasswd:
admin:
cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
puppet:
cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
</pre>
### Parameters ###
dashboard_workers
-----------------
Number of dashboard workers to start. Only used on osfamily Debian.
- *Default*: $::processorcount
database_config_path
--------------------
The path to the database config file.
- *Default*: /usr/share/puppet-dashboard/config/database.yml
database_config_owner
---------------------
The owner of the database config file.
- *Default*: puppet-dashboard
database_config_group
---------------------
The database config file group.
- *Default*: puppet-dashboard
database_config_mode
--------------------
The database config file mode.
- *Default*: 0640
htpasswd
--------
Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
- *Default*: undef
htpasswd_path
-------------
String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
- *Default*: `/etc/puppet/dashboard.htpasswd`
htpasswd_owner
--------------
Owner of htpasswd file.
- *Default*: root
htpasswd_group
--------------
Group of htpasswd file.
- *Default*: use defaults based on osfamily
htpasswd_mode
-------------
Mode of htpasswd file.
- *Default*: 0640
log_dir
-------
The location for the puppet log files.
- *Default*: /var/log/puppet
mysql_user
----------
The user for the mysql connection.
- *Default*: dashboard
mysql_password
--------------
The password for the mysql connection.
- *Default*: puppet
mysql_max_packet_size
---------------------
The mysql max packet size.
- *Default*: 32M
security
--------
String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
- *Default*: 'none'
vhost_path
----------
The location of puppet dashboard vhost file for apache.
- *Default*: use defaults based on osfamily
===
## Class `puppet::dashboard::maintenance` ##
### Parameters ###
db_optimization_command
-----------------------
The command to run to optimize the db.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
db_optimization_user
--------------------
The user to run db optimization.
- *Default*: root
db_optimization_hour
--------------------
The hour on which to run db optimization.
- *Default*: 0
db_optimization_minute
----------------------
The minute at which to run db optimization.
- *Default*: 0
db_optimization_monthday
------------------------
The day of the month on which to run db optimization.
- *Default*: 1
reports_days_to_keep
--------------------
How many days to keep the reports.
- *Default*: 30
purge_old_reports_command
-------------------------
Which command to run to purge old reports.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=30 unit=day >> /var/log/puppet/dashboard_maintenance.log
purge_old_reports_user
----------------------
User to purge reports as.
- *Default*: root
purge_old_reports_hour
----------------------
On which hour to purge old reports.
- *Default*: 0
purge_old_reports_minute
------------------------
At which minute to purge old reports.
- *Default*: 30
remove_old_reports_spool
------------------------
Whether we should remove old dashboard reports that have not been imported
- *Default*: 'True'
reports_spool_dir
-----------------
Path to reports in dashboard spool
- *Default*: '/usr/share/puppet-dashboard/spool'
reports_spool_days_to_keep
--------------------------
How many days to keep the unimported reports.
remove_reports_spool_user
-------------------------
User to remove unimported reports.
- *Default*: root
remove_reports_spool_hour
-------------------------
On which hour to remove unimported reports.
- *Default*: 0
remove_reports_spool_minute
---------------------------
At which minute to remove unimported reports
- *Default*: 45
dump_dir
--------
The directory to use for dumps.
- *Default*: /var/local
dump_database_command
---------------------
The command to run to dump the database.
- *Default*: sudo -u puppet-dashboard /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log
dump_database_user
------------------
User to dump database as.
- *Default*: root
dump_database_hour
------------------
On which hour to dump database.
- *Default*: 1
dump_database_minute
--------------------
At which minute to purge old reports.
- *Default*: 0
days_to_keep_backups
--------------------
Number of days to keep database backups.
- *Default*: 7
purge_old_db_backups_user
-------------------------
User to purge old database dumps as.
- *Default*: root
purge_old_db_backups_hour
-------------------------
On which hour to purge old database dumps.
- *Default*: 2
purge_old_db_backups_minute
---------------------------
At which minute to purge old database dumps.
- *Default*: 0
===
## Class `puppet::lint` ##
### Parameters ###
ensure
------
Whether to install lint.
- *Default*: present
provider
--------
Which provider should supply lint.
- *Default*: gem
version
-------
If you do not want to use the default version of lint, specify which version you want to use here.
- *Default*: undef
lint_args
---------
Which args should be added to the .puppet-lint.rc file
- *Default*: --no-80chars-check
lintrc_path
-----------
The full path to the lint config file.
- *Default*: ${::root_home}/.puppet-lint.rc
lintrc_owner
------------
The owner of the lint config file.
- *Default*: root
lintrc_group
------------
The group of the lint config file.
- *Default*: root
lintrc_mode
-----------
The mode of the lint config file.
- *Default*: 0644
===
## Class `puppet::master` ##
### Usage ###
In Hiera you will need to specify the following.
<pre>
puppet::agent::is_puppet_master: 'true'
</pre>
### Parameters ###
sysconfig_path
--------------
The location of puppet master sysconfig file.
- *Default*: use defaults based on osfamily
vhost_path
----------
The location of puppet master vhost file for apache.
- *Default*: use defaults based on osfamily
rack_dir
--------
The rack directory path.
- *Default*: /usr/share/puppet/rack/puppetmasterd
puppet_user
-----------
The user the puppet master should run as.
- *Default*: puppet
manage_firewall
---------------
Whether to manage the firewall settings on the client
- *Default*: undef
===
## Class `puppet::master::maintenance` ##
### Parameters ###
clientbucket_path
-----------------
Path to where the clientbucket files are stored.
- *Default*: /var/lib/puppet/clientbucket
clientbucket_days_to_keep
-------------------------
The number of days to keep clientbuckets
diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb
index ee88511..42f41ef 100644
--- a/spec/classes/agent_spec.rb
+++ b/spec/classes/agent_spec.rb
@@ -1,643 +1,705 @@
require 'spec_helper'
describe 'puppet::agent' do
describe 'config file' do
context 'with default settings' do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/masterport =/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should_not contain_file('puppet_config').with_content(/^\s*http_proxy_host =/) }
it { should_not contain_file('puppet_config').with_content(/^\s*http_proxy_port =/) }
it { should contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
it { should_not contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
['false',false].each do |value|
context "with is_puppet_master set to #{value} (default)" do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) do
{ :env => 'production',
:is_puppet_master => value,
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['true',true].each do |value|
context "with is_puppet_master set to #{value}" do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) do
{ :env => 'production',
:is_puppet_master => value,
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'content' => nil,
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should_not contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should_not contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should_not contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
end
+ describe 'with run_interval' do
+ ['29','30',30,'45',56].each do |value|
+ context "set to #{value}" do
+ let(:facts) do
+ {
+ :osfamily => 'RedHat',
+ :fqdn => 'agent.learnpuppet.com',
+ }
+ end
+ let(:params) do
+ {
+ :run_method => 'cron',
+ :run_interval => value,
+ :env => 'production',
+ }
+ end
+
+ # Values here are from trial and error based on the fqdn above. Not
+ # sure if it is possible to stub fqdn_rand()
+ if value.to_s > '30'
+ it {
+ should contain_cron('puppet_agent').with({
+ 'ensure' => 'present',
+ 'minute' => 39,
+ })
+ }
+ else
+ it {
+ should contain_cron('puppet_agent').with({
+ 'ensure' => 'present',
+ 'minute' => ['7', 37],
+ })
+ }
+ end
+ end
+ end
+
+ [true,false,{ 'k' => 'v'},['1','2']].each do |value|
+ context "set to invalid value #{value}" do
+ let(:facts) do
+ {
+ :osfamily => 'RedHat',
+ :fqdn => 'agent.learnpuppet.com',
+ }
+ end
+ let(:params) do
+ {
+ :run_method => 'cron',
+ :run_interval => value,
+ :env => 'production',
+ }
+ end
+
+ it 'should fail' do
+ expect {
+ should contain_class('puppet::agent')
+ }.to raise_error(Puppet::Error)
+ end
+ end
+ end
+ end
+
describe 'with stringify_facts' do
['true',true].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['false',false].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = false$/) }
end
end
context 'set to an invalid setting' do
let(:params) do
{
:stringify_facts => 'invalid',
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
end
describe 'sysconfig file' do
context 'Puppet agent sysconfig file on osfamily RedHat' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Debian',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on Ubuntu' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Solaris' do
let(:facts) { { :osfamily => 'Solaris' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should_not contain_file('puppet_agent_sysconfig') }
end
context 'Puppet agent sysconfig file on osfamily Suse' do
let(:facts) { { :osfamily => 'Suse' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on invalid osfamily' do
let(:facts) { { :osfamily => 'invalid' } }
let(:params) { { :env => 'production' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <invalid>./)
end
end
end
describe 'with symlink_puppet_binary' do
['true',true].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/usr/local/bin/puppet',
'target' => '/usr/bin/puppet',
'ensure' => 'link',
})
}
end
end
['false',false].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it { should_not contain_file('puppet_symlink') }
end
end
context 'enabled with all params specified' do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => '/bar',
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/bar',
'target' => '/foo/bar',
'ensure' => 'link',
})
}
end
context 'enabled with invalid puppet_binary' do
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => 'true',
:symlink_puppet_binary_target => '/bar' } }
it do
expect { should }.to raise_error(Puppet::Error)
end
end
context 'enabled with invalid symlink_puppet_binary_target' do
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => 'undef' } }
it do
expect { should }.to raise_error(Puppet::Error)
end
end
end
describe 'with run_method' do
context 'set to disable' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'disable',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => false,
})
}
end
context 'set to service' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'service',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => true,
})
}
end
context 'set to cron' do
context 'with run_in_noop set to non-string and non-boolean' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => ['invalid_type','not_a_string','not_a_boolean'],
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
context 'with run_in_noop set to invalid string' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => 'invalid_string',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
# iterate through a matrix of setting true and false as booleans and
# strings for both run_in_noop and run_at_boot.
['true',true,'false',false].each do |rin_value|
context "with run_in_noop => #{rin_value}" do
['true',true,'false',false].each do |rab_value|
context "and run_at_boot => #{rab_value}" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => rin_value,
:run_at_boot => rab_value,
}
end
if rin_value == true or rin_value == 'true' then
command = "#{cron_command} --noop"
else
command = cron_command
end
if rab_value == true or rab_value == 'true' then
at_boot_ensure = 'present'
else
at_boot_ensure = 'absent'
end
it { should contain_class('puppet::agent') }
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'user' => 'root',
'command' => command,
})
}
it { should contain_cron('puppet_agent_once_at_boot').with({
'ensure' => at_boot_ensure,
'user' => 'root',
'command' => command,
'special' => 'reboot',
})
}
end
end
end
end
end
end
describe 'with puppet_masterport' do
context 'set to integer' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => '8888',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with_content(/^\s*masterport = 8888$/) }
end
context 'set to a string that is not an integer (foo)' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => 'foo',
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::puppet_masterport is set to <foo>. It should be an integer./)
end
end
context 'set to an invalid type (non-string)' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => ['invalid','type'],
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
end
describe 'with etckeeper_hooks' do
['true',true].each do |value|
context "set to #{value}" do
let(:params) do
{
:etckeeper_hooks => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('etckeeper_pre') }
it { should contain_file('etckeeper_post') }
it { should contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
it { should contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
end
['false',false].each do |value|
context "set to #{value}" do
let(:params) do
{
:etckeeper_hooks => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should_not contain_file('etckeeper_pre') }
it { should_not contain_file('etckeeper_post') }
it { should_not contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
it { should_not contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
end
context 'set to an invalid setting' do
let(:params) do
{
:etckeeper_hooks => 'invalid',
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
end
describe 'with http_proxy_host' do
context 'set to a valid domain' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_host => 'proxy.host.local.domain',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it {should contain_file('puppet_config').with_content(/^\s*http_proxy_host = proxy\.host\.local\.domain$/) }
end
['8.8.8.8','2a00:1450:400f:804::1011'].each do |ip_address|
context "set to #{ip_address} (ip-address)" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :env => 'production',
:http_proxy_host => ip_address,
}
end
it { should contain_file('puppet_config').with_content(/\s*http_proxy_host = #{Regexp.escape(ip_address)}$/) }
end
end
['8.8.8.8.#','".#.%.!','foo..bar'].each do |invalid_value|
context "set to #{invalid_value} (invalid value)" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :env => 'production',
:http_proxy_host => invalid_value,
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::http_proxy_host is set to <#{Regexp.escape(invalid_value)}>. It should be a fqdn or an ip-address./)
end
end
end
context 'set to an invalid type' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_host => ['invalid','type'],
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
end
describe 'with http_proxy_port' do
context 'set to integer' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :http_proxy_port => '8888',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
|
ghoneycutt/puppet-module-puppet
|
66070451583a5392578f475f4e7db2a238f5ae22
|
Release v2.14.1 - Bugfix puppet masters with symlink for reportdir
|
diff --git a/Modulefile b/Modulefile
index 3741032..cc06fa5 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,17 +1,17 @@
name 'ghoneycutt-puppet'
-version '2.14.0'
+version '2.14.1'
source 'git://github.com/ghoneycutt/puppet-module-puppet.git'
author 'ghoneycutt'
-license 'Apache License, Version 2.0'
+license 'Apache-2.0'
summary 'Manage Puppet'
description 'Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.'
project_page 'https://github.com/ghoneycutt/puppet-module-puppet'
dependency 'ghoneycutt/common', '>= 1.0.3'
dependency 'leinaddm/htpasswd', '>= 0.0.1'
dependency 'puppetlabs/stdlib', '>= 3.2.0'
dependency 'puppetlabs/mysql', '>= 2.0.0'
dependency 'puppetlabs/passenger', '>= 0.0.4'
dependency 'puppetlabs/apache', '>= 0.5.0'
dependency 'puppetlabs/firewall', '>= 0.2.1'
dependency 'puppetlabs/concat', '>= 1.0.0'
diff --git a/metadata.json b/metadata.json
index 2cbcaba..adb598f 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.14.0",
+ "version": "2.14.1",
"author": "ghoneycutt",
"summary": "Manage Puppet",
- "license": "Apache License, Version 2.0",
+ "license": "Apache-2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
965b26f0a69d2136d30600612a03b1b4f4a1b004
|
Follow symlink for reportdir
|
diff --git a/README.md b/README.md
index eab22c6..3950c3a 100644
--- a/README.md
+++ b/README.md
@@ -202,531 +202,531 @@ The location of puppet agent sysconfig file.
- *Default*: use defaults based on osfamily
agent_sysconfig_ensure
----------------------
String for 'file' or 'present'. Allows you to not manage the sysconfig file.
- *Default*: use defaults based on osfamily
daemon_name
-----------
The name the puppet agent daemon should run as.
- *Default*: puppet
stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
- *Default*: true
etckeeper_hooks
---------------
Boolean to include pre- and postrun hooks for etckeeper in the main section of the puppet agent's config.
- *Default*: false
===
## Class `puppet::dashboard` ##
### Parameters ###
dashboard_package
-----------------
String or Array of the dashboard package(s) name.
- *Default*: 'puppet-dashboard'
dashboard_user
--------------
The user for dashboard installation.
- *Default*: use defaults based on osfamily
dashboard_group
--------------
The group for dashboard installation.
- *Default*: use defaults based on osfamily
sysconfig_path
-------------------
The location of puppet dashboard sysconfig file.
- *Default*: use defaults based on osfamily
external_node_script_path
-------------------------
The script to call from puppet to get manifests from dashboard.
- *Default*: /usr/share/puppet-dashboard/bin/external_node
dashboard_fqdn
--------------
The dashboard server FQDN.
- *Default*: puppet.${::domain}
port
----
The port the web server will respond to.
- *Default*: 3000
manage_mysql_options
--------------------
Boolean to use modules default mysql::server settings (mysql_max_packet_size).
For specific mysql::server settings you can use hiera now:
<pre>
puppet::dashboard::server::manage_mysql_options: false
mysql::server::override_options:
mysqld:
max_allowed_packet: '32M'
innodb_buffer_pool_size: '64M'
</pre>
- *Default*: true
===
## Class `puppet::dashboard::server` ##
### Usage ###
You can optionally specify a hash of htpasswd entries in Hiera.
<pre>
---
puppet::dashboard::htpasswd:
admin:
cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
puppet:
cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
</pre>
### Parameters ###
dashboard_workers
-----------------
Number of dashboard workers to start. Only used on osfamily Debian.
- *Default*: $::processorcount
database_config_path
--------------------
The path to the database config file.
- *Default*: /usr/share/puppet-dashboard/config/database.yml
database_config_owner
---------------------
The owner of the database config file.
- *Default*: puppet-dashboard
database_config_group
---------------------
The database config file group.
- *Default*: puppet-dashboard
database_config_mode
--------------------
The database config file mode.
- *Default*: 0640
htpasswd
--------
Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
- *Default*: undef
htpasswd_path
-------------
String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
- *Default*: `/etc/puppet/dashboard.htpasswd`
htpasswd_owner
--------------
Owner of htpasswd file.
- *Default*: root
htpasswd_group
--------------
Group of htpasswd file.
- *Default*: use defaults based on osfamily
htpasswd_mode
-------------
Mode of htpasswd file.
- *Default*: 0640
log_dir
-------
The location for the puppet log files.
- *Default*: /var/log/puppet
mysql_user
----------
The user for the mysql connection.
- *Default*: dashboard
mysql_password
--------------
The password for the mysql connection.
- *Default*: puppet
mysql_max_packet_size
---------------------
The mysql max packet size.
- *Default*: 32M
security
--------
String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
- *Default*: 'none'
vhost_path
----------
The location of puppet dashboard vhost file for apache.
- *Default*: use defaults based on osfamily
===
## Class `puppet::dashboard::maintenance` ##
### Parameters ###
db_optimization_command
-----------------------
The command to run to optimize the db.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
db_optimization_user
--------------------
The user to run db optimization.
- *Default*: root
db_optimization_hour
--------------------
The hour on which to run db optimization.
- *Default*: 0
db_optimization_minute
----------------------
The minute at which to run db optimization.
- *Default*: 0
db_optimization_monthday
------------------------
The day of the month on which to run db optimization.
- *Default*: 1
reports_days_to_keep
--------------------
How many days to keep the reports.
- *Default*: 30
purge_old_reports_command
-------------------------
Which command to run to purge old reports.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=30 unit=day >> /var/log/puppet/dashboard_maintenance.log
purge_old_reports_user
----------------------
User to purge reports as.
- *Default*: root
purge_old_reports_hour
----------------------
On which hour to purge old reports.
- *Default*: 0
purge_old_reports_minute
------------------------
At which minute to purge old reports.
- *Default*: 30
remove_old_reports_spool
------------------------
Whether we should remove old dashboard reports that have not been imported
- *Default*: 'True'
reports_spool_dir
-----------------
Path to reports in dashboard spool
- *Default*: '/usr/share/puppet-dashboard/spool'
reports_spool_days_to_keep
--------------------------
How many days to keep the unimported reports.
remove_reports_spool_user
-------------------------
User to remove unimported reports.
- *Default*: root
remove_reports_spool_hour
-------------------------
On which hour to remove unimported reports.
- *Default*: 0
remove_reports_spool_minute
---------------------------
At which minute to remove unimported reports
- *Default*: 45
dump_dir
--------
The directory to use for dumps.
- *Default*: /var/local
dump_database_command
---------------------
The command to run to dump the database.
- *Default*: sudo -u puppet-dashboard /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log
dump_database_user
------------------
User to dump database as.
- *Default*: root
dump_database_hour
------------------
On which hour to dump database.
- *Default*: 1
dump_database_minute
--------------------
At which minute to purge old reports.
- *Default*: 0
days_to_keep_backups
--------------------
Number of days to keep database backups.
- *Default*: 7
purge_old_db_backups_user
-------------------------
User to purge old database dumps as.
- *Default*: root
purge_old_db_backups_hour
-------------------------
On which hour to purge old database dumps.
- *Default*: 2
purge_old_db_backups_minute
---------------------------
At which minute to purge old database dumps.
- *Default*: 0
===
## Class `puppet::lint` ##
### Parameters ###
ensure
------
Whether to install lint.
- *Default*: present
provider
--------
Which provider should supply lint.
- *Default*: gem
version
-------
If you do not want to use the default version of lint, specify which version you want to use here.
- *Default*: undef
lint_args
---------
Which args should be added to the .puppet-lint.rc file
- *Default*: --no-80chars-check
lintrc_path
-----------
The full path to the lint config file.
- *Default*: ${::root_home}/.puppet-lint.rc
lintrc_owner
------------
The owner of the lint config file.
- *Default*: root
lintrc_group
------------
The group of the lint config file.
- *Default*: root
lintrc_mode
-----------
The mode of the lint config file.
- *Default*: 0644
===
## Class `puppet::master` ##
### Usage ###
In Hiera you will need to specify the following.
<pre>
puppet::agent::is_puppet_master: 'true'
</pre>
### Parameters ###
sysconfig_path
--------------
The location of puppet master sysconfig file.
- *Default*: use defaults based on osfamily
vhost_path
----------
The location of puppet master vhost file for apache.
- *Default*: use defaults based on osfamily
rack_dir
--------
The rack directory path.
- *Default*: /usr/share/puppet/rack/puppetmasterd
puppet_user
-----------
The user the puppet master should run as.
- *Default*: puppet
manage_firewall
---------------
Whether to manage the firewall settings on the client
- *Default*: undef
===
## Class `puppet::master::maintenance` ##
### Parameters ###
clientbucket_path
-----------------
Path to where the clientbucket files are stored.
- *Default*: /var/lib/puppet/clientbucket
clientbucket_days_to_keep
-------------------------
The number of days to keep clientbuckets
- *Default*: 30
filebucket_cleanup_command
--------------------------
Command used to cleanup the clientbuckets.
- *Default*: /usr/bin/find ${clientbucket_path} -type f -mtime +30 -exec /bin/rm -fr {} \;
filebucket_cleanup_user
-----------------------
User to run the clientbucket cleanup as.
- *Default*: root
filebucket_cleanup_hour
-----------------------
Hour on which to run the filebucket cleanup.
- *Default*: 0
filebucket_cleanup_minute
-------------------------
Minute at which to run the filebucket cleanup.
- *Default*: 0
reportdir
---------
Directory that holds the reports. `$::puppet_reportdir` is a custom fact that reads the `reportdir` setting from Puppet's configuration. This is likely `/var/lib/puppet/reports/`.
- *Default*: $::puppet_reportdir
reportdir_days_to_key
---------------------
String for number of days of reports to keep. Must be a positive integer > 0.
- *Default*: '30'
reportdir_purge_command
-----------------------
Command ran by cron to purge old reports.
-- *Default*: /usr/bin/find /var/lib/puppet/reports/ -type f -mtime +30 -exec /bin/rm -fr {} \;'
+- *Default*: /usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;'
reportdir_purge_user
--------------------
User for the crontab entry to run the reportdir_purge_command.
- *Default*: root
reportdir_purge_hour
--------------------
Hour at which to run the reportdir_purge_command.
- *Default*: 0
reportdir_purge_minute
----------------------
Minute past the hour in which to run the reportdir_purge_command.
- *Default*: 15
diff --git a/manifests/master/maintenance.pp b/manifests/master/maintenance.pp
index 91ab7ed..28f890b 100755
--- a/manifests/master/maintenance.pp
+++ b/manifests/master/maintenance.pp
@@ -1,53 +1,53 @@
# == Class: puppet::master::maintenance
#
class puppet::master::maintenance (
$clientbucket_path = '/var/lib/puppet/clientbucket/',
$clientbucket_days_to_keep = '30',
$filebucket_cleanup_command = '/usr/bin/find /var/lib/puppet/clientbucket/ -type f -mtime +30 -exec /bin/rm -fr {} \;',
$filebucket_cleanup_user = 'root',
$filebucket_cleanup_hour = '0',
$filebucket_cleanup_minute = '0',
$reportdir = $::puppet_reportdir,
$reportdir_days_to_keep = '30',
- $reportdir_purge_command = '/usr/bin/find /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ $reportdir_purge_command = '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
$reportdir_purge_user = 'root',
$reportdir_purge_hour = '0',
$reportdir_purge_minute = '15',
) {
validate_absolute_path($reportdir)
# if not using the defaults, then construct the command with variables, else
# use the default command
if ( $clientbucket_days_to_keep != 30 ) or ( $clientbucket_path != '/var/lib/puppet/clientbucket/' ) {
$my_filebucket_cleanup_command = "/usr/bin/find ${clientbucket_path} -type f -mtime +${clientbucket_days_to_keep} -exec /bin/rm -fr {} \\;"
} else {
$my_filebucket_cleanup_command = $filebucket_cleanup_command
}
cron { 'filebucket_cleanup':
ensure => present,
command => $my_filebucket_cleanup_command,
user => $filebucket_cleanup_user,
hour => $filebucket_cleanup_hour,
minute => $filebucket_cleanup_minute,
}
if $reportdir_days_to_keep <= '0' {
fail("puppet::master::maintenance::reportdir_days_to_keep must be a positive integer greater than zero. Detected value is <${reportdir_days_to_keep}>.")
}
if ( $reportdir_days_to_keep != 30 ) or ( $reportdir != '/var/lib/puppet/reports' ) {
- $my_reportdir_purge_command = "/usr/bin/find ${reportdir} -type f -mtime +${reportdir_days_to_keep} -exec /bin/rm -fr {} \\;"
+ $my_reportdir_purge_command = "/usr/bin/find -L ${reportdir} -type f -mtime +${reportdir_days_to_keep} -exec /bin/rm -fr {} \\;"
} else {
$my_reportdir_purge_command = $reportdir_purge_command
}
cron { 'purge_old_puppet_reports':
ensure => present,
command => $my_reportdir_purge_command,
user => $reportdir_purge_user,
hour => $reportdir_purge_hour,
minute => $reportdir_purge_minute,
}
}
diff --git a/spec/classes/master_maintenance_spec.rb b/spec/classes/master_maintenance_spec.rb
index d9a48ef..cccaafc 100644
--- a/spec/classes/master_maintenance_spec.rb
+++ b/spec/classes/master_maintenance_spec.rb
@@ -1,173 +1,173 @@
require 'spec_helper'
describe 'puppet::master::maintenance' do
describe 'class puppet::master::maintenance' do
context 'Puppetmaster maintenance cron' do
let(:facts) { { :puppet_reportdir => '/var/lib/puppet/reports' } }
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('filebucket_cleanup').with({
'user' => 'root',
'hour' => '0',
'minute' => '0',
})
}
end
end
describe 'purge reportdir' do
context 'with default settings for params' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
- 'command' => '/usr/bin/find /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ 'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
context 'with reportdir_purge_user, reportdir_purge_hour, and reportdir_purge_minute set' do
let(:params) do
{ :reportdir_purge_user => 'gh',
:reportdir_purge_hour => '23',
:reportdir_purge_minute => '42',
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
- 'command' => '/usr/bin/find /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ 'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'gh',
'hour' => '23',
'minute' => '42',
})
}
end
describe 'with reportdir_days_to_keep specified' do
context 'as a valid integer greater than zero' do
let(:params) { { :reportdir_days_to_keep => '42' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
- 'command' => '/usr/bin/find /var/lib/puppet/reports -type f -mtime +42 -exec /bin/rm -fr {} \;',
+ 'command' => '/usr/bin/find -L /var/lib/puppet/reports -type f -mtime +42 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
['0','-23'].each do |value|
context "as #{value}" do
let(:params) { { :reportdir_days_to_keep => value } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it do
expect {
should contain_class('puppet::master::maintenance')
}.to raise_error(Puppet::Error,/puppet::master::maintenance::reportdir_days_to_keep must be a positive integer greater than zero. Detected value is <#{value}>./)
end
end
end
end
describe 'with reportdir specified' do
context 'as a valid directory' do
let(:params) { { :reportdir => '/etc/puppet/reports' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
- 'command' => '/usr/bin/find /etc/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
+ 'command' => '/usr/bin/find -L /etc/puppet/reports -type f -mtime +30 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
context 'as an invalid directory' do
let(:params) { { :reportdir => 'invalid/path' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it do
expect {
should contain_class('puppet::master::maintenance')
}.to raise_error(Puppet::Error)
end
end
end
context 'with reportdir and reportdir_days_to_keep specified' do
let(:params) do
{ :reportdir => '/etc/puppet/reports',
:reportdir_days_to_keep => '42',
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:puppet_reportdir => '/var/lib/puppet/reports',
}
end
it { should contain_class('puppet::master::maintenance') }
it { should contain_cron('purge_old_puppet_reports').with({
'ensure' => 'present',
- 'command' => '/usr/bin/find /etc/puppet/reports -type f -mtime +42 -exec /bin/rm -fr {} \;',
+ 'command' => '/usr/bin/find -L /etc/puppet/reports -type f -mtime +42 -exec /bin/rm -fr {} \;',
'user' => 'root',
'hour' => '0',
'minute' => '15',
})
}
end
end
end
|
ghoneycutt/puppet-module-puppet
|
195bb42d2f72884106c2672e69a77cda7049d809
|
Support run_interval larger than 30
|
diff --git a/manifests/agent.pp b/manifests/agent.pp
index d3c0c95..d4bea78 100755
--- a/manifests/agent.pp
+++ b/manifests/agent.pp
@@ -1,257 +1,262 @@
# == Class: puppet::agent
#
# Manage Puppet agents
#
# We also run puppet once at boot via cron, regardless of if you normally run
# puppet from cron or as a daemon.
#
class puppet::agent (
$certname = $::fqdn,
$config_path = '/etc/puppet/puppet.conf',
$config_owner = 'root',
$config_group = 'root',
$config_mode = '0644',
$env = $::env,
$puppet_server = 'puppet',
$puppet_masterport = 'UNSET',
$puppet_ca_server = 'UNSET',
$http_proxy_host = 'UNSET',
$http_proxy_port = 'UNSET',
$is_puppet_master = false,
$run_method = 'service',
$run_interval = '30',
$run_in_noop = false,
$cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay',
$run_at_boot = true,
$puppet_binary = '/usr/bin/puppet',
$symlink_puppet_binary_target = '/usr/local/bin/puppet',
$symlink_puppet_binary = false,
$agent_sysconfig = 'USE_DEFAULTS',
$agent_sysconfig_ensure = 'USE_DEFAULTS',
$daemon_name = 'puppet',
$stringify_facts = true,
$etckeeper_hooks = false,
) {
if type($run_in_noop) == 'String' {
$run_in_noop_bool = str2bool($run_in_noop)
} else {
$run_in_noop_bool = $run_in_noop
}
validate_bool($run_in_noop_bool)
if type($run_at_boot) == 'String' {
$run_at_boot_bool = str2bool($run_at_boot)
} else {
$run_at_boot_bool = $run_at_boot
}
validate_bool($run_at_boot_bool)
if type($is_puppet_master) == 'String' {
$is_puppet_master_bool = str2bool($is_puppet_master)
} else {
$is_puppet_master_bool = $is_puppet_master
}
validate_bool($is_puppet_master_bool)
# env must be set, else fail, since we use it in the puppet_config template
if ! $env {
fail('puppet::agent::env must be set')
}
if $puppet_masterport != 'UNSET' and is_integer($puppet_masterport) == false {
fail("puppet::agent::puppet_masterport is set to <${puppet_masterport}>. It should be an integer.")
}
if type($stringify_facts) == 'string' {
$stringify_facts_bool = str2bool($stringify_facts)
} else {
$stringify_facts_bool = $stringify_facts
}
validate_bool($stringify_facts_bool)
if type($etckeeper_hooks) == 'String' {
$etckeeper_hooks_bool = str2bool($etckeeper_hooks)
} else {
$etckeeper_hooks_bool = $etckeeper_hooks
}
validate_bool($etckeeper_hooks_bool)
if $http_proxy_host != 'UNSET' and (is_domain_name($http_proxy_host) == false and is_ip_address($http_proxy_host) == false){
fail("puppet::agent::http_proxy_host is set to <${http_proxy_host}>. It should be a fqdn or an ip-address.")
}
if $http_proxy_port != 'UNSET' and is_integer($http_proxy_port) == false {
fail("puppet::agent::http_proxy_port is set to <${http_proxy_port}>. It should be an Integer.")
}
case $::osfamily {
'Debian': {
$default_agent_sysconfig = '/etc/default/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'RedHat': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'Solaris': {
$default_agent_sysconfig = undef
$default_agent_sysconfig_ensure = 'absent'
}
'Suse': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
default: {
fail("puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <${::osfamily}>.")
}
}
if $agent_sysconfig == 'USE_DEFAULTS' {
$agent_sysconfig_real = $default_agent_sysconfig
} else {
$agent_sysconfig_real = $agent_sysconfig
}
if $agent_sysconfig_ensure == 'USE_DEFAULTS' {
$agent_sysconfig_ensure_real = $default_agent_sysconfig_ensure
} else {
$agent_sysconfig_ensure_real = $agent_sysconfig_ensure
}
if $is_puppet_master_bool == false {
$config_content = template('puppet/puppetagent.conf.erb')
} else {
$config_content = undef
}
case $run_method {
'service': {
$daemon_ensure = 'running'
$daemon_enable = true
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
'cron': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_run_one = fqdn_rand($run_interval)
$cron_run_two = fqdn_rand($run_interval) + 30
$cron_ensure = 'present'
$cron_user = 'root'
$cron_hour = '*'
- $cron_minute = [$cron_run_one, $cron_run_two]
+
+ if $run_interval > 30 {
+ $cron_minute = $cron_run_one
+ } else {
+ $cron_minute = [$cron_run_one, $cron_run_two]
+ }
if $run_in_noop_bool == true {
$my_cron_command = "${cron_command} --noop"
} else {
$my_cron_command = $cron_command
}
}
'disable': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
default: {
fail("puppet::agent::run_method is ${run_method} and must be 'disable', 'service' or 'cron'.")
}
}
if $run_at_boot_bool == true {
$at_boot_ensure = 'present'
} else {
$at_boot_ensure = 'absent'
}
if type($symlink_puppet_binary) == 'string' {
$symlink_puppet_binary_bool = str2bool($symlink_puppet_binary)
} else {
$symlink_puppet_binary_bool = $symlink_puppet_binary
}
validate_bool($symlink_puppet_binary_bool)
# optionally create symlinks to puppet binary
if $symlink_puppet_binary_bool == true {
# validate params
validate_absolute_path($symlink_puppet_binary_target)
validate_absolute_path($puppet_binary)
file { 'puppet_symlink':
ensure => link,
path => $symlink_puppet_binary_target,
target => $puppet_binary,
}
}
file { 'puppet_config':
path => $config_path,
content => $config_content,
owner => $config_owner,
group => $config_group,
mode => $config_mode,
}
if ($etckeeper_hooks_bool) {
file { 'etckeeper_pre':
path => '/etc/puppet/etckeeper-commit-pre',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/puppet/etckeeper-commit-pre'
}
file { 'etckeeper_post':
path => '/etc/puppet/etckeeper-commit-post',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/puppet/etckeeper-commit-post'
}
}
if $default_agent_sysconfig_ensure =~ /(present)|(file)/ {
file { 'puppet_agent_sysconfig':
ensure => $agent_sysconfig_ensure_real,
path => $agent_sysconfig_real,
content => template('puppet/agent_sysconfig.erb'),
owner => 'root',
group => 'root',
mode => '0644',
}
}
service { 'puppet_agent_daemon':
# GH: This service will always show as being running while an agent run is
# taking place, so we no longer ensure its status. Before doing this, there
# would *always* be a logged change and the Console could never be green.
#ensure => $daemon_ensure,
name => $daemon_name,
enable => $daemon_enable,
}
cron { 'puppet_agent':
ensure => $cron_ensure,
command => $my_cron_command,
user => $cron_user,
hour => $cron_hour,
minute => $cron_minute,
}
if $run_method == 'cron' {
cron { 'puppet_agent_once_at_boot':
ensure => $at_boot_ensure,
command => $my_cron_command,
user => $cron_user,
special => 'reboot',
}
}
}
|
ghoneycutt/puppet-module-puppet
|
be6691c1fca7078f9b41f018c36cc44f7d716eb8
|
Release v2.14.0 - control include vs param class for Dashboard server
|
diff --git a/Modulefile b/Modulefile
index da82a58..3741032 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,17 +1,17 @@
name 'ghoneycutt-puppet'
-version '2.13.1'
+version '2.14.0'
source 'git://github.com/ghoneycutt/puppet-module-puppet.git'
author 'ghoneycutt'
license 'Apache License, Version 2.0'
summary 'Manage Puppet'
description 'Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.'
project_page 'https://github.com/ghoneycutt/puppet-module-puppet'
dependency 'ghoneycutt/common', '>= 1.0.3'
dependency 'leinaddm/htpasswd', '>= 0.0.1'
dependency 'puppetlabs/stdlib', '>= 3.2.0'
dependency 'puppetlabs/mysql', '>= 2.0.0'
dependency 'puppetlabs/passenger', '>= 0.0.4'
dependency 'puppetlabs/apache', '>= 0.5.0'
dependency 'puppetlabs/firewall', '>= 0.2.1'
dependency 'puppetlabs/concat', '>= 1.0.0'
diff --git a/metadata.json b/metadata.json
index f573e98..2cbcaba 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.13.1",
+ "version": "2.14.0",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"license": "Apache License, Version 2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
d8c7b717215c447bace71f4d632105ee98e00acb
|
Style - Fix indentation of attribute arrows
|
diff --git a/manifests/agent.pp b/manifests/agent.pp
index c4be663..d3c0c95 100755
--- a/manifests/agent.pp
+++ b/manifests/agent.pp
@@ -1,257 +1,257 @@
# == Class: puppet::agent
#
# Manage Puppet agents
#
# We also run puppet once at boot via cron, regardless of if you normally run
# puppet from cron or as a daemon.
#
class puppet::agent (
$certname = $::fqdn,
$config_path = '/etc/puppet/puppet.conf',
$config_owner = 'root',
$config_group = 'root',
$config_mode = '0644',
$env = $::env,
$puppet_server = 'puppet',
$puppet_masterport = 'UNSET',
$puppet_ca_server = 'UNSET',
$http_proxy_host = 'UNSET',
$http_proxy_port = 'UNSET',
$is_puppet_master = false,
$run_method = 'service',
$run_interval = '30',
$run_in_noop = false,
$cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay',
$run_at_boot = true,
$puppet_binary = '/usr/bin/puppet',
$symlink_puppet_binary_target = '/usr/local/bin/puppet',
$symlink_puppet_binary = false,
$agent_sysconfig = 'USE_DEFAULTS',
$agent_sysconfig_ensure = 'USE_DEFAULTS',
$daemon_name = 'puppet',
$stringify_facts = true,
$etckeeper_hooks = false,
) {
if type($run_in_noop) == 'String' {
$run_in_noop_bool = str2bool($run_in_noop)
} else {
$run_in_noop_bool = $run_in_noop
}
validate_bool($run_in_noop_bool)
if type($run_at_boot) == 'String' {
$run_at_boot_bool = str2bool($run_at_boot)
} else {
$run_at_boot_bool = $run_at_boot
}
validate_bool($run_at_boot_bool)
if type($is_puppet_master) == 'String' {
$is_puppet_master_bool = str2bool($is_puppet_master)
} else {
$is_puppet_master_bool = $is_puppet_master
}
validate_bool($is_puppet_master_bool)
# env must be set, else fail, since we use it in the puppet_config template
if ! $env {
fail('puppet::agent::env must be set')
}
if $puppet_masterport != 'UNSET' and is_integer($puppet_masterport) == false {
fail("puppet::agent::puppet_masterport is set to <${puppet_masterport}>. It should be an integer.")
}
if type($stringify_facts) == 'string' {
$stringify_facts_bool = str2bool($stringify_facts)
} else {
$stringify_facts_bool = $stringify_facts
}
validate_bool($stringify_facts_bool)
if type($etckeeper_hooks) == 'String' {
$etckeeper_hooks_bool = str2bool($etckeeper_hooks)
} else {
$etckeeper_hooks_bool = $etckeeper_hooks
}
validate_bool($etckeeper_hooks_bool)
if $http_proxy_host != 'UNSET' and (is_domain_name($http_proxy_host) == false and is_ip_address($http_proxy_host) == false){
fail("puppet::agent::http_proxy_host is set to <${http_proxy_host}>. It should be a fqdn or an ip-address.")
}
if $http_proxy_port != 'UNSET' and is_integer($http_proxy_port) == false {
fail("puppet::agent::http_proxy_port is set to <${http_proxy_port}>. It should be an Integer.")
}
case $::osfamily {
'Debian': {
$default_agent_sysconfig = '/etc/default/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'RedHat': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'Solaris': {
$default_agent_sysconfig = undef
$default_agent_sysconfig_ensure = 'absent'
}
'Suse': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
default: {
fail("puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <${::osfamily}>.")
}
}
if $agent_sysconfig == 'USE_DEFAULTS' {
$agent_sysconfig_real = $default_agent_sysconfig
} else {
$agent_sysconfig_real = $agent_sysconfig
}
if $agent_sysconfig_ensure == 'USE_DEFAULTS' {
$agent_sysconfig_ensure_real = $default_agent_sysconfig_ensure
} else {
$agent_sysconfig_ensure_real = $agent_sysconfig_ensure
}
if $is_puppet_master_bool == false {
$config_content = template('puppet/puppetagent.conf.erb')
} else {
$config_content = undef
}
case $run_method {
'service': {
$daemon_ensure = 'running'
$daemon_enable = true
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
'cron': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_run_one = fqdn_rand($run_interval)
$cron_run_two = fqdn_rand($run_interval) + 30
$cron_ensure = 'present'
$cron_user = 'root'
$cron_hour = '*'
$cron_minute = [$cron_run_one, $cron_run_two]
if $run_in_noop_bool == true {
$my_cron_command = "${cron_command} --noop"
} else {
$my_cron_command = $cron_command
}
}
'disable': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
default: {
fail("puppet::agent::run_method is ${run_method} and must be 'disable', 'service' or 'cron'.")
}
}
if $run_at_boot_bool == true {
$at_boot_ensure = 'present'
} else {
$at_boot_ensure = 'absent'
}
if type($symlink_puppet_binary) == 'string' {
$symlink_puppet_binary_bool = str2bool($symlink_puppet_binary)
} else {
$symlink_puppet_binary_bool = $symlink_puppet_binary
}
validate_bool($symlink_puppet_binary_bool)
# optionally create symlinks to puppet binary
if $symlink_puppet_binary_bool == true {
# validate params
validate_absolute_path($symlink_puppet_binary_target)
validate_absolute_path($puppet_binary)
file { 'puppet_symlink':
ensure => link,
path => $symlink_puppet_binary_target,
target => $puppet_binary,
}
}
file { 'puppet_config':
path => $config_path,
content => $config_content,
owner => $config_owner,
group => $config_group,
mode => $config_mode,
}
if ($etckeeper_hooks_bool) {
file { 'etckeeper_pre':
path => '/etc/puppet/etckeeper-commit-pre',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/puppet/etckeeper-commit-pre'
}
file { 'etckeeper_post':
path => '/etc/puppet/etckeeper-commit-post',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/puppet/etckeeper-commit-post'
}
}
if $default_agent_sysconfig_ensure =~ /(present)|(file)/ {
file { 'puppet_agent_sysconfig':
ensure => $agent_sysconfig_ensure_real,
path => $agent_sysconfig_real,
content => template('puppet/agent_sysconfig.erb'),
owner => 'root',
group => 'root',
mode => '0644',
}
}
service { 'puppet_agent_daemon':
# GH: This service will always show as being running while an agent run is
# taking place, so we no longer ensure its status. Before doing this, there
# would *always* be a logged change and the Console could never be green.
- #ensure => $daemon_ensure,
- name => $daemon_name,
- enable => $daemon_enable,
+ #ensure => $daemon_ensure,
+ name => $daemon_name,
+ enable => $daemon_enable,
}
cron { 'puppet_agent':
ensure => $cron_ensure,
command => $my_cron_command,
user => $cron_user,
hour => $cron_hour,
minute => $cron_minute,
}
if $run_method == 'cron' {
cron { 'puppet_agent_once_at_boot':
ensure => $at_boot_ensure,
command => $my_cron_command,
user => $cron_user,
special => 'reboot',
}
}
}
diff --git a/manifests/dashboard.pp b/manifests/dashboard.pp
index e9bbcbf..2e19396 100644
--- a/manifests/dashboard.pp
+++ b/manifests/dashboard.pp
@@ -1,89 +1,89 @@
# == Class: puppet::dashboard
#
class puppet::dashboard (
$dashboard_package = 'puppet-dashboard',
$dashboard_user = 'USE_DEFAULTS',
$dashboard_group = 'USE_DEFAULTS',
$sysconfig_path = 'USE_DEFAULTS',
$external_node_script_path = '/usr/share/puppet-dashboard/bin/external_node',
$dashboard_fqdn = "puppet.${::domain}",
$port = '3000',
) {
validate_absolute_path($external_node_script_path)
if type($dashboard_package) != 'String' and type($dashboard_package) != 'Array' {
fail('puppet::dashboard::dashboard_package must be a string or an array.')
}
case $::osfamily {
'RedHat': {
$default_sysconfig_path = '/etc/sysconfig/puppet-dashboard'
$sysconfig_template = 'dashboard_sysconfig.erb'
$default_dashboard_user = 'puppet-dashboard'
$default_dashboard_group = 'puppet-dashboard'
}
'Debian': {
$default_sysconfig_path = '/etc/default/puppet-dashboard'
$sysconfig_template = 'dashboard_default.erb'
$default_dashboard_user = 'puppet'
$default_dashboard_group = 'puppet'
}
default: {
fail("puppet::dashboard supports osfamilies Debian and RedHat. Detected osfamily is <${::osfamily}>.")
}
}
if $sysconfig_path == 'USE_DEFAULTS' {
$sysconfig_path_real = $default_sysconfig_path
} else {
$sysconfig_path_real = $sysconfig_path
}
validate_absolute_path($sysconfig_path_real)
if $dashboard_user == 'USE_DEFAULTS' {
$dashboard_user_real = $default_dashboard_user
} else {
$dashboard_user_real = $dashboard_user
}
if $dashboard_group == 'USE_DEFAULTS' {
$dashboard_group_real = $default_dashboard_group
} else {
$dashboard_group_real = $dashboard_group
}
package { $dashboard_package:
ensure => present,
}
file { 'external_node_script':
ensure => file,
content => template('puppet/external_node.erb'),
path => $external_node_script_path,
owner => $dashboard_user_real,
group => $dashboard_group_real,
mode => '0755',
require => Package[$dashboard_package],
}
file { 'dashboard_sysconfig':
ensure => file,
path => $sysconfig_path_real,
content => template("puppet/${sysconfig_template}"),
owner => 'root',
group => 'root',
mode => '0644',
}
# Dashboard is ran under Passenger with Apache
service { 'puppet-dashboard':
ensure => stopped,
enable => false,
subscribe => File['dashboard_sysconfig'],
}
service { 'puppet-dashboard-workers':
- ensure => stopped,
- enable => false,
+ ensure => stopped,
+ enable => false,
}
}
|
ghoneycutt/puppet-module-puppet
|
163d94a702ca2a8f1020a5f801e508ea67202025
|
Appease ruby 1.8.7
|
diff --git a/spec/classes/dashboard_server_spec.rb b/spec/classes/dashboard_server_spec.rb
index 2a2d805..89c44de 100644
--- a/spec/classes/dashboard_server_spec.rb
+++ b/spec/classes/dashboard_server_spec.rb
@@ -1,523 +1,523 @@
require 'spec_helper'
describe 'puppet::dashboard::server' do
context 'with default dashboard_workers on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should_not contain_file('dashboard_workers_default') }
end
context 'with default dashboard_workers on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_workers_default').with({
'ensure' => 'file',
'path' => '/etc/default/puppet-dashboard-workers',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('dashboard_workers_default').with_content(/^START=yes$/) }
it { should contain_file('dashboard_workers_default').with_content(/^NUM_DELAYED_JOB_WORKERS=8$/) }
end
context 'with default dashboard_workers set to non-digit' do
let(:params) { { :dashboard_workers => '8invalid' } }
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:concat_basedir => '/tmp',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error,/puppet::dashboard::server::dashboard_workers must be a digit. Detected value is <8invalid>./)
end
end
context 'with default htpasswd path on osfamily RedHat' do
let(:params) do
{ :security => 'htpasswd',
:htpasswd => {
'gh' => {
'cryptpasswd' => 'password',
},
}
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_htpasswd_path').with({
'ensure' => 'file',
'path' => '/etc/puppet/dashboard.htpasswd',
'owner' => 'root',
'group' => 'apache',
'mode' => '0640',
})
}
end
context 'with default htpasswd path on osfamily Debian' do
let(:params) do
{ :security => 'htpasswd',
:htpasswd => {
'gh' => {
'cryptpasswd' => 'password',
},
}
}
end
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_htpasswd_path').with({
'ensure' => 'file',
'path' => '/etc/puppet/dashboard.htpasswd',
'owner' => 'root',
'group' => 'www-data',
'mode' => '0640',
})
}
end
context 'with htpasswd_path set by user' do
let(:params) do
{ :htpasswd_path => '/var/www/html/dashboard_passwd',
:security => 'htpasswd',
:htpasswd => {
'gh' => {
'cryptpasswd' => 'password',
},
}
}
end
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_htpasswd_path').with({
'ensure' => 'file',
'path' => '/var/www/html/dashboard_passwd',
'owner' => 'root',
'group' => 'www-data',
'mode' => '0640',
})
}
end
context 'with invalid value for htpasswd_path' do
let(:params) do
{ :htpasswd_path => 'not/a/valid/path',
:security => 'htpasswd',
:htpasswd => {
'gh' => {
'cryptpasswd' => 'password',
},
}
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error)
end
end
[false,'false'].each do |value|
context "with manage_mysql_options set to <#{value}>" do
let(:params) { { :manage_mysql_options => "#{value}" } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:processorcount => '8',
}
end
it { should contain_class('puppet::dashboard::server') }
- it { should contain_class('mysql::server').with('override_options' => {},) }
+ it { should contain_class('mysql::server').with({'override_options' => {},}) }
it { should_not contain_file('/etc/my.cnf').with_content(/^max_allowed_packet = 32M$/) }
end
end
[true,'true'].each do |value|
context "with manage_mysql_options set to <#{value}>" do
let(:params) { { :manage_mysql_options => "#{value}" } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:processorcount => '8',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('/etc/my.cnf').with_content(/^max_allowed_packet = 32M$/) }
it {
should contain_class('mysql::server').with({
'override_options' => {
'mysqld' => {
'max_allowed_packet' => '32M',
},
},
})
}
end
end
['invalid',[ 'dont', 'like', 'arrays', ], { 'nor' => 'hashes', }, ].each do |value|
context "with manage_mysql_options set to invalid value <#{value}>" do
let(:params) { { :manage_mysql_options => "#{value}" } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:processorcount => '8',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error)
end
end
end
describe 'Dashboard vhost configuration file content' do
context 'when vhost_path is invalid it should fail' do
let(:params) { { :vhost_path => 'not/a/valid/path' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error)
end
end
context 'when htpasswd_path is invalid it should fail' do
let(:params) { { :htpasswd_path => 'not/a/valid/path' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error)
end
end
context 'when security is invalid it should fail' do
let(:params) { { :security => 'invalid' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error,/Security is <invalid> which does not match regex. Valid values are none and htpasswd./)
end
end
context 'with default settings' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost').with_content(/^\s*ServerName puppet.example.com$/) }
end
context 'with security set to none' do
let(:params) { { :security => 'none' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost') }
it { should_not contain_file('dashboard_vhost').with_content(/(\s+|)AuthType(\s+)basic(\s*)/) }
end
context 'with security set to htpasswd' do
let(:params) { { :security => 'htpasswd' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost').with_content(/(\s+|)AuthType(\s+)basic(\s*)/) }
end
end
context 'with database configuration file on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('database_config').with({
'path' => '/usr/share/puppet-dashboard/config/database.yml',
'owner' => 'puppet-dashboard',
'group' => 'puppet-dashboard',
'mode' => '0640',
'require' => 'Package[puppet-dashboard]',
})
}
end
context 'with database configuration file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('database_config').with({
'path' => '/usr/share/puppet-dashboard/config/database.yml',
'owner' => 'puppet',
'group' => 'www-data',
'mode' => '0640',
'require' => 'Package[puppet-dashboard]',
})
}
end
context 'Dashboard database configuration file content' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('database_config').with_content(/^\s*username: dashboard$/) }
end
context 'Dashboard vhost configuration file on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost').with({
'ensure' => 'file',
'path' => '/etc/httpd/conf.d/dashboard.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
context 'Dashboard vhost configuration file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost').with({
'ensure' => 'file',
'path' => '/etc/apache2/sites-enabled/puppetdashboard',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
context 'Dashboard Mysql Database' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_mysql__db('dashboard').with({
'user' => 'dashboard',
'password' => 'puppet',
'host' => 'localhost',
})
}
end
context 'Dashboard database migration' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_exec('migrate_dashboard_database').with({
'command' => 'rake RAILS_ENV=production db:migrate',
'path' => '/bin:/usr/bin:/sbin:/usr/sbin',
'cwd' => '/usr/share/puppet-dashboard',
'refreshonly' => true,
})
}
end
context 'Dashboard workers service' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_service('puppet-dashboard-workers').with({
'ensure' => 'running',
'enable' => true,
})
}
end
end
|
ghoneycutt/puppet-module-puppet
|
200259a668e024131f2975a3211d3711448ca25d
|
Add tests for puppet::dashboard::server::manage_mysql_options
|
diff --git a/spec/classes/dashboard_server_spec.rb b/spec/classes/dashboard_server_spec.rb
index 9f2f2bf..2a2d805 100644
--- a/spec/classes/dashboard_server_spec.rb
+++ b/spec/classes/dashboard_server_spec.rb
@@ -1,509 +1,523 @@
require 'spec_helper'
describe 'puppet::dashboard::server' do
context 'with default dashboard_workers on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should_not contain_file('dashboard_workers_default') }
end
context 'with default dashboard_workers on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_workers_default').with({
'ensure' => 'file',
'path' => '/etc/default/puppet-dashboard-workers',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('dashboard_workers_default').with_content(/^START=yes$/) }
it { should contain_file('dashboard_workers_default').with_content(/^NUM_DELAYED_JOB_WORKERS=8$/) }
end
context 'with default dashboard_workers set to non-digit' do
let(:params) { { :dashboard_workers => '8invalid' } }
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:concat_basedir => '/tmp',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error,/puppet::dashboard::server::dashboard_workers must be a digit. Detected value is <8invalid>./)
end
end
context 'with default htpasswd path on osfamily RedHat' do
let(:params) do
{ :security => 'htpasswd',
:htpasswd => {
'gh' => {
'cryptpasswd' => 'password',
},
}
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_htpasswd_path').with({
'ensure' => 'file',
'path' => '/etc/puppet/dashboard.htpasswd',
'owner' => 'root',
'group' => 'apache',
'mode' => '0640',
})
}
end
context 'with default htpasswd path on osfamily Debian' do
let(:params) do
{ :security => 'htpasswd',
:htpasswd => {
'gh' => {
'cryptpasswd' => 'password',
},
}
}
end
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_htpasswd_path').with({
'ensure' => 'file',
'path' => '/etc/puppet/dashboard.htpasswd',
'owner' => 'root',
'group' => 'www-data',
'mode' => '0640',
})
}
end
context 'with htpasswd_path set by user' do
let(:params) do
{ :htpasswd_path => '/var/www/html/dashboard_passwd',
:security => 'htpasswd',
:htpasswd => {
'gh' => {
'cryptpasswd' => 'password',
},
}
}
end
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_htpasswd_path').with({
'ensure' => 'file',
'path' => '/var/www/html/dashboard_passwd',
'owner' => 'root',
'group' => 'www-data',
'mode' => '0640',
})
}
end
context 'with invalid value for htpasswd_path' do
let(:params) do
{ :htpasswd_path => 'not/a/valid/path',
:security => 'htpasswd',
:htpasswd => {
'gh' => {
'cryptpasswd' => 'password',
},
}
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error)
end
end
[false,'false'].each do |value|
context "with manage_mysql_options set to <#{value}>" do
let(:params) { { :manage_mysql_options => "#{value}" } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:processorcount => '8',
}
end
it { should contain_class('puppet::dashboard::server') }
- it { should contain_file('/etc/my.cnf').without_content(/^max_allowed_packet = 32M$/) }
+ it { should contain_class('mysql::server').with('override_options' => {},) }
+
+ it { should_not contain_file('/etc/my.cnf').with_content(/^max_allowed_packet = 32M$/) }
+
end
end
[true,'true'].each do |value|
context "with manage_mysql_options set to <#{value}>" do
let(:params) { { :manage_mysql_options => "#{value}" } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:processorcount => '8',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('/etc/my.cnf').with_content(/^max_allowed_packet = 32M$/) }
+
+ it {
+ should contain_class('mysql::server').with({
+ 'override_options' => {
+ 'mysqld' => {
+ 'max_allowed_packet' => '32M',
+ },
+ },
+ })
+ }
+
end
end
['invalid',[ 'dont', 'like', 'arrays', ], { 'nor' => 'hashes', }, ].each do |value|
context "with manage_mysql_options set to invalid value <#{value}>" do
let(:params) { { :manage_mysql_options => "#{value}" } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:processorcount => '8',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error)
end
end
end
describe 'Dashboard vhost configuration file content' do
context 'when vhost_path is invalid it should fail' do
let(:params) { { :vhost_path => 'not/a/valid/path' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error)
end
end
context 'when htpasswd_path is invalid it should fail' do
let(:params) { { :htpasswd_path => 'not/a/valid/path' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error)
end
end
context 'when security is invalid it should fail' do
let(:params) { { :security => 'invalid' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error,/Security is <invalid> which does not match regex. Valid values are none and htpasswd./)
end
end
context 'with default settings' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost').with_content(/^\s*ServerName puppet.example.com$/) }
end
context 'with security set to none' do
let(:params) { { :security => 'none' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost') }
it { should_not contain_file('dashboard_vhost').with_content(/(\s+|)AuthType(\s+)basic(\s*)/) }
end
context 'with security set to htpasswd' do
let(:params) { { :security => 'htpasswd' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost').with_content(/(\s+|)AuthType(\s+)basic(\s*)/) }
end
end
context 'with database configuration file on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('database_config').with({
'path' => '/usr/share/puppet-dashboard/config/database.yml',
'owner' => 'puppet-dashboard',
'group' => 'puppet-dashboard',
'mode' => '0640',
'require' => 'Package[puppet-dashboard]',
})
}
end
context 'with database configuration file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('database_config').with({
'path' => '/usr/share/puppet-dashboard/config/database.yml',
'owner' => 'puppet',
'group' => 'www-data',
'mode' => '0640',
'require' => 'Package[puppet-dashboard]',
})
}
end
context 'Dashboard database configuration file content' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('database_config').with_content(/^\s*username: dashboard$/) }
end
context 'Dashboard vhost configuration file on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost').with({
'ensure' => 'file',
'path' => '/etc/httpd/conf.d/dashboard.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
context 'Dashboard vhost configuration file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost').with({
'ensure' => 'file',
'path' => '/etc/apache2/sites-enabled/puppetdashboard',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
context 'Dashboard Mysql Database' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_mysql__db('dashboard').with({
'user' => 'dashboard',
'password' => 'puppet',
'host' => 'localhost',
})
}
end
context 'Dashboard database migration' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_exec('migrate_dashboard_database').with({
'command' => 'rake RAILS_ENV=production db:migrate',
'path' => '/bin:/usr/bin:/sbin:/usr/sbin',
'cwd' => '/usr/share/puppet-dashboard',
'refreshonly' => true,
})
}
end
context 'Dashboard workers service' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_service('puppet-dashboard-workers').with({
'ensure' => 'running',
'enable' => true,
})
}
end
end
|
ghoneycutt/puppet-module-puppet
|
1b903a1804d7acc34c1b6db628037a4989c3bbd4
|
add manage_mysql_options for flexible MySQL configuration
|
diff --git a/README.md b/README.md
index c24e569..eab22c6 100644
--- a/README.md
+++ b/README.md
@@ -1,718 +1,732 @@
# puppet-module-puppet #
===
[](https://travis-ci.org/ghoneycutt/puppet-module-puppet)
This module handles the various parts of puppet on a given machine.
Dependencies for this module are: apache, common, mysql and passenger
## Components ##
### Agent
---------
- Manages the puppet agent on a client
- Setup of configuration files
- Setup of service or crontask to run the agent periodically
- Ensure puppet agent is run at boottime
### Master
----------
- Manages apache with passenger
- Setup of config files needed to run master
- Calls the `puppet::lint` class
- Calls the `puppet::master::maintenance` class
- Manages firewall rule for puppet if needed
- Maintenance to purge filebucket and reports
### Dashboard
-------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This installation is used by puppet systems, that need access to the dashboard
### Dashboard Server
--------------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This is the actual server running the Dashboard
- Configures the Dashboard MySQL settings
- Creates database for puppet with mysql module
- Calls the `puppet::dashboard::maintenance` class
- Maintenance to clean up old reports, optimize database and dump database
- For the maintenance cron jobs, you should have the following line in your `/etc/sudoers` which is not managed with this module.
<pre>
Defaults:root !requiretty
</pre>
### Lint
--------
- Manages [puppet-lint](http://github.com/rodjek/puppet-lint)
## Compatibility ##
-------------------
Ruby versions 1.8.7, 1.9.3, and 2.0.0 on Puppet 3.x
### Puppet Master
-----------------
* Debian 6
* Debian 7
* EL 6
* Ubuntu 12.04 LTS
### Puppet Agent
----------------
* Debian 6
* Debian 7
* EL 6
* EL 7
* Solaris
* Suse 11
* Ubuntu 12.04 LTS
===
## Class `puppet::agent` ##
### Parameters ###
certname
--------
The certificate name for the client.
- *Default*: $::fqdn
config_path
-----------
The location of the puppet config file.
- *Default*: /etc/puppet/puppet.conf
config_owner
------------
The owner of the config file.
- *Default*: root
config_group
------------
The group for the config file.
- *Default*: root
config_mode
-----------
The mode for the config file.
- *Default*: 0644
env
---
The selected environment for the client.
- *Default*: $::env
puppet_server
-------------
The puppet server the client should connect to.
- *Default*: puppet
puppet_masterport
-----------------
The masterport setting in puppet.conf. By default this line is not set.
- *Default*: UNSET
puppet_ca_server
----------------
The puppet CA server the client should use
- *Default*: UNSET
http_proxy_host
---------------
The http-proxy the client should use
- *Default*: UNSET
http_proxy_port
----------------
The http-proxy port the client should use
- *Default*: UNSET
is_puppet_master
----------------
Whether the machine is a puppet master or not.
- *Default*: false
run_method
----------
Whether to run as a service or in cron mode. Valid values are `disable`, `cron`, and `service`. The value `disable` disables automatic puppet runs and assumes you are running as a service.
- *Default*: service
run_interval
------------
The interval with which the client should run (in minutes)
- *Default*: 30
run_in_noop
-----------
Whether the client should run in noop mode or not.
- *Default*: false
cron_command
------------
The command that should be added to the crontab (in cron mode)
- *Default*: /usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay
run_at_boot
-----------
Whether the client should run right after boot
- *Default*: true
puppet_binary
-------------
Path to puppet binary to create symlink from
- *Default*: '/usr/bin/puppet'
symlink_puppet_binary_target
----------------------------
Path to where the symlink should be created
- *Default*: '/usr/local/bin/puppet'
symlink_puppet_binary
---------------------
Boolean for ensuring a symlink for puppet_binary to symlink_puppet_binary_target. This is useful if you install puppet in a non-standard location that is not in your $PATH.
- *Default*: false
agent_sysconfig
---------------
The location of puppet agent sysconfig file.
- *Default*: use defaults based on osfamily
agent_sysconfig_ensure
----------------------
String for 'file' or 'present'. Allows you to not manage the sysconfig file.
- *Default*: use defaults based on osfamily
daemon_name
-----------
The name the puppet agent daemon should run as.
- *Default*: puppet
stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
- *Default*: true
etckeeper_hooks
---------------
Boolean to include pre- and postrun hooks for etckeeper in the main section of the puppet agent's config.
- *Default*: false
===
## Class `puppet::dashboard` ##
### Parameters ###
dashboard_package
-----------------
String or Array of the dashboard package(s) name.
- *Default*: 'puppet-dashboard'
dashboard_user
--------------
The user for dashboard installation.
- *Default*: use defaults based on osfamily
dashboard_group
--------------
The group for dashboard installation.
- *Default*: use defaults based on osfamily
sysconfig_path
-------------------
The location of puppet dashboard sysconfig file.
- *Default*: use defaults based on osfamily
external_node_script_path
-------------------------
The script to call from puppet to get manifests from dashboard.
- *Default*: /usr/share/puppet-dashboard/bin/external_node
dashboard_fqdn
--------------
The dashboard server FQDN.
- *Default*: puppet.${::domain}
port
----
The port the web server will respond to.
- *Default*: 3000
+manage_mysql_options
+--------------------
+Boolean to use modules default mysql::server settings (mysql_max_packet_size).
+For specific mysql::server settings you can use hiera now:
+<pre>
+puppet::dashboard::server::manage_mysql_options: false
+mysql::server::override_options:
+ mysqld:
+ max_allowed_packet: '32M'
+ innodb_buffer_pool_size: '64M'
+</pre>
+
+- *Default*: true
+
===
## Class `puppet::dashboard::server` ##
### Usage ###
You can optionally specify a hash of htpasswd entries in Hiera.
<pre>
---
puppet::dashboard::htpasswd:
admin:
cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
puppet:
cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
</pre>
### Parameters ###
dashboard_workers
-----------------
Number of dashboard workers to start. Only used on osfamily Debian.
- *Default*: $::processorcount
database_config_path
--------------------
The path to the database config file.
- *Default*: /usr/share/puppet-dashboard/config/database.yml
database_config_owner
---------------------
The owner of the database config file.
- *Default*: puppet-dashboard
database_config_group
---------------------
The database config file group.
- *Default*: puppet-dashboard
database_config_mode
--------------------
The database config file mode.
- *Default*: 0640
htpasswd
--------
Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
- *Default*: undef
htpasswd_path
-------------
String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
- *Default*: `/etc/puppet/dashboard.htpasswd`
htpasswd_owner
--------------
Owner of htpasswd file.
- *Default*: root
htpasswd_group
--------------
Group of htpasswd file.
- *Default*: use defaults based on osfamily
htpasswd_mode
-------------
Mode of htpasswd file.
- *Default*: 0640
log_dir
-------
The location for the puppet log files.
- *Default*: /var/log/puppet
mysql_user
----------
The user for the mysql connection.
- *Default*: dashboard
mysql_password
--------------
The password for the mysql connection.
- *Default*: puppet
mysql_max_packet_size
---------------------
The mysql max packet size.
- *Default*: 32M
security
--------
String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
- *Default*: 'none'
vhost_path
----------
The location of puppet dashboard vhost file for apache.
- *Default*: use defaults based on osfamily
===
## Class `puppet::dashboard::maintenance` ##
### Parameters ###
db_optimization_command
-----------------------
The command to run to optimize the db.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
db_optimization_user
--------------------
The user to run db optimization.
- *Default*: root
db_optimization_hour
--------------------
The hour on which to run db optimization.
- *Default*: 0
db_optimization_minute
----------------------
The minute at which to run db optimization.
- *Default*: 0
db_optimization_monthday
------------------------
The day of the month on which to run db optimization.
- *Default*: 1
reports_days_to_keep
--------------------
How many days to keep the reports.
- *Default*: 30
purge_old_reports_command
-------------------------
Which command to run to purge old reports.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=30 unit=day >> /var/log/puppet/dashboard_maintenance.log
purge_old_reports_user
----------------------
User to purge reports as.
- *Default*: root
purge_old_reports_hour
----------------------
On which hour to purge old reports.
- *Default*: 0
purge_old_reports_minute
------------------------
At which minute to purge old reports.
- *Default*: 30
remove_old_reports_spool
------------------------
Whether we should remove old dashboard reports that have not been imported
- *Default*: 'True'
reports_spool_dir
-----------------
Path to reports in dashboard spool
- *Default*: '/usr/share/puppet-dashboard/spool'
reports_spool_days_to_keep
--------------------------
How many days to keep the unimported reports.
remove_reports_spool_user
-------------------------
User to remove unimported reports.
- *Default*: root
remove_reports_spool_hour
-------------------------
On which hour to remove unimported reports.
- *Default*: 0
remove_reports_spool_minute
---------------------------
At which minute to remove unimported reports
- *Default*: 45
dump_dir
--------
The directory to use for dumps.
- *Default*: /var/local
dump_database_command
---------------------
The command to run to dump the database.
- *Default*: sudo -u puppet-dashboard /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log
dump_database_user
------------------
User to dump database as.
- *Default*: root
dump_database_hour
------------------
On which hour to dump database.
- *Default*: 1
dump_database_minute
--------------------
At which minute to purge old reports.
- *Default*: 0
days_to_keep_backups
--------------------
Number of days to keep database backups.
- *Default*: 7
purge_old_db_backups_user
-------------------------
User to purge old database dumps as.
- *Default*: root
purge_old_db_backups_hour
-------------------------
On which hour to purge old database dumps.
- *Default*: 2
purge_old_db_backups_minute
---------------------------
At which minute to purge old database dumps.
- *Default*: 0
===
## Class `puppet::lint` ##
### Parameters ###
ensure
------
Whether to install lint.
- *Default*: present
provider
--------
Which provider should supply lint.
- *Default*: gem
version
-------
If you do not want to use the default version of lint, specify which version you want to use here.
- *Default*: undef
lint_args
---------
Which args should be added to the .puppet-lint.rc file
- *Default*: --no-80chars-check
lintrc_path
-----------
The full path to the lint config file.
- *Default*: ${::root_home}/.puppet-lint.rc
lintrc_owner
------------
The owner of the lint config file.
- *Default*: root
lintrc_group
------------
The group of the lint config file.
- *Default*: root
lintrc_mode
-----------
The mode of the lint config file.
- *Default*: 0644
===
## Class `puppet::master` ##
### Usage ###
In Hiera you will need to specify the following.
<pre>
puppet::agent::is_puppet_master: 'true'
</pre>
### Parameters ###
sysconfig_path
--------------
The location of puppet master sysconfig file.
- *Default*: use defaults based on osfamily
vhost_path
----------
The location of puppet master vhost file for apache.
- *Default*: use defaults based on osfamily
rack_dir
--------
The rack directory path.
- *Default*: /usr/share/puppet/rack/puppetmasterd
puppet_user
-----------
The user the puppet master should run as.
- *Default*: puppet
manage_firewall
---------------
Whether to manage the firewall settings on the client
- *Default*: undef
===
## Class `puppet::master::maintenance` ##
### Parameters ###
clientbucket_path
-----------------
Path to where the clientbucket files are stored.
- *Default*: /var/lib/puppet/clientbucket
clientbucket_days_to_keep
-------------------------
The number of days to keep clientbuckets
- *Default*: 30
filebucket_cleanup_command
--------------------------
Command used to cleanup the clientbuckets.
- *Default*: /usr/bin/find ${clientbucket_path} -type f -mtime +30 -exec /bin/rm -fr {} \;
filebucket_cleanup_user
-----------------------
User to run the clientbucket cleanup as.
- *Default*: root
filebucket_cleanup_hour
-----------------------
Hour on which to run the filebucket cleanup.
- *Default*: 0
filebucket_cleanup_minute
-------------------------
Minute at which to run the filebucket cleanup.
- *Default*: 0
reportdir
---------
Directory that holds the reports. `$::puppet_reportdir` is a custom fact that reads the `reportdir` setting from Puppet's configuration. This is likely `/var/lib/puppet/reports/`.
- *Default*: $::puppet_reportdir
reportdir_days_to_key
---------------------
String for number of days of reports to keep. Must be a positive integer > 0.
- *Default*: '30'
reportdir_purge_command
-----------------------
Command ran by cron to purge old reports.
- *Default*: /usr/bin/find /var/lib/puppet/reports/ -type f -mtime +30 -exec /bin/rm -fr {} \;'
reportdir_purge_user
--------------------
User for the crontab entry to run the reportdir_purge_command.
- *Default*: root
reportdir_purge_hour
--------------------
Hour at which to run the reportdir_purge_command.
- *Default*: 0
reportdir_purge_minute
----------------------
Minute past the hour in which to run the reportdir_purge_command.
- *Default*: 15
diff --git a/manifests/dashboard/server.pp b/manifests/dashboard/server.pp
index 5a8157c..0a7ca36 100644
--- a/manifests/dashboard/server.pp
+++ b/manifests/dashboard/server.pp
@@ -1,158 +1,175 @@
# == Class: puppet::dashboard::server
#
class puppet::dashboard::server (
$dashboard_workers = $::processorcount,
$database_config_path = '/usr/share/puppet-dashboard/config/database.yml',
$database_config_owner = 'USE_DEFAULTS',
$database_config_group = 'USE_DEFAULTS',
$database_config_mode = '0640',
$htpasswd = undef,
$htpasswd_path = '/etc/puppet/dashboard.htpasswd',
$htpasswd_owner = 'root',
$htpasswd_group = 'USE_DEFAULTS',
$htpasswd_mode = '0640',
$log_dir = '/var/log/puppet',
+ $manage_mysql_options = true,
$mysql_user = 'dashboard',
$mysql_password = 'puppet',
$mysql_max_packet_size = '32M',
$security = 'none',
$vhost_path = 'USE_DEFAULTS',
) inherits puppet::dashboard {
validate_re($dashboard_workers, '^\d+$',
"puppet::dashboard::server::dashboard_workers must be a digit. Detected value is <${dashboard_workers}>."
)
validate_absolute_path($htpasswd_path)
validate_re($security, '^(none|htpasswd)$',
"Security is <${security}> which does not match regex. Valid values are none and htpasswd."
)
case $::osfamily {
'RedHat': {
$default_database_config_group = $puppet::dashboard::dashboard_group_real
$default_htpasswd_group = 'apache'
$default_vhost_path = '/etc/httpd/conf.d/dashboard.conf'
}
'Debian': {
$default_database_config_group = 'www-data'
$default_htpasswd_group = 'www-data'
$default_vhost_path = '/etc/apache2/sites-enabled/puppetdashboard'
file { 'dashboard_workers_default':
ensure => file,
path => '/etc/default/puppet-dashboard-workers',
content => template('puppet/puppet-dashboard-workers.erb'),
owner => 'root',
group => 'root',
mode => '0644',
notify => Service['puppet-dashboard-workers'],
}
}
default: {
fail("puppet::dashboard::server supports osfamilies Debian and RedHat. Detected osfamily is <${::osfamily}>.")
}
}
if $database_config_owner == 'USE_DEFAULTS' {
$database_config_owner_real = $puppet::dashboard::dashboard_user_real
} else {
$database_config_owner_real = $database_config_owner
}
if $database_config_group == 'USE_DEFAULTS' {
$database_config_group_real = $default_database_config_group
} else {
$database_config_group_real = $database_config_group
}
if $htpasswd_group == 'USE_DEFAULTS' {
$htpasswd_group_real = $default_htpasswd_group
} else {
$htpasswd_group_real = $htpasswd_group
}
if $vhost_path == 'USE_DEFAULTS' {
$vhost_path_real = $default_vhost_path
} else {
$vhost_path_real = $vhost_path
}
validate_absolute_path($vhost_path_real)
require 'passenger'
include puppet::dashboard::maintenance
- class { 'mysql::server':
- override_options => {
- 'mysqld' => {
- 'max_allowed_packet' => $mysql_max_packet_size,
+ case type($manage_mysql_options) {
+ 'boolean': {
+ $manage_mysql_options_real = $manage_mysql_options
+ }
+ 'string': {
+ $manage_mysql_options_real = str2bool($manage_mysql_options)
+ }
+ default: {
+ fail("puppet::dashboard::server::manage_mysql_options supports booleans only and is <${manage_mysql_options}>.")
+ }
+ }
+
+ if $manage_mysql_options_real == true {
+ class { 'mysql::server':
+ override_options => {
+ 'mysqld' => {
+ 'max_allowed_packet' => $mysql_max_packet_size,
+ }
}
}
+ } else {
+ include mysql::server
}
if $security == 'htpasswd' and $htpasswd != undef {
Htpasswd {
target => $htpasswd_path,
}
Htpasswd <||> -> File['dashboard_htpasswd_path']
create_resources('htpasswd',$htpasswd)
file { 'dashboard_htpasswd_path':
ensure => file,
path => $htpasswd_path,
owner => $htpasswd_owner,
group => $htpasswd_group_real,
mode => $htpasswd_mode,
}
}
file { 'database_config':
ensure => file,
content => template('puppet/database.yml.erb'),
path => $database_config_path,
owner => $database_config_owner_real,
group => $database_config_group_real,
mode => $database_config_mode,
require => Package[$puppet::dashboard::dashboard_package],
}
file { 'dashboard_vhost':
ensure => file,
path => $vhost_path_real,
content => template('puppet/dashboard-vhost.conf.erb'),
owner => 'root',
group => 'root',
mode => '0644',
require => [ File['httpd_vdir'], # apache
# Exec['compile-passenger'], # passenger
],
notify => Service['httpd'], # apache
}
mysql::db { 'dashboard':
user => $mysql_user,
password => $mysql_password,
host => 'localhost',
grant => ['ALL'],
require => [ Class['mysql::server'],
File['database_config'],
],
}
exec { 'migrate_dashboard_database':
command => 'rake RAILS_ENV=production db:migrate',
onlyif => 'rake RAILS_ENV=production db:version 2>/dev/null|grep ^\'Current version\' | awk -F : \'{print $2}\' | awk \'{print $1}\'|grep ^0$',
path => '/bin:/usr/bin:/sbin:/usr/sbin',
cwd => '/usr/share/puppet-dashboard',
refreshonly => true,
subscribe => Mysql::Db['dashboard'],
}
Service['puppet-dashboard-workers'] {
ensure => running,
enable => true,
subscribe => File['dashboard_sysconfig'],
}
}
diff --git a/spec/classes/dashboard_server_spec.rb b/spec/classes/dashboard_server_spec.rb
index e453b1d..9f2f2bf 100644
--- a/spec/classes/dashboard_server_spec.rb
+++ b/spec/classes/dashboard_server_spec.rb
@@ -1,459 +1,509 @@
require 'spec_helper'
describe 'puppet::dashboard::server' do
context 'with default dashboard_workers on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should_not contain_file('dashboard_workers_default') }
end
context 'with default dashboard_workers on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_workers_default').with({
'ensure' => 'file',
'path' => '/etc/default/puppet-dashboard-workers',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('dashboard_workers_default').with_content(/^START=yes$/) }
it { should contain_file('dashboard_workers_default').with_content(/^NUM_DELAYED_JOB_WORKERS=8$/) }
end
context 'with default dashboard_workers set to non-digit' do
let(:params) { { :dashboard_workers => '8invalid' } }
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:concat_basedir => '/tmp',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error,/puppet::dashboard::server::dashboard_workers must be a digit. Detected value is <8invalid>./)
end
end
context 'with default htpasswd path on osfamily RedHat' do
let(:params) do
{ :security => 'htpasswd',
:htpasswd => {
'gh' => {
'cryptpasswd' => 'password',
},
}
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_htpasswd_path').with({
'ensure' => 'file',
'path' => '/etc/puppet/dashboard.htpasswd',
'owner' => 'root',
'group' => 'apache',
'mode' => '0640',
})
}
end
context 'with default htpasswd path on osfamily Debian' do
let(:params) do
{ :security => 'htpasswd',
:htpasswd => {
'gh' => {
'cryptpasswd' => 'password',
},
}
}
end
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_htpasswd_path').with({
'ensure' => 'file',
'path' => '/etc/puppet/dashboard.htpasswd',
'owner' => 'root',
'group' => 'www-data',
'mode' => '0640',
})
}
end
context 'with htpasswd_path set by user' do
let(:params) do
{ :htpasswd_path => '/var/www/html/dashboard_passwd',
:security => 'htpasswd',
:htpasswd => {
'gh' => {
'cryptpasswd' => 'password',
},
}
}
end
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_htpasswd_path').with({
'ensure' => 'file',
'path' => '/var/www/html/dashboard_passwd',
'owner' => 'root',
'group' => 'www-data',
'mode' => '0640',
})
}
end
context 'with invalid value for htpasswd_path' do
let(:params) do
{ :htpasswd_path => 'not/a/valid/path',
:security => 'htpasswd',
:htpasswd => {
'gh' => {
'cryptpasswd' => 'password',
},
}
}
end
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error)
end
end
+ [false,'false'].each do |value|
+ context "with manage_mysql_options set to <#{value}>" do
+ let(:params) { { :manage_mysql_options => "#{value}" } }
+ let(:facts) do
+ { :osfamily => 'RedHat',
+ :operatingsystemrelease => '6.4',
+ :processorcount => '8',
+ }
+ end
+
+ it { should contain_class('puppet::dashboard::server') }
+
+ it { should contain_file('/etc/my.cnf').without_content(/^max_allowed_packet = 32M$/) }
+ end
+ end
+
+ [true,'true'].each do |value|
+ context "with manage_mysql_options set to <#{value}>" do
+ let(:params) { { :manage_mysql_options => "#{value}" } }
+ let(:facts) do
+ { :osfamily => 'RedHat',
+ :operatingsystemrelease => '6.4',
+ :processorcount => '8',
+ }
+ end
+
+ it { should contain_class('puppet::dashboard::server') }
+
+ it { should contain_file('/etc/my.cnf').with_content(/^max_allowed_packet = 32M$/) }
+ end
+ end
+
+ ['invalid',[ 'dont', 'like', 'arrays', ], { 'nor' => 'hashes', }, ].each do |value|
+ context "with manage_mysql_options set to invalid value <#{value}>" do
+ let(:params) { { :manage_mysql_options => "#{value}" } }
+ let(:facts) do
+ { :osfamily => 'RedHat',
+ :operatingsystemrelease => '6.4',
+ :processorcount => '8',
+ }
+ end
+
+ it do
+ expect {
+ should contain_class('puppet::dashboard')
+ }.to raise_error(Puppet::Error)
+ end
+ end
+ end
+
describe 'Dashboard vhost configuration file content' do
context 'when vhost_path is invalid it should fail' do
let(:params) { { :vhost_path => 'not/a/valid/path' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error)
end
end
context 'when htpasswd_path is invalid it should fail' do
let(:params) { { :htpasswd_path => 'not/a/valid/path' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error)
end
end
context 'when security is invalid it should fail' do
let(:params) { { :security => 'invalid' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it do
expect {
should contain_class('puppet::dashboard')
}.to raise_error(Puppet::Error,/Security is <invalid> which does not match regex. Valid values are none and htpasswd./)
end
end
context 'with default settings' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost').with_content(/^\s*ServerName puppet.example.com$/) }
end
context 'with security set to none' do
let(:params) { { :security => 'none' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost') }
it { should_not contain_file('dashboard_vhost').with_content(/(\s+|)AuthType(\s+)basic(\s*)/) }
end
context 'with security set to htpasswd' do
let(:params) { { :security => 'htpasswd' } }
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost').with_content(/(\s+|)AuthType(\s+)basic(\s*)/) }
end
end
context 'with database configuration file on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('database_config').with({
'path' => '/usr/share/puppet-dashboard/config/database.yml',
'owner' => 'puppet-dashboard',
'group' => 'puppet-dashboard',
'mode' => '0640',
'require' => 'Package[puppet-dashboard]',
})
}
end
context 'with database configuration file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('database_config').with({
'path' => '/usr/share/puppet-dashboard/config/database.yml',
'owner' => 'puppet',
'group' => 'www-data',
'mode' => '0640',
'require' => 'Package[puppet-dashboard]',
})
}
end
context 'Dashboard database configuration file content' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('database_config').with_content(/^\s*username: dashboard$/) }
end
context 'Dashboard vhost configuration file on osfamily RedHat' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost').with({
'ensure' => 'file',
'path' => '/etc/httpd/conf.d/dashboard.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
context 'Dashboard vhost configuration file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:operatingsystemrelease => '6.0.8',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
:domain => 'example.com',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_file('dashboard_vhost').with({
'ensure' => 'file',
'path' => '/etc/apache2/sites-enabled/puppetdashboard',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
context 'Dashboard Mysql Database' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_mysql__db('dashboard').with({
'user' => 'dashboard',
'password' => 'puppet',
'host' => 'localhost',
})
}
end
context 'Dashboard database migration' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_exec('migrate_dashboard_database').with({
'command' => 'rake RAILS_ENV=production db:migrate',
'path' => '/bin:/usr/bin:/sbin:/usr/sbin',
'cwd' => '/usr/share/puppet-dashboard',
'refreshonly' => true,
})
}
end
context 'Dashboard workers service' do
let(:facts) do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '6.4',
:ports_file => '/etc/httpd/ports.conf"',
:processorcount => '8',
:concat_basedir => '/tmp',
}
end
it { should contain_class('puppet::dashboard::server') }
it { should contain_service('puppet-dashboard-workers').with({
'ensure' => 'running',
'enable' => true,
})
}
end
end
|
ghoneycutt/puppet-module-puppet
|
c6aae205c10edd087f308b95b3dde216dd0151ac
|
Remove extraneous comment from puppet.conf
|
diff --git a/templates/puppetagent.conf.erb b/templates/puppetagent.conf.erb
index 02ba72d..01f873d 100644
--- a/templates/puppetagent.conf.erb
+++ b/templates/puppetagent.conf.erb
@@ -1,65 +1,64 @@
# This file is being maintained by Puppet.
# DO NOT EDIT
[main]
# The Puppet log directory.
# The default value is '$vardir/log'.
logdir = /var/log/puppet
# Where Puppet PID files are kept.
# The default value is '$vardir/run'.
rundir = /var/run/puppet
# Where SSL certificates are kept.
# The default value is '$confdir/ssl'.
ssldir = $vardir/ssl
archive_files = true
archive_file_server = <%= @puppet_server %>
# If stringify_facts is true, you have the classic facter fact that is
# always a string. If set to false, then you can use structured facts which
# were introduced in Facter v2
stringify_facts = <%= @stringify_facts_bool %>
<% if @etckeeper_hooks_bool == true %>
prerun_command=/etc/puppet/etckeeper-commit-pre
postrun_command=/etc/puppet/etckeeper-commit-post
<% end -%>
[agent]
# The file in which puppetd stores a list of the classes
# associated with the retrieved configuratiion. Can be loaded in
# the separate ``puppet`` executable using the ``--loadclasses``
# option.
# The default value is '$confdir/classes.txt'.
classfile = $vardir/classes.txt
# Where puppetd caches the local configuration. An
# extension indicating the cache format is added automatically.
# The default value is '$confdir/localconfig'.
localconfig = $vardir/localconfig
certname = <%= @certname %>
server = <%= @puppet_server %>
<% if @puppet_masterport != 'UNSET' -%>
masterport = <%= @puppet_masterport %>
<% end -%>
<% if @puppet_ca_server != 'UNSET' -%>
ca_server = <%= @puppet_ca_server %>
<% end -%>
<% if @http_proxy_host != 'UNSET' -%>
http_proxy_host = <%= @http_proxy_host %>
<% end -%>
<% if @http_proxy_port != 'UNSET' -%>
http_proxy_port = <%= @http_proxy_port %>
<% end -%>
report = true
graph = true
pluginsync = true
<% if @run_method == 'service' %>
- # run in noop mode?
noop = <%= @run_in_noop %>
<% end -%>
<% if @env != 'production' -%>
environment = <%= @env %>
<% end -%>
|
ghoneycutt/puppet-module-puppet
|
c5726a65a4a2a59d72bcc1f2f7f1b4292371c77b
|
fix linebreaks in puppet.conf
|
diff --git a/templates/puppetagent.conf.erb b/templates/puppetagent.conf.erb
index b3293b6..02ba72d 100644
--- a/templates/puppetagent.conf.erb
+++ b/templates/puppetagent.conf.erb
@@ -1,54 +1,65 @@
# This file is being maintained by Puppet.
# DO NOT EDIT
[main]
# The Puppet log directory.
# The default value is '$vardir/log'.
logdir = /var/log/puppet
# Where Puppet PID files are kept.
# The default value is '$vardir/run'.
rundir = /var/run/puppet
# Where SSL certificates are kept.
# The default value is '$confdir/ssl'.
ssldir = $vardir/ssl
archive_files = true
archive_file_server = <%= @puppet_server %>
# If stringify_facts is true, you have the classic facter fact that is
# always a string. If set to false, then you can use structured facts which
# were introduced in Facter v2
stringify_facts = <%= @stringify_facts_bool %>
<% if @etckeeper_hooks_bool == true %>
prerun_command=/etc/puppet/etckeeper-commit-pre
postrun_command=/etc/puppet/etckeeper-commit-post
<% end -%>
[agent]
# The file in which puppetd stores a list of the classes
# associated with the retrieved configuratiion. Can be loaded in
# the separate ``puppet`` executable using the ``--loadclasses``
# option.
# The default value is '$confdir/classes.txt'.
classfile = $vardir/classes.txt
# Where puppetd caches the local configuration. An
# extension indicating the cache format is added automatically.
# The default value is '$confdir/localconfig'.
localconfig = $vardir/localconfig
certname = <%= @certname %>
server = <%= @puppet_server %>
-<% if @puppet_masterport != 'UNSET' %> masterport = <%= @puppet_masterport %><% end %>
-<% if @puppet_ca_server != 'UNSET' %> ca_server = <%= @puppet_ca_server %><% end %>
-<% if @http_proxy_host != 'UNSET' %> http_proxy_host = <%= @http_proxy_host %><% end %>
-<% if @http_proxy_port != 'UNSET' %> http_proxy_port = <%= @http_proxy_port %><% end %>
+<% if @puppet_masterport != 'UNSET' -%>
+ masterport = <%= @puppet_masterport %>
+<% end -%>
+<% if @puppet_ca_server != 'UNSET' -%>
+ ca_server = <%= @puppet_ca_server %>
+<% end -%>
+<% if @http_proxy_host != 'UNSET' -%>
+ http_proxy_host = <%= @http_proxy_host %>
+<% end -%>
+<% if @http_proxy_port != 'UNSET' -%>
+ http_proxy_port = <%= @http_proxy_port %>
+<% end -%>
report = true
graph = true
pluginsync = true
-<% if @run_method == 'service' %> # run in noop mode?
+<% if @run_method == 'service' %>
+ # run in noop mode?
noop = <%= @run_in_noop %>
<% end -%>
-<% if @env != 'production' %> environment = <%= @env %><% end -%>
+<% if @env != 'production' -%>
+ environment = <%= @env %>
+<% end -%>
|
ghoneycutt/puppet-module-puppet
|
69677449ef70439d7c38470b50f2e30559ec16c3
|
Release v2.13.1 - Bugfix to disable insecure SSLv3
|
diff --git a/Modulefile b/Modulefile
index c58f035..da82a58 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,17 +1,17 @@
name 'ghoneycutt-puppet'
-version '2.13.0'
+version '2.13.1'
source 'git://github.com/ghoneycutt/puppet-module-puppet.git'
author 'ghoneycutt'
license 'Apache License, Version 2.0'
summary 'Manage Puppet'
description 'Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.'
project_page 'https://github.com/ghoneycutt/puppet-module-puppet'
dependency 'ghoneycutt/common', '>= 1.0.3'
dependency 'leinaddm/htpasswd', '>= 0.0.1'
dependency 'puppetlabs/stdlib', '>= 3.2.0'
dependency 'puppetlabs/mysql', '>= 2.0.0'
dependency 'puppetlabs/passenger', '>= 0.0.4'
dependency 'puppetlabs/apache', '>= 0.5.0'
dependency 'puppetlabs/firewall', '>= 0.2.1'
dependency 'puppetlabs/concat', '>= 1.0.0'
diff --git a/metadata.json b/metadata.json
index 44545e0..f573e98 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.13.0",
+ "version": "2.13.1",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"license": "Apache License, Version 2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
79f305bf1ece14e9ed88b7c8293761bb299f1060
|
Disable SSLv3 as it is insecure
|
diff --git a/templates/puppetmaster-vhost.conf.erb b/templates/puppetmaster-vhost.conf.erb
index bccbe66..6a365da 100644
--- a/templates/puppetmaster-vhost.conf.erb
+++ b/templates/puppetmaster-vhost.conf.erb
@@ -1,49 +1,49 @@
# This file is being maintained by Puppet.
# DO NOT EDIT
PassengerUseGlobalQueue On
# Recycle master processes after they service 1000 requests
PassengerMaxRequests 1000
# Stop processes if they sit idle for 10 minutes
PassengerPoolIdleTime 600
PassengerStatThrottleRate 120
RackAutoDetect On
RailsAutoDetect On
Listen 8140
<VirtualHost *:8140>
SSLEngine On
# Only allow high security cryptography. Alter if needed for compatibility.
- SSLProtocol All -SSLv2
+ SSLProtocol All -SSLv2 -SSLv3
SSLCipherSuite HIGH:!ADH:RC4+RSA:-MEDIUM:-LOW:-EXP
SSLCertificateFile /var/lib/puppet/ssl/certs/<%= @fqdn %>.pem
SSLCertificateKeyFile /var/lib/puppet/ssl/private_keys/<%= @fqdn %>.pem
SSLCertificateChainFile /var/lib/puppet/ssl/ca/ca_crt.pem
SSLCACertificateFile /var/lib/puppet/ssl/ca/ca_crt.pem
SSLCARevocationFile /var/lib/puppet/ssl/ca/ca_crl.pem
SSLVerifyClient optional
SSLVerifyDepth 1
SSLOptions +StdEnvVars +ExportCertData
# This header needs to be set if using a loadbalancer or proxy
RequestHeader unset X-Forwarded-For
# These request headers are used to pass the client certificate
# authentication information on to the puppet master process
RequestHeader set X-SSL-Subject %{SSL_CLIENT_S_DN}e
RequestHeader set X-Client-DN %{SSL_CLIENT_S_DN}e
RequestHeader set X-Client-Verify %{SSL_CLIENT_VERIFY}e
RackAutoDetect On
DocumentRoot <%= @rack_dir %>/public/
<Directory <%= @rack_dir %>/>
Options None
AllowOverride None
Order Allow,Deny
Allow from All
</Directory>
</VirtualHost>
|
ghoneycutt/puppet-module-puppet
|
81ab1c55d6988733741e2e98357e36bc03e70809
|
Release v2.13.0 - Add http_proxy_{host,port} config options
|
diff --git a/Modulefile b/Modulefile
index 2108d28..c58f035 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,17 +1,17 @@
name 'ghoneycutt-puppet'
-version '2.12.0'
+version '2.13.0'
source 'git://github.com/ghoneycutt/puppet-module-puppet.git'
author 'ghoneycutt'
license 'Apache License, Version 2.0'
summary 'Manage Puppet'
description 'Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.'
project_page 'https://github.com/ghoneycutt/puppet-module-puppet'
dependency 'ghoneycutt/common', '>= 1.0.3'
dependency 'leinaddm/htpasswd', '>= 0.0.1'
dependency 'puppetlabs/stdlib', '>= 3.2.0'
dependency 'puppetlabs/mysql', '>= 2.0.0'
dependency 'puppetlabs/passenger', '>= 0.0.4'
dependency 'puppetlabs/apache', '>= 0.5.0'
dependency 'puppetlabs/firewall', '>= 0.2.1'
dependency 'puppetlabs/concat', '>= 1.0.0'
diff --git a/metadata.json b/metadata.json
index e41cfac..44545e0 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.12.0",
+ "version": "2.13.0",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"license": "Apache License, Version 2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
a056d901c7b1ebbf2187601fd6ae4a3e6bad2453
|
http_proxy_host and http_proxy_port in agent's puppet.conf
|
diff --git a/README.md b/README.md
index 476772c..c24e569 100644
--- a/README.md
+++ b/README.md
@@ -1,643 +1,655 @@
# puppet-module-puppet #
===
[](https://travis-ci.org/ghoneycutt/puppet-module-puppet)
This module handles the various parts of puppet on a given machine.
Dependencies for this module are: apache, common, mysql and passenger
## Components ##
### Agent
---------
- Manages the puppet agent on a client
- Setup of configuration files
- Setup of service or crontask to run the agent periodically
- Ensure puppet agent is run at boottime
### Master
----------
- Manages apache with passenger
- Setup of config files needed to run master
- Calls the `puppet::lint` class
- Calls the `puppet::master::maintenance` class
- Manages firewall rule for puppet if needed
- Maintenance to purge filebucket and reports
### Dashboard
-------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This installation is used by puppet systems, that need access to the dashboard
### Dashboard Server
--------------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This is the actual server running the Dashboard
- Configures the Dashboard MySQL settings
- Creates database for puppet with mysql module
- Calls the `puppet::dashboard::maintenance` class
- Maintenance to clean up old reports, optimize database and dump database
- For the maintenance cron jobs, you should have the following line in your `/etc/sudoers` which is not managed with this module.
<pre>
Defaults:root !requiretty
</pre>
### Lint
--------
- Manages [puppet-lint](http://github.com/rodjek/puppet-lint)
## Compatibility ##
-------------------
Ruby versions 1.8.7, 1.9.3, and 2.0.0 on Puppet 3.x
### Puppet Master
-----------------
* Debian 6
* Debian 7
* EL 6
* Ubuntu 12.04 LTS
### Puppet Agent
----------------
* Debian 6
* Debian 7
* EL 6
* EL 7
* Solaris
* Suse 11
* Ubuntu 12.04 LTS
===
## Class `puppet::agent` ##
### Parameters ###
certname
--------
The certificate name for the client.
- *Default*: $::fqdn
config_path
-----------
The location of the puppet config file.
- *Default*: /etc/puppet/puppet.conf
config_owner
------------
The owner of the config file.
- *Default*: root
config_group
------------
The group for the config file.
- *Default*: root
config_mode
-----------
The mode for the config file.
- *Default*: 0644
env
---
The selected environment for the client.
- *Default*: $::env
puppet_server
-------------
The puppet server the client should connect to.
- *Default*: puppet
puppet_masterport
-----------------
The masterport setting in puppet.conf. By default this line is not set.
- *Default*: UNSET
puppet_ca_server
----------------
The puppet CA server the client should use
- *Default*: UNSET
+http_proxy_host
+---------------
+The http-proxy the client should use
+
+- *Default*: UNSET
+
+http_proxy_port
+----------------
+The http-proxy port the client should use
+
+- *Default*: UNSET
+
is_puppet_master
----------------
Whether the machine is a puppet master or not.
- *Default*: false
run_method
----------
Whether to run as a service or in cron mode. Valid values are `disable`, `cron`, and `service`. The value `disable` disables automatic puppet runs and assumes you are running as a service.
- *Default*: service
run_interval
------------
The interval with which the client should run (in minutes)
- *Default*: 30
run_in_noop
-----------
Whether the client should run in noop mode or not.
- *Default*: false
cron_command
------------
The command that should be added to the crontab (in cron mode)
- *Default*: /usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay
run_at_boot
-----------
Whether the client should run right after boot
- *Default*: true
puppet_binary
-------------
Path to puppet binary to create symlink from
- *Default*: '/usr/bin/puppet'
symlink_puppet_binary_target
----------------------------
Path to where the symlink should be created
- *Default*: '/usr/local/bin/puppet'
symlink_puppet_binary
---------------------
Boolean for ensuring a symlink for puppet_binary to symlink_puppet_binary_target. This is useful if you install puppet in a non-standard location that is not in your $PATH.
- *Default*: false
agent_sysconfig
---------------
The location of puppet agent sysconfig file.
- *Default*: use defaults based on osfamily
agent_sysconfig_ensure
----------------------
String for 'file' or 'present'. Allows you to not manage the sysconfig file.
- *Default*: use defaults based on osfamily
daemon_name
-----------
The name the puppet agent daemon should run as.
- *Default*: puppet
stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
- *Default*: true
etckeeper_hooks
---------------
Boolean to include pre- and postrun hooks for etckeeper in the main section of the puppet agent's config.
- *Default*: false
===
## Class `puppet::dashboard` ##
### Parameters ###
dashboard_package
-----------------
String or Array of the dashboard package(s) name.
- *Default*: 'puppet-dashboard'
dashboard_user
--------------
The user for dashboard installation.
- *Default*: use defaults based on osfamily
dashboard_group
--------------
The group for dashboard installation.
- *Default*: use defaults based on osfamily
sysconfig_path
-------------------
The location of puppet dashboard sysconfig file.
- *Default*: use defaults based on osfamily
external_node_script_path
-------------------------
The script to call from puppet to get manifests from dashboard.
- *Default*: /usr/share/puppet-dashboard/bin/external_node
dashboard_fqdn
--------------
The dashboard server FQDN.
- *Default*: puppet.${::domain}
port
----
The port the web server will respond to.
- *Default*: 3000
===
## Class `puppet::dashboard::server` ##
### Usage ###
You can optionally specify a hash of htpasswd entries in Hiera.
<pre>
---
puppet::dashboard::htpasswd:
admin:
cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
puppet:
cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
</pre>
### Parameters ###
dashboard_workers
-----------------
Number of dashboard workers to start. Only used on osfamily Debian.
- *Default*: $::processorcount
database_config_path
--------------------
The path to the database config file.
- *Default*: /usr/share/puppet-dashboard/config/database.yml
database_config_owner
---------------------
The owner of the database config file.
- *Default*: puppet-dashboard
database_config_group
---------------------
The database config file group.
- *Default*: puppet-dashboard
database_config_mode
--------------------
The database config file mode.
- *Default*: 0640
htpasswd
--------
Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
- *Default*: undef
htpasswd_path
-------------
String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
- *Default*: `/etc/puppet/dashboard.htpasswd`
htpasswd_owner
--------------
Owner of htpasswd file.
- *Default*: root
htpasswd_group
--------------
Group of htpasswd file.
- *Default*: use defaults based on osfamily
htpasswd_mode
-------------
Mode of htpasswd file.
- *Default*: 0640
log_dir
-------
The location for the puppet log files.
- *Default*: /var/log/puppet
mysql_user
----------
The user for the mysql connection.
- *Default*: dashboard
mysql_password
--------------
The password for the mysql connection.
- *Default*: puppet
mysql_max_packet_size
---------------------
The mysql max packet size.
- *Default*: 32M
security
--------
String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
- *Default*: 'none'
vhost_path
----------
The location of puppet dashboard vhost file for apache.
- *Default*: use defaults based on osfamily
===
## Class `puppet::dashboard::maintenance` ##
### Parameters ###
db_optimization_command
-----------------------
The command to run to optimize the db.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
db_optimization_user
--------------------
The user to run db optimization.
- *Default*: root
db_optimization_hour
--------------------
The hour on which to run db optimization.
- *Default*: 0
db_optimization_minute
----------------------
The minute at which to run db optimization.
- *Default*: 0
db_optimization_monthday
------------------------
The day of the month on which to run db optimization.
- *Default*: 1
reports_days_to_keep
--------------------
How many days to keep the reports.
- *Default*: 30
purge_old_reports_command
-------------------------
Which command to run to purge old reports.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=30 unit=day >> /var/log/puppet/dashboard_maintenance.log
purge_old_reports_user
----------------------
User to purge reports as.
- *Default*: root
purge_old_reports_hour
----------------------
On which hour to purge old reports.
- *Default*: 0
purge_old_reports_minute
------------------------
At which minute to purge old reports.
- *Default*: 30
remove_old_reports_spool
------------------------
Whether we should remove old dashboard reports that have not been imported
- *Default*: 'True'
reports_spool_dir
-----------------
Path to reports in dashboard spool
- *Default*: '/usr/share/puppet-dashboard/spool'
reports_spool_days_to_keep
--------------------------
How many days to keep the unimported reports.
remove_reports_spool_user
-------------------------
User to remove unimported reports.
- *Default*: root
remove_reports_spool_hour
-------------------------
On which hour to remove unimported reports.
- *Default*: 0
remove_reports_spool_minute
---------------------------
At which minute to remove unimported reports
- *Default*: 45
dump_dir
--------
The directory to use for dumps.
- *Default*: /var/local
dump_database_command
---------------------
The command to run to dump the database.
- *Default*: sudo -u puppet-dashboard /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log
dump_database_user
------------------
User to dump database as.
- *Default*: root
dump_database_hour
------------------
On which hour to dump database.
- *Default*: 1
dump_database_minute
--------------------
At which minute to purge old reports.
- *Default*: 0
days_to_keep_backups
--------------------
Number of days to keep database backups.
- *Default*: 7
purge_old_db_backups_user
-------------------------
User to purge old database dumps as.
- *Default*: root
purge_old_db_backups_hour
-------------------------
On which hour to purge old database dumps.
- *Default*: 2
purge_old_db_backups_minute
---------------------------
At which minute to purge old database dumps.
- *Default*: 0
===
## Class `puppet::lint` ##
### Parameters ###
ensure
------
Whether to install lint.
- *Default*: present
provider
--------
Which provider should supply lint.
- *Default*: gem
version
-------
If you do not want to use the default version of lint, specify which version you want to use here.
- *Default*: undef
lint_args
---------
Which args should be added to the .puppet-lint.rc file
- *Default*: --no-80chars-check
lintrc_path
-----------
The full path to the lint config file.
- *Default*: ${::root_home}/.puppet-lint.rc
lintrc_owner
------------
The owner of the lint config file.
- *Default*: root
lintrc_group
------------
The group of the lint config file.
- *Default*: root
lintrc_mode
-----------
The mode of the lint config file.
- *Default*: 0644
===
## Class `puppet::master` ##
### Usage ###
In Hiera you will need to specify the following.
<pre>
puppet::agent::is_puppet_master: 'true'
</pre>
### Parameters ###
sysconfig_path
--------------
The location of puppet master sysconfig file.
- *Default*: use defaults based on osfamily
vhost_path
----------
The location of puppet master vhost file for apache.
- *Default*: use defaults based on osfamily
rack_dir
--------
The rack directory path.
- *Default*: /usr/share/puppet/rack/puppetmasterd
puppet_user
-----------
The user the puppet master should run as.
- *Default*: puppet
manage_firewall
---------------
Whether to manage the firewall settings on the client
- *Default*: undef
===
## Class `puppet::master::maintenance` ##
### Parameters ###
clientbucket_path
-----------------
Path to where the clientbucket files are stored.
- *Default*: /var/lib/puppet/clientbucket
clientbucket_days_to_keep
-------------------------
diff --git a/manifests/agent.pp b/manifests/agent.pp
index e1fe593..c4be663 100755
--- a/manifests/agent.pp
+++ b/manifests/agent.pp
@@ -1,247 +1,257 @@
# == Class: puppet::agent
#
# Manage Puppet agents
#
# We also run puppet once at boot via cron, regardless of if you normally run
# puppet from cron or as a daemon.
#
class puppet::agent (
$certname = $::fqdn,
$config_path = '/etc/puppet/puppet.conf',
$config_owner = 'root',
$config_group = 'root',
$config_mode = '0644',
$env = $::env,
$puppet_server = 'puppet',
$puppet_masterport = 'UNSET',
$puppet_ca_server = 'UNSET',
+ $http_proxy_host = 'UNSET',
+ $http_proxy_port = 'UNSET',
$is_puppet_master = false,
$run_method = 'service',
$run_interval = '30',
$run_in_noop = false,
$cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay',
$run_at_boot = true,
$puppet_binary = '/usr/bin/puppet',
$symlink_puppet_binary_target = '/usr/local/bin/puppet',
$symlink_puppet_binary = false,
$agent_sysconfig = 'USE_DEFAULTS',
$agent_sysconfig_ensure = 'USE_DEFAULTS',
$daemon_name = 'puppet',
$stringify_facts = true,
$etckeeper_hooks = false,
) {
if type($run_in_noop) == 'String' {
$run_in_noop_bool = str2bool($run_in_noop)
} else {
$run_in_noop_bool = $run_in_noop
}
validate_bool($run_in_noop_bool)
if type($run_at_boot) == 'String' {
$run_at_boot_bool = str2bool($run_at_boot)
} else {
$run_at_boot_bool = $run_at_boot
}
validate_bool($run_at_boot_bool)
if type($is_puppet_master) == 'String' {
$is_puppet_master_bool = str2bool($is_puppet_master)
} else {
$is_puppet_master_bool = $is_puppet_master
}
validate_bool($is_puppet_master_bool)
# env must be set, else fail, since we use it in the puppet_config template
if ! $env {
fail('puppet::agent::env must be set')
}
if $puppet_masterport != 'UNSET' and is_integer($puppet_masterport) == false {
fail("puppet::agent::puppet_masterport is set to <${puppet_masterport}>. It should be an integer.")
}
if type($stringify_facts) == 'string' {
$stringify_facts_bool = str2bool($stringify_facts)
} else {
$stringify_facts_bool = $stringify_facts
}
validate_bool($stringify_facts_bool)
if type($etckeeper_hooks) == 'String' {
$etckeeper_hooks_bool = str2bool($etckeeper_hooks)
} else {
$etckeeper_hooks_bool = $etckeeper_hooks
}
validate_bool($etckeeper_hooks_bool)
+ if $http_proxy_host != 'UNSET' and (is_domain_name($http_proxy_host) == false and is_ip_address($http_proxy_host) == false){
+ fail("puppet::agent::http_proxy_host is set to <${http_proxy_host}>. It should be a fqdn or an ip-address.")
+ }
+
+ if $http_proxy_port != 'UNSET' and is_integer($http_proxy_port) == false {
+ fail("puppet::agent::http_proxy_port is set to <${http_proxy_port}>. It should be an Integer.")
+ }
+
case $::osfamily {
'Debian': {
$default_agent_sysconfig = '/etc/default/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'RedHat': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'Solaris': {
$default_agent_sysconfig = undef
$default_agent_sysconfig_ensure = 'absent'
}
'Suse': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
default: {
fail("puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <${::osfamily}>.")
}
}
if $agent_sysconfig == 'USE_DEFAULTS' {
$agent_sysconfig_real = $default_agent_sysconfig
} else {
$agent_sysconfig_real = $agent_sysconfig
}
if $agent_sysconfig_ensure == 'USE_DEFAULTS' {
$agent_sysconfig_ensure_real = $default_agent_sysconfig_ensure
} else {
$agent_sysconfig_ensure_real = $agent_sysconfig_ensure
}
if $is_puppet_master_bool == false {
$config_content = template('puppet/puppetagent.conf.erb')
} else {
$config_content = undef
}
case $run_method {
'service': {
$daemon_ensure = 'running'
$daemon_enable = true
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
'cron': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_run_one = fqdn_rand($run_interval)
$cron_run_two = fqdn_rand($run_interval) + 30
$cron_ensure = 'present'
$cron_user = 'root'
$cron_hour = '*'
$cron_minute = [$cron_run_one, $cron_run_two]
if $run_in_noop_bool == true {
$my_cron_command = "${cron_command} --noop"
} else {
$my_cron_command = $cron_command
}
}
'disable': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
default: {
fail("puppet::agent::run_method is ${run_method} and must be 'disable', 'service' or 'cron'.")
}
}
if $run_at_boot_bool == true {
$at_boot_ensure = 'present'
} else {
$at_boot_ensure = 'absent'
}
if type($symlink_puppet_binary) == 'string' {
$symlink_puppet_binary_bool = str2bool($symlink_puppet_binary)
} else {
$symlink_puppet_binary_bool = $symlink_puppet_binary
}
validate_bool($symlink_puppet_binary_bool)
# optionally create symlinks to puppet binary
if $symlink_puppet_binary_bool == true {
# validate params
validate_absolute_path($symlink_puppet_binary_target)
validate_absolute_path($puppet_binary)
file { 'puppet_symlink':
ensure => link,
path => $symlink_puppet_binary_target,
target => $puppet_binary,
}
}
file { 'puppet_config':
path => $config_path,
content => $config_content,
owner => $config_owner,
group => $config_group,
mode => $config_mode,
}
if ($etckeeper_hooks_bool) {
file { 'etckeeper_pre':
path => '/etc/puppet/etckeeper-commit-pre',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/puppet/etckeeper-commit-pre'
}
file { 'etckeeper_post':
path => '/etc/puppet/etckeeper-commit-post',
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/puppet/etckeeper-commit-post'
}
}
if $default_agent_sysconfig_ensure =~ /(present)|(file)/ {
file { 'puppet_agent_sysconfig':
ensure => $agent_sysconfig_ensure_real,
path => $agent_sysconfig_real,
content => template('puppet/agent_sysconfig.erb'),
owner => 'root',
group => 'root',
mode => '0644',
}
}
service { 'puppet_agent_daemon':
# GH: This service will always show as being running while an agent run is
# taking place, so we no longer ensure its status. Before doing this, there
# would *always* be a logged change and the Console could never be green.
#ensure => $daemon_ensure,
name => $daemon_name,
enable => $daemon_enable,
}
cron { 'puppet_agent':
ensure => $cron_ensure,
command => $my_cron_command,
user => $cron_user,
hour => $cron_hour,
minute => $cron_minute,
}
if $run_method == 'cron' {
cron { 'puppet_agent_once_at_boot':
ensure => $at_boot_ensure,
command => $my_cron_command,
user => $cron_user,
special => 'reboot',
}
}
}
diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb
index b01d31c..ee88511 100644
--- a/spec/classes/agent_spec.rb
+++ b/spec/classes/agent_spec.rb
@@ -1,575 +1,673 @@
require 'spec_helper'
describe 'puppet::agent' do
describe 'config file' do
context 'with default settings' do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/masterport =/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
+ it { should_not contain_file('puppet_config').with_content(/^\s*http_proxy_host =/) }
+ it { should_not contain_file('puppet_config').with_content(/^\s*http_proxy_port =/) }
it { should contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
it { should_not contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
['false',false].each do |value|
context "with is_puppet_master set to #{value} (default)" do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) do
{ :env => 'production',
:is_puppet_master => value,
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['true',true].each do |value|
context "with is_puppet_master set to #{value}" do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) do
{ :env => 'production',
:is_puppet_master => value,
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'content' => nil,
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should_not contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should_not contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should_not contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
end
describe 'with stringify_facts' do
['true',true].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['false',false].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = false$/) }
end
end
context 'set to an invalid setting' do
let(:params) do
{
:stringify_facts => 'invalid',
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
end
describe 'sysconfig file' do
context 'Puppet agent sysconfig file on osfamily RedHat' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Debian',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on Ubuntu' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Solaris' do
let(:facts) { { :osfamily => 'Solaris' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should_not contain_file('puppet_agent_sysconfig') }
end
context 'Puppet agent sysconfig file on osfamily Suse' do
let(:facts) { { :osfamily => 'Suse' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on invalid osfamily' do
let(:facts) { { :osfamily => 'invalid' } }
let(:params) { { :env => 'production' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <invalid>./)
end
end
end
describe 'with symlink_puppet_binary' do
['true',true].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/usr/local/bin/puppet',
'target' => '/usr/bin/puppet',
'ensure' => 'link',
})
}
end
end
['false',false].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it { should_not contain_file('puppet_symlink') }
end
end
context 'enabled with all params specified' do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => '/bar',
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/bar',
'target' => '/foo/bar',
'ensure' => 'link',
})
}
end
context 'enabled with invalid puppet_binary' do
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => 'true',
:symlink_puppet_binary_target => '/bar' } }
it do
expect { should }.to raise_error(Puppet::Error)
end
end
context 'enabled with invalid symlink_puppet_binary_target' do
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => 'undef' } }
it do
expect { should }.to raise_error(Puppet::Error)
end
end
end
describe 'with run_method' do
context 'set to disable' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'disable',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => false,
})
}
end
context 'set to service' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'service',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => true,
})
}
end
context 'set to cron' do
context 'with run_in_noop set to non-string and non-boolean' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => ['invalid_type','not_a_string','not_a_boolean'],
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
context 'with run_in_noop set to invalid string' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => 'invalid_string',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
# iterate through a matrix of setting true and false as booleans and
# strings for both run_in_noop and run_at_boot.
['true',true,'false',false].each do |rin_value|
context "with run_in_noop => #{rin_value}" do
['true',true,'false',false].each do |rab_value|
context "and run_at_boot => #{rab_value}" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => rin_value,
:run_at_boot => rab_value,
}
end
if rin_value == true or rin_value == 'true' then
command = "#{cron_command} --noop"
else
command = cron_command
end
if rab_value == true or rab_value == 'true' then
at_boot_ensure = 'present'
else
at_boot_ensure = 'absent'
end
it { should contain_class('puppet::agent') }
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'user' => 'root',
'command' => command,
})
}
it { should contain_cron('puppet_agent_once_at_boot').with({
'ensure' => at_boot_ensure,
'user' => 'root',
'command' => command,
'special' => 'reboot',
})
}
end
end
end
end
end
end
+
describe 'with puppet_masterport' do
context 'set to integer' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => '8888',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with_content(/^\s*masterport = 8888$/) }
end
context 'set to a string that is not an integer (foo)' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => 'foo',
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::puppet_masterport is set to <foo>. It should be an integer./)
end
end
context 'set to an invalid type (non-string)' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => ['invalid','type'],
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
end
+
describe 'with etckeeper_hooks' do
['true',true].each do |value|
context "set to #{value}" do
let(:params) do
{
:etckeeper_hooks => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('etckeeper_pre') }
it { should contain_file('etckeeper_post') }
it { should contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
it { should contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
end
['false',false].each do |value|
context "set to #{value}" do
let(:params) do
{
:etckeeper_hooks => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should_not contain_file('etckeeper_pre') }
it { should_not contain_file('etckeeper_post') }
it { should_not contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
it { should_not contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
end
context 'set to an invalid setting' do
let(:params) do
{
:etckeeper_hooks => 'invalid',
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
end
+
+ describe 'with http_proxy_host' do
+ context 'set to a valid domain' do
+ let(:facts) { { :osfamily => 'RedHat' } }
+ let(:params) do
+ { :http_proxy_host => 'proxy.host.local.domain',
+ :env => 'production',
+ }
+ end
+ it { should contain_class('puppet::agent') }
+ it {should contain_file('puppet_config').with_content(/^\s*http_proxy_host = proxy\.host\.local\.domain$/) }
+ end
+
+ ['8.8.8.8','2a00:1450:400f:804::1011'].each do |ip_address|
+ context "set to #{ip_address} (ip-address)" do
+ let(:facts) { { :osfamily => 'RedHat' } }
+ let(:params) do
+ { :env => 'production',
+ :http_proxy_host => ip_address,
+ }
+ end
+
+ it { should contain_file('puppet_config').with_content(/\s*http_proxy_host = #{Regexp.escape(ip_address)}$/) }
+ end
+ end
+ ['8.8.8.8.#','".#.%.!','foo..bar'].each do |invalid_value|
+ context "set to #{invalid_value} (invalid value)" do
+ let(:facts) { { :osfamily => 'RedHat' } }
+ let(:params) do
+ { :env => 'production',
+ :http_proxy_host => invalid_value,
+ }
+ end
+ it 'should fail' do
+ expect {
+ should contain_class('puppet::agent')
+ }.to raise_error(Puppet::Error,/puppet::agent::http_proxy_host is set to <#{Regexp.escape(invalid_value)}>. It should be a fqdn or an ip-address./)
+ end
+ end
+ end
+ context 'set to an invalid type' do
+ let(:facts) { { :osfamily => 'RedHat' } }
+ let(:params) do
+ { :http_proxy_host => ['invalid','type'],
+ :env => 'production',
+ }
+ end
+ it 'should fail' do
+ expect {
+ should contain_class('puppet::agent')
+ }.to raise_error(Puppet::Error)
+ end
+ end
+ end
+
+
+ describe 'with http_proxy_port' do
+ context 'set to integer' do
+ let(:facts) { { :osfamily => 'RedHat' } }
+ let(:params) do
+ { :http_proxy_port => '8888',
+ :env => 'production',
+ }
+ end
+ it { should contain_class('puppet::agent') }
+ it { should contain_file('puppet_config').with_content(/^\s*http_proxy_port = 8888$/) }
+ end
+ context 'set to an invalid type' do
+ let(:facts) { { :osfamily => 'RedHat' } }
+ let(:params) do
+ { :http_proxy_port => ['invalid','type'],
+ :env => 'production',
+ }
+ end
+ it 'should fail' do
+ expect {
+ should contain_class('puppet::agent')
+ }.to raise_error(Puppet::Error)
+ end
+ end
+ context 'set to an invalid value' do
+ let(:facts) { { :osfamily => 'RedHat' } }
+ let(:params) do
+ { :http_proxy_port => 'foo',
+ :env => 'production',
+ }
+ end
+ it 'should fail' do
+ expect {
+ should contain_class('puppet::agent')
+ }.to raise_error(Puppet::Error,/puppet::agent::http_proxy_port is set to <foo>. It should be an Integer./)
+ end
+ end
+ end
end
diff --git a/templates/puppetagent.conf.erb b/templates/puppetagent.conf.erb
index b0354ca..b3293b6 100644
--- a/templates/puppetagent.conf.erb
+++ b/templates/puppetagent.conf.erb
@@ -1,52 +1,54 @@
# This file is being maintained by Puppet.
# DO NOT EDIT
[main]
# The Puppet log directory.
# The default value is '$vardir/log'.
logdir = /var/log/puppet
# Where Puppet PID files are kept.
# The default value is '$vardir/run'.
rundir = /var/run/puppet
# Where SSL certificates are kept.
# The default value is '$confdir/ssl'.
ssldir = $vardir/ssl
archive_files = true
archive_file_server = <%= @puppet_server %>
# If stringify_facts is true, you have the classic facter fact that is
# always a string. If set to false, then you can use structured facts which
# were introduced in Facter v2
stringify_facts = <%= @stringify_facts_bool %>
<% if @etckeeper_hooks_bool == true %>
prerun_command=/etc/puppet/etckeeper-commit-pre
postrun_command=/etc/puppet/etckeeper-commit-post
<% end -%>
[agent]
# The file in which puppetd stores a list of the classes
# associated with the retrieved configuratiion. Can be loaded in
# the separate ``puppet`` executable using the ``--loadclasses``
# option.
# The default value is '$confdir/classes.txt'.
classfile = $vardir/classes.txt
# Where puppetd caches the local configuration. An
# extension indicating the cache format is added automatically.
# The default value is '$confdir/localconfig'.
localconfig = $vardir/localconfig
certname = <%= @certname %>
server = <%= @puppet_server %>
<% if @puppet_masterport != 'UNSET' %> masterport = <%= @puppet_masterport %><% end %>
<% if @puppet_ca_server != 'UNSET' %> ca_server = <%= @puppet_ca_server %><% end %>
+<% if @http_proxy_host != 'UNSET' %> http_proxy_host = <%= @http_proxy_host %><% end %>
+<% if @http_proxy_port != 'UNSET' %> http_proxy_port = <%= @http_proxy_port %><% end %>
report = true
graph = true
pluginsync = true
<% if @run_method == 'service' %> # run in noop mode?
noop = <%= @run_in_noop %>
<% end -%>
<% if @env != 'production' %> environment = <%= @env %><% end -%>
|
ghoneycutt/puppet-module-puppet
|
9468fd9009c8244ebc2c33e6252cdfeeb7f5cb98
|
Release v2.12.0 - Additional agent config settings and etckeeper support
|
diff --git a/Modulefile b/Modulefile
index 6a4f826..2108d28 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,17 +1,17 @@
name 'ghoneycutt-puppet'
-version '2.11.3'
+version '2.12.0'
source 'git://github.com/ghoneycutt/puppet-module-puppet.git'
author 'ghoneycutt'
license 'Apache License, Version 2.0'
summary 'Manage Puppet'
description 'Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.'
project_page 'https://github.com/ghoneycutt/puppet-module-puppet'
dependency 'ghoneycutt/common', '>= 1.0.3'
dependency 'leinaddm/htpasswd', '>= 0.0.1'
dependency 'puppetlabs/stdlib', '>= 3.2.0'
dependency 'puppetlabs/mysql', '>= 2.0.0'
dependency 'puppetlabs/passenger', '>= 0.0.4'
dependency 'puppetlabs/apache', '>= 0.5.0'
dependency 'puppetlabs/firewall', '>= 0.2.1'
dependency 'puppetlabs/concat', '>= 1.0.0'
diff --git a/metadata.json b/metadata.json
index 6cd0cda..e41cfac 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,92 +1,92 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.11.3",
+ "version": "2.12.0",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"license": "Apache License, Version 2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
5b7f650b25ef589319a933833054e654b7bc4cb6
|
Add support for etckeeper
|
diff --git a/README.md b/README.md
index 170c6b7..476772c 100644
--- a/README.md
+++ b/README.md
@@ -1,700 +1,706 @@
# puppet-module-puppet #
===
[](https://travis-ci.org/ghoneycutt/puppet-module-puppet)
This module handles the various parts of puppet on a given machine.
Dependencies for this module are: apache, common, mysql and passenger
## Components ##
### Agent
---------
- Manages the puppet agent on a client
- Setup of configuration files
- Setup of service or crontask to run the agent periodically
- Ensure puppet agent is run at boottime
### Master
----------
- Manages apache with passenger
- Setup of config files needed to run master
- Calls the `puppet::lint` class
- Calls the `puppet::master::maintenance` class
- Manages firewall rule for puppet if needed
- Maintenance to purge filebucket and reports
### Dashboard
-------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This installation is used by puppet systems, that need access to the dashboard
### Dashboard Server
--------------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This is the actual server running the Dashboard
- Configures the Dashboard MySQL settings
- Creates database for puppet with mysql module
- Calls the `puppet::dashboard::maintenance` class
- Maintenance to clean up old reports, optimize database and dump database
- For the maintenance cron jobs, you should have the following line in your `/etc/sudoers` which is not managed with this module.
<pre>
Defaults:root !requiretty
</pre>
### Lint
--------
- Manages [puppet-lint](http://github.com/rodjek/puppet-lint)
## Compatibility ##
-------------------
Ruby versions 1.8.7, 1.9.3, and 2.0.0 on Puppet 3.x
### Puppet Master
-----------------
* Debian 6
* Debian 7
* EL 6
* Ubuntu 12.04 LTS
### Puppet Agent
----------------
* Debian 6
* Debian 7
* EL 6
* EL 7
* Solaris
* Suse 11
* Ubuntu 12.04 LTS
===
## Class `puppet::agent` ##
### Parameters ###
certname
--------
The certificate name for the client.
- *Default*: $::fqdn
config_path
-----------
The location of the puppet config file.
- *Default*: /etc/puppet/puppet.conf
config_owner
------------
The owner of the config file.
- *Default*: root
config_group
------------
The group for the config file.
- *Default*: root
config_mode
-----------
The mode for the config file.
- *Default*: 0644
env
---
The selected environment for the client.
- *Default*: $::env
puppet_server
-------------
The puppet server the client should connect to.
- *Default*: puppet
puppet_masterport
-----------------
The masterport setting in puppet.conf. By default this line is not set.
- *Default*: UNSET
puppet_ca_server
----------------
The puppet CA server the client should use
- *Default*: UNSET
is_puppet_master
----------------
Whether the machine is a puppet master or not.
- *Default*: false
run_method
----------
Whether to run as a service or in cron mode. Valid values are `disable`, `cron`, and `service`. The value `disable` disables automatic puppet runs and assumes you are running as a service.
- *Default*: service
run_interval
------------
The interval with which the client should run (in minutes)
- *Default*: 30
run_in_noop
-----------
Whether the client should run in noop mode or not.
- *Default*: false
cron_command
------------
The command that should be added to the crontab (in cron mode)
- *Default*: /usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay
run_at_boot
-----------
Whether the client should run right after boot
- *Default*: true
puppet_binary
-------------
Path to puppet binary to create symlink from
- *Default*: '/usr/bin/puppet'
symlink_puppet_binary_target
----------------------------
Path to where the symlink should be created
- *Default*: '/usr/local/bin/puppet'
symlink_puppet_binary
---------------------
Boolean for ensuring a symlink for puppet_binary to symlink_puppet_binary_target. This is useful if you install puppet in a non-standard location that is not in your $PATH.
- *Default*: false
agent_sysconfig
---------------
The location of puppet agent sysconfig file.
- *Default*: use defaults based on osfamily
agent_sysconfig_ensure
----------------------
String for 'file' or 'present'. Allows you to not manage the sysconfig file.
- *Default*: use defaults based on osfamily
daemon_name
-----------
The name the puppet agent daemon should run as.
- *Default*: puppet
stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
- *Default*: true
+etckeeper_hooks
+---------------
+Boolean to include pre- and postrun hooks for etckeeper in the main section of the puppet agent's config.
+
+- *Default*: false
+
===
## Class `puppet::dashboard` ##
### Parameters ###
dashboard_package
-----------------
String or Array of the dashboard package(s) name.
- *Default*: 'puppet-dashboard'
dashboard_user
--------------
The user for dashboard installation.
- *Default*: use defaults based on osfamily
dashboard_group
--------------
The group for dashboard installation.
- *Default*: use defaults based on osfamily
sysconfig_path
-------------------
The location of puppet dashboard sysconfig file.
- *Default*: use defaults based on osfamily
external_node_script_path
-------------------------
The script to call from puppet to get manifests from dashboard.
- *Default*: /usr/share/puppet-dashboard/bin/external_node
dashboard_fqdn
--------------
The dashboard server FQDN.
- *Default*: puppet.${::domain}
port
----
The port the web server will respond to.
- *Default*: 3000
===
## Class `puppet::dashboard::server` ##
### Usage ###
You can optionally specify a hash of htpasswd entries in Hiera.
<pre>
---
puppet::dashboard::htpasswd:
admin:
cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
puppet:
cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
</pre>
### Parameters ###
dashboard_workers
-----------------
Number of dashboard workers to start. Only used on osfamily Debian.
- *Default*: $::processorcount
database_config_path
--------------------
The path to the database config file.
- *Default*: /usr/share/puppet-dashboard/config/database.yml
database_config_owner
---------------------
The owner of the database config file.
- *Default*: puppet-dashboard
database_config_group
---------------------
The database config file group.
- *Default*: puppet-dashboard
database_config_mode
--------------------
The database config file mode.
- *Default*: 0640
htpasswd
--------
Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
- *Default*: undef
htpasswd_path
-------------
String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
- *Default*: `/etc/puppet/dashboard.htpasswd`
htpasswd_owner
--------------
Owner of htpasswd file.
- *Default*: root
htpasswd_group
--------------
Group of htpasswd file.
- *Default*: use defaults based on osfamily
htpasswd_mode
-------------
Mode of htpasswd file.
- *Default*: 0640
log_dir
-------
The location for the puppet log files.
- *Default*: /var/log/puppet
mysql_user
----------
The user for the mysql connection.
- *Default*: dashboard
mysql_password
--------------
The password for the mysql connection.
- *Default*: puppet
mysql_max_packet_size
---------------------
The mysql max packet size.
- *Default*: 32M
security
--------
String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
- *Default*: 'none'
vhost_path
----------
The location of puppet dashboard vhost file for apache.
- *Default*: use defaults based on osfamily
===
## Class `puppet::dashboard::maintenance` ##
### Parameters ###
db_optimization_command
-----------------------
The command to run to optimize the db.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
db_optimization_user
--------------------
The user to run db optimization.
- *Default*: root
db_optimization_hour
--------------------
The hour on which to run db optimization.
- *Default*: 0
db_optimization_minute
----------------------
The minute at which to run db optimization.
- *Default*: 0
db_optimization_monthday
------------------------
The day of the month on which to run db optimization.
- *Default*: 1
reports_days_to_keep
--------------------
How many days to keep the reports.
- *Default*: 30
purge_old_reports_command
-------------------------
Which command to run to purge old reports.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=30 unit=day >> /var/log/puppet/dashboard_maintenance.log
purge_old_reports_user
----------------------
User to purge reports as.
- *Default*: root
purge_old_reports_hour
----------------------
On which hour to purge old reports.
- *Default*: 0
purge_old_reports_minute
------------------------
At which minute to purge old reports.
- *Default*: 30
remove_old_reports_spool
------------------------
Whether we should remove old dashboard reports that have not been imported
- *Default*: 'True'
reports_spool_dir
-----------------
Path to reports in dashboard spool
- *Default*: '/usr/share/puppet-dashboard/spool'
reports_spool_days_to_keep
--------------------------
How many days to keep the unimported reports.
remove_reports_spool_user
-------------------------
User to remove unimported reports.
- *Default*: root
remove_reports_spool_hour
-------------------------
On which hour to remove unimported reports.
- *Default*: 0
remove_reports_spool_minute
---------------------------
At which minute to remove unimported reports
- *Default*: 45
dump_dir
--------
The directory to use for dumps.
- *Default*: /var/local
dump_database_command
---------------------
The command to run to dump the database.
- *Default*: sudo -u puppet-dashboard /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log
dump_database_user
------------------
User to dump database as.
- *Default*: root
dump_database_hour
------------------
On which hour to dump database.
- *Default*: 1
dump_database_minute
--------------------
At which minute to purge old reports.
- *Default*: 0
days_to_keep_backups
--------------------
Number of days to keep database backups.
- *Default*: 7
purge_old_db_backups_user
-------------------------
User to purge old database dumps as.
- *Default*: root
purge_old_db_backups_hour
-------------------------
On which hour to purge old database dumps.
- *Default*: 2
purge_old_db_backups_minute
---------------------------
At which minute to purge old database dumps.
- *Default*: 0
===
## Class `puppet::lint` ##
### Parameters ###
ensure
------
Whether to install lint.
- *Default*: present
provider
--------
Which provider should supply lint.
- *Default*: gem
version
-------
If you do not want to use the default version of lint, specify which version you want to use here.
- *Default*: undef
lint_args
---------
Which args should be added to the .puppet-lint.rc file
- *Default*: --no-80chars-check
lintrc_path
-----------
The full path to the lint config file.
- *Default*: ${::root_home}/.puppet-lint.rc
lintrc_owner
------------
The owner of the lint config file.
- *Default*: root
lintrc_group
------------
The group of the lint config file.
- *Default*: root
lintrc_mode
-----------
The mode of the lint config file.
- *Default*: 0644
===
## Class `puppet::master` ##
### Usage ###
In Hiera you will need to specify the following.
<pre>
puppet::agent::is_puppet_master: 'true'
</pre>
### Parameters ###
sysconfig_path
--------------
The location of puppet master sysconfig file.
- *Default*: use defaults based on osfamily
vhost_path
----------
The location of puppet master vhost file for apache.
- *Default*: use defaults based on osfamily
rack_dir
--------
The rack directory path.
- *Default*: /usr/share/puppet/rack/puppetmasterd
puppet_user
-----------
The user the puppet master should run as.
- *Default*: puppet
manage_firewall
---------------
Whether to manage the firewall settings on the client
- *Default*: undef
===
## Class `puppet::master::maintenance` ##
### Parameters ###
clientbucket_path
-----------------
Path to where the clientbucket files are stored.
- *Default*: /var/lib/puppet/clientbucket
clientbucket_days_to_keep
-------------------------
The number of days to keep clientbuckets
- *Default*: 30
filebucket_cleanup_command
--------------------------
Command used to cleanup the clientbuckets.
- *Default*: /usr/bin/find ${clientbucket_path} -type f -mtime +30 -exec /bin/rm -fr {} \;
filebucket_cleanup_user
-----------------------
User to run the clientbucket cleanup as.
- *Default*: root
filebucket_cleanup_hour
-----------------------
Hour on which to run the filebucket cleanup.
- *Default*: 0
filebucket_cleanup_minute
-------------------------
Minute at which to run the filebucket cleanup.
- *Default*: 0
reportdir
---------
Directory that holds the reports. `$::puppet_reportdir` is a custom fact that reads the `reportdir` setting from Puppet's configuration. This is likely `/var/lib/puppet/reports/`.
- *Default*: $::puppet_reportdir
reportdir_days_to_key
---------------------
String for number of days of reports to keep. Must be a positive integer > 0.
- *Default*: '30'
reportdir_purge_command
-----------------------
Command ran by cron to purge old reports.
- *Default*: /usr/bin/find /var/lib/puppet/reports/ -type f -mtime +30 -exec /bin/rm -fr {} \;'
reportdir_purge_user
--------------------
User for the crontab entry to run the reportdir_purge_command.
- *Default*: root
reportdir_purge_hour
--------------------
Hour at which to run the reportdir_purge_command.
- *Default*: 0
reportdir_purge_minute
----------------------
Minute past the hour in which to run the reportdir_purge_command.
- *Default*: 15
diff --git a/files/etckeeper-commit-post b/files/etckeeper-commit-post
new file mode 100755
index 0000000..489b2bd
--- /dev/null
+++ b/files/etckeeper-commit-post
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+
+which etckeeper > /dev/null 2>&1 || exit 0
+
+etckeeper commit "committing changes in /etc after puppet catalog run"
+
+# Failure of etckeeper should not be fatal.
+exit 0
diff --git a/files/etckeeper-commit-pre b/files/etckeeper-commit-pre
new file mode 100755
index 0000000..a66fb62
--- /dev/null
+++ b/files/etckeeper-commit-pre
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+
+which etckeeper > /dev/null 2>&1 || exit 0
+
+etckeeper commit "saving uncommitted changes in /etc prior to puppet catalog run"
+
+# Failure of etckeeper should not be fatal.
+exit 0
diff --git a/manifests/agent.pp b/manifests/agent.pp
index 36beecf..e1fe593 100755
--- a/manifests/agent.pp
+++ b/manifests/agent.pp
@@ -1,221 +1,247 @@
# == Class: puppet::agent
#
# Manage Puppet agents
#
# We also run puppet once at boot via cron, regardless of if you normally run
# puppet from cron or as a daemon.
#
class puppet::agent (
$certname = $::fqdn,
$config_path = '/etc/puppet/puppet.conf',
$config_owner = 'root',
$config_group = 'root',
$config_mode = '0644',
$env = $::env,
$puppet_server = 'puppet',
$puppet_masterport = 'UNSET',
$puppet_ca_server = 'UNSET',
$is_puppet_master = false,
$run_method = 'service',
$run_interval = '30',
$run_in_noop = false,
$cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay',
$run_at_boot = true,
$puppet_binary = '/usr/bin/puppet',
$symlink_puppet_binary_target = '/usr/local/bin/puppet',
$symlink_puppet_binary = false,
$agent_sysconfig = 'USE_DEFAULTS',
$agent_sysconfig_ensure = 'USE_DEFAULTS',
$daemon_name = 'puppet',
$stringify_facts = true,
+ $etckeeper_hooks = false,
) {
if type($run_in_noop) == 'String' {
$run_in_noop_bool = str2bool($run_in_noop)
} else {
$run_in_noop_bool = $run_in_noop
}
validate_bool($run_in_noop_bool)
if type($run_at_boot) == 'String' {
$run_at_boot_bool = str2bool($run_at_boot)
} else {
$run_at_boot_bool = $run_at_boot
}
validate_bool($run_at_boot_bool)
if type($is_puppet_master) == 'String' {
$is_puppet_master_bool = str2bool($is_puppet_master)
} else {
$is_puppet_master_bool = $is_puppet_master
}
validate_bool($is_puppet_master_bool)
# env must be set, else fail, since we use it in the puppet_config template
if ! $env {
fail('puppet::agent::env must be set')
}
if $puppet_masterport != 'UNSET' and is_integer($puppet_masterport) == false {
fail("puppet::agent::puppet_masterport is set to <${puppet_masterport}>. It should be an integer.")
}
if type($stringify_facts) == 'string' {
$stringify_facts_bool = str2bool($stringify_facts)
} else {
$stringify_facts_bool = $stringify_facts
}
validate_bool($stringify_facts_bool)
+ if type($etckeeper_hooks) == 'String' {
+ $etckeeper_hooks_bool = str2bool($etckeeper_hooks)
+ } else {
+ $etckeeper_hooks_bool = $etckeeper_hooks
+ }
+ validate_bool($etckeeper_hooks_bool)
+
case $::osfamily {
'Debian': {
$default_agent_sysconfig = '/etc/default/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'RedHat': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'Solaris': {
$default_agent_sysconfig = undef
$default_agent_sysconfig_ensure = 'absent'
}
'Suse': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
default: {
fail("puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <${::osfamily}>.")
}
}
if $agent_sysconfig == 'USE_DEFAULTS' {
$agent_sysconfig_real = $default_agent_sysconfig
} else {
$agent_sysconfig_real = $agent_sysconfig
}
if $agent_sysconfig_ensure == 'USE_DEFAULTS' {
$agent_sysconfig_ensure_real = $default_agent_sysconfig_ensure
} else {
$agent_sysconfig_ensure_real = $agent_sysconfig_ensure
}
if $is_puppet_master_bool == false {
$config_content = template('puppet/puppetagent.conf.erb')
} else {
$config_content = undef
}
case $run_method {
'service': {
$daemon_ensure = 'running'
$daemon_enable = true
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
'cron': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_run_one = fqdn_rand($run_interval)
$cron_run_two = fqdn_rand($run_interval) + 30
$cron_ensure = 'present'
$cron_user = 'root'
$cron_hour = '*'
$cron_minute = [$cron_run_one, $cron_run_two]
if $run_in_noop_bool == true {
$my_cron_command = "${cron_command} --noop"
} else {
$my_cron_command = $cron_command
}
}
'disable': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
default: {
fail("puppet::agent::run_method is ${run_method} and must be 'disable', 'service' or 'cron'.")
}
}
if $run_at_boot_bool == true {
$at_boot_ensure = 'present'
} else {
$at_boot_ensure = 'absent'
}
if type($symlink_puppet_binary) == 'string' {
$symlink_puppet_binary_bool = str2bool($symlink_puppet_binary)
} else {
$symlink_puppet_binary_bool = $symlink_puppet_binary
}
validate_bool($symlink_puppet_binary_bool)
# optionally create symlinks to puppet binary
if $symlink_puppet_binary_bool == true {
# validate params
validate_absolute_path($symlink_puppet_binary_target)
validate_absolute_path($puppet_binary)
file { 'puppet_symlink':
ensure => link,
path => $symlink_puppet_binary_target,
target => $puppet_binary,
}
}
file { 'puppet_config':
path => $config_path,
content => $config_content,
owner => $config_owner,
group => $config_group,
mode => $config_mode,
}
+ if ($etckeeper_hooks_bool) {
+ file { 'etckeeper_pre':
+ path => '/etc/puppet/etckeeper-commit-pre',
+ owner => 'root',
+ group => 'root',
+ mode => '0755',
+ source => 'puppet:///modules/puppet/etckeeper-commit-pre'
+ }
+
+ file { 'etckeeper_post':
+ path => '/etc/puppet/etckeeper-commit-post',
+ owner => 'root',
+ group => 'root',
+ mode => '0755',
+ source => 'puppet:///modules/puppet/etckeeper-commit-post'
+ }
+ }
+
if $default_agent_sysconfig_ensure =~ /(present)|(file)/ {
file { 'puppet_agent_sysconfig':
ensure => $agent_sysconfig_ensure_real,
path => $agent_sysconfig_real,
content => template('puppet/agent_sysconfig.erb'),
owner => 'root',
group => 'root',
mode => '0644',
}
}
service { 'puppet_agent_daemon':
# GH: This service will always show as being running while an agent run is
# taking place, so we no longer ensure its status. Before doing this, there
# would *always* be a logged change and the Console could never be green.
#ensure => $daemon_ensure,
name => $daemon_name,
enable => $daemon_enable,
}
cron { 'puppet_agent':
ensure => $cron_ensure,
command => $my_cron_command,
user => $cron_user,
hour => $cron_hour,
minute => $cron_minute,
}
if $run_method == 'cron' {
cron { 'puppet_agent_once_at_boot':
ensure => $at_boot_ensure,
command => $my_cron_command,
user => $cron_user,
special => 'reboot',
}
}
}
diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb
index 15b8e2f..b01d31c 100644
--- a/spec/classes/agent_spec.rb
+++ b/spec/classes/agent_spec.rb
@@ -1,522 +1,575 @@
require 'spec_helper'
describe 'puppet::agent' do
describe 'config file' do
context 'with default settings' do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/masterport =/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
+ it { should_not contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
+ it { should_not contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
end
['false',false].each do |value|
context "with is_puppet_master set to #{value} (default)" do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) do
{ :env => 'production',
:is_puppet_master => value,
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['true',true].each do |value|
context "with is_puppet_master set to #{value}" do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) do
{ :env => 'production',
:is_puppet_master => value,
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'content' => nil,
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should_not contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should_not contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should_not contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
end
describe 'with stringify_facts' do
['true',true].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['false',false].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = false$/) }
end
end
context 'set to an invalid setting' do
let(:params) do
{
:stringify_facts => 'invalid',
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
end
describe 'sysconfig file' do
context 'Puppet agent sysconfig file on osfamily RedHat' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Debian',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on Ubuntu' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Solaris' do
let(:facts) { { :osfamily => 'Solaris' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should_not contain_file('puppet_agent_sysconfig') }
end
context 'Puppet agent sysconfig file on osfamily Suse' do
let(:facts) { { :osfamily => 'Suse' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on invalid osfamily' do
let(:facts) { { :osfamily => 'invalid' } }
let(:params) { { :env => 'production' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <invalid>./)
end
end
end
describe 'with symlink_puppet_binary' do
['true',true].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/usr/local/bin/puppet',
'target' => '/usr/bin/puppet',
'ensure' => 'link',
})
}
end
end
['false',false].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it { should_not contain_file('puppet_symlink') }
end
end
context 'enabled with all params specified' do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => '/bar',
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/bar',
'target' => '/foo/bar',
'ensure' => 'link',
})
}
end
context 'enabled with invalid puppet_binary' do
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => 'true',
:symlink_puppet_binary_target => '/bar' } }
it do
expect { should }.to raise_error(Puppet::Error)
end
end
context 'enabled with invalid symlink_puppet_binary_target' do
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => 'undef' } }
it do
expect { should }.to raise_error(Puppet::Error)
end
end
end
describe 'with run_method' do
context 'set to disable' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'disable',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => false,
})
}
end
context 'set to service' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'service',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => true,
})
}
end
context 'set to cron' do
context 'with run_in_noop set to non-string and non-boolean' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => ['invalid_type','not_a_string','not_a_boolean'],
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
context 'with run_in_noop set to invalid string' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => 'invalid_string',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
# iterate through a matrix of setting true and false as booleans and
# strings for both run_in_noop and run_at_boot.
['true',true,'false',false].each do |rin_value|
context "with run_in_noop => #{rin_value}" do
['true',true,'false',false].each do |rab_value|
context "and run_at_boot => #{rab_value}" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => rin_value,
:run_at_boot => rab_value,
}
end
if rin_value == true or rin_value == 'true' then
command = "#{cron_command} --noop"
else
command = cron_command
end
if rab_value == true or rab_value == 'true' then
at_boot_ensure = 'present'
else
at_boot_ensure = 'absent'
end
it { should contain_class('puppet::agent') }
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'user' => 'root',
'command' => command,
})
}
it { should contain_cron('puppet_agent_once_at_boot').with({
'ensure' => at_boot_ensure,
'user' => 'root',
'command' => command,
'special' => 'reboot',
})
}
end
end
end
end
end
end
describe 'with puppet_masterport' do
context 'set to integer' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => '8888',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with_content(/^\s*masterport = 8888$/) }
end
context 'set to a string that is not an integer (foo)' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => 'foo',
:env => 'production',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent::puppet_masterport is set to <foo>. It should be an integer./)
end
end
context 'set to an invalid type (non-string)' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => ['invalid','type'],
:env => 'production',
}
end
+ it 'should fail' do
+ expect {
+ should contain_class('puppet::agent')
+ }.to raise_error(Puppet::Error)
+ end
+ end
+ end
+ describe 'with etckeeper_hooks' do
+ ['true',true].each do |value|
+ context "set to #{value}" do
+ let(:params) do
+ {
+ :etckeeper_hooks => value,
+ :env => 'production',
+ }
+ end
+ let(:facts) { { :osfamily => 'RedHat' } }
+
+ it { should contain_file('etckeeper_pre') }
+ it { should contain_file('etckeeper_post') }
+ it { should contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
+ it { should contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
+ end
+ end
+
+ ['false',false].each do |value|
+ context "set to #{value}" do
+ let(:params) do
+ {
+ :etckeeper_hooks => value,
+ :env => 'production',
+ }
+ end
+ let(:facts) { { :osfamily => 'RedHat' } }
+
+ it { should_not contain_file('etckeeper_pre') }
+ it { should_not contain_file('etckeeper_post') }
+ it { should_not contain_file('puppet_config').with_content(/^\s*prerun_command=\/etc\/puppet\/etckeeper-commit-pre$/) }
+ it { should_not contain_file('puppet_config').with_content(/^\s*postrun_command=\/etc\/puppet\/etckeeper-commit-post$/) }
+ end
+ end
+
+ context 'set to an invalid setting' do
+ let(:params) do
+ {
+ :etckeeper_hooks => 'invalid',
+ :env => 'production',
+ }
+ end
+ let(:facts) { { :osfamily => 'RedHat' } }
+
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
end
end
diff --git a/templates/puppetagent.conf.erb b/templates/puppetagent.conf.erb
index e87d47b..b0354ca 100644
--- a/templates/puppetagent.conf.erb
+++ b/templates/puppetagent.conf.erb
@@ -1,48 +1,52 @@
# This file is being maintained by Puppet.
# DO NOT EDIT
[main]
# The Puppet log directory.
# The default value is '$vardir/log'.
logdir = /var/log/puppet
# Where Puppet PID files are kept.
# The default value is '$vardir/run'.
rundir = /var/run/puppet
# Where SSL certificates are kept.
# The default value is '$confdir/ssl'.
ssldir = $vardir/ssl
archive_files = true
archive_file_server = <%= @puppet_server %>
# If stringify_facts is true, you have the classic facter fact that is
# always a string. If set to false, then you can use structured facts which
# were introduced in Facter v2
stringify_facts = <%= @stringify_facts_bool %>
+<% if @etckeeper_hooks_bool == true %>
+ prerun_command=/etc/puppet/etckeeper-commit-pre
+ postrun_command=/etc/puppet/etckeeper-commit-post
+<% end -%>
[agent]
# The file in which puppetd stores a list of the classes
# associated with the retrieved configuratiion. Can be loaded in
# the separate ``puppet`` executable using the ``--loadclasses``
# option.
# The default value is '$confdir/classes.txt'.
classfile = $vardir/classes.txt
# Where puppetd caches the local configuration. An
# extension indicating the cache format is added automatically.
# The default value is '$confdir/localconfig'.
localconfig = $vardir/localconfig
certname = <%= @certname %>
server = <%= @puppet_server %>
<% if @puppet_masterport != 'UNSET' %> masterport = <%= @puppet_masterport %><% end %>
<% if @puppet_ca_server != 'UNSET' %> ca_server = <%= @puppet_ca_server %><% end %>
report = true
graph = true
pluginsync = true
<% if @run_method == 'service' %> # run in noop mode?
noop = <%= @run_in_noop %>
<% end -%>
<% if @env != 'production' %> environment = <%= @env %><% end -%>
|
ghoneycutt/puppet-module-puppet
|
7adbff50543213cf3f9fe2183548de818f5ed0c8
|
Fixup masterport commit - Add test and simplify logic
|
diff --git a/manifests/agent.pp b/manifests/agent.pp
index e382d4f..36beecf 100755
--- a/manifests/agent.pp
+++ b/manifests/agent.pp
@@ -1,223 +1,221 @@
# == Class: puppet::agent
#
# Manage Puppet agents
#
# We also run puppet once at boot via cron, regardless of if you normally run
# puppet from cron or as a daemon.
#
class puppet::agent (
$certname = $::fqdn,
$config_path = '/etc/puppet/puppet.conf',
$config_owner = 'root',
$config_group = 'root',
$config_mode = '0644',
$env = $::env,
$puppet_server = 'puppet',
$puppet_masterport = 'UNSET',
$puppet_ca_server = 'UNSET',
$is_puppet_master = false,
$run_method = 'service',
$run_interval = '30',
$run_in_noop = false,
$cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay',
$run_at_boot = true,
$puppet_binary = '/usr/bin/puppet',
$symlink_puppet_binary_target = '/usr/local/bin/puppet',
$symlink_puppet_binary = false,
$agent_sysconfig = 'USE_DEFAULTS',
$agent_sysconfig_ensure = 'USE_DEFAULTS',
$daemon_name = 'puppet',
$stringify_facts = true,
) {
if type($run_in_noop) == 'String' {
$run_in_noop_bool = str2bool($run_in_noop)
} else {
$run_in_noop_bool = $run_in_noop
}
validate_bool($run_in_noop_bool)
if type($run_at_boot) == 'String' {
$run_at_boot_bool = str2bool($run_at_boot)
} else {
$run_at_boot_bool = $run_at_boot
}
validate_bool($run_at_boot_bool)
if type($is_puppet_master) == 'String' {
$is_puppet_master_bool = str2bool($is_puppet_master)
} else {
$is_puppet_master_bool = $is_puppet_master
}
validate_bool($is_puppet_master_bool)
# env must be set, else fail, since we use it in the puppet_config template
if ! $env {
fail('puppet::agent::env must be set')
}
- unless $puppet_masterport == 'UNSET' {
- unless is_integer($puppet_masterport) {
- fail("puppet::agent::puppet_masterport is set to '${puppet_masterport}'. It should be an integer.")
- }
+ if $puppet_masterport != 'UNSET' and is_integer($puppet_masterport) == false {
+ fail("puppet::agent::puppet_masterport is set to <${puppet_masterport}>. It should be an integer.")
}
if type($stringify_facts) == 'string' {
$stringify_facts_bool = str2bool($stringify_facts)
} else {
$stringify_facts_bool = $stringify_facts
}
validate_bool($stringify_facts_bool)
case $::osfamily {
'Debian': {
$default_agent_sysconfig = '/etc/default/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'RedHat': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'Solaris': {
$default_agent_sysconfig = undef
$default_agent_sysconfig_ensure = 'absent'
}
'Suse': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
default: {
fail("puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <${::osfamily}>.")
}
}
if $agent_sysconfig == 'USE_DEFAULTS' {
$agent_sysconfig_real = $default_agent_sysconfig
} else {
$agent_sysconfig_real = $agent_sysconfig
}
if $agent_sysconfig_ensure == 'USE_DEFAULTS' {
$agent_sysconfig_ensure_real = $default_agent_sysconfig_ensure
} else {
$agent_sysconfig_ensure_real = $agent_sysconfig_ensure
}
if $is_puppet_master_bool == false {
$config_content = template('puppet/puppetagent.conf.erb')
} else {
$config_content = undef
}
case $run_method {
'service': {
$daemon_ensure = 'running'
$daemon_enable = true
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
'cron': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_run_one = fqdn_rand($run_interval)
$cron_run_two = fqdn_rand($run_interval) + 30
$cron_ensure = 'present'
$cron_user = 'root'
$cron_hour = '*'
$cron_minute = [$cron_run_one, $cron_run_two]
if $run_in_noop_bool == true {
$my_cron_command = "${cron_command} --noop"
} else {
$my_cron_command = $cron_command
}
}
'disable': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
default: {
fail("puppet::agent::run_method is ${run_method} and must be 'disable', 'service' or 'cron'.")
}
}
if $run_at_boot_bool == true {
$at_boot_ensure = 'present'
} else {
$at_boot_ensure = 'absent'
}
if type($symlink_puppet_binary) == 'string' {
$symlink_puppet_binary_bool = str2bool($symlink_puppet_binary)
} else {
$symlink_puppet_binary_bool = $symlink_puppet_binary
}
validate_bool($symlink_puppet_binary_bool)
# optionally create symlinks to puppet binary
if $symlink_puppet_binary_bool == true {
# validate params
validate_absolute_path($symlink_puppet_binary_target)
validate_absolute_path($puppet_binary)
file { 'puppet_symlink':
ensure => link,
path => $symlink_puppet_binary_target,
target => $puppet_binary,
}
}
file { 'puppet_config':
path => $config_path,
content => $config_content,
owner => $config_owner,
group => $config_group,
mode => $config_mode,
}
if $default_agent_sysconfig_ensure =~ /(present)|(file)/ {
file { 'puppet_agent_sysconfig':
ensure => $agent_sysconfig_ensure_real,
path => $agent_sysconfig_real,
content => template('puppet/agent_sysconfig.erb'),
owner => 'root',
group => 'root',
mode => '0644',
}
}
service { 'puppet_agent_daemon':
# GH: This service will always show as being running while an agent run is
# taking place, so we no longer ensure its status. Before doing this, there
# would *always* be a logged change and the Console could never be green.
#ensure => $daemon_ensure,
name => $daemon_name,
enable => $daemon_enable,
}
cron { 'puppet_agent':
ensure => $cron_ensure,
command => $my_cron_command,
user => $cron_user,
hour => $cron_hour,
minute => $cron_minute,
}
if $run_method == 'cron' {
cron { 'puppet_agent_once_at_boot':
ensure => $at_boot_ensure,
command => $my_cron_command,
user => $cron_user,
special => 'reboot',
}
}
}
diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb
index df67e5b..15b8e2f 100644
--- a/spec/classes/agent_spec.rb
+++ b/spec/classes/agent_spec.rb
@@ -1,506 +1,522 @@
require 'spec_helper'
describe 'puppet::agent' do
describe 'config file' do
context 'with default settings' do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/masterport =/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
['false',false].each do |value|
context "with is_puppet_master set to #{value} (default)" do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) do
{ :env => 'production',
:is_puppet_master => value,
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['true',true].each do |value|
context "with is_puppet_master set to #{value}" do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) do
{ :env => 'production',
:is_puppet_master => value,
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'content' => nil,
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should_not contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should_not contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should_not contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
end
describe 'with stringify_facts' do
['true',true].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['false',false].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = false$/) }
end
end
context 'set to an invalid setting' do
let(:params) do
{
:stringify_facts => 'invalid',
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
end
describe 'sysconfig file' do
context 'Puppet agent sysconfig file on osfamily RedHat' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Debian',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on Ubuntu' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Solaris' do
let(:facts) { { :osfamily => 'Solaris' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should_not contain_file('puppet_agent_sysconfig') }
end
context 'Puppet agent sysconfig file on osfamily Suse' do
let(:facts) { { :osfamily => 'Suse' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on invalid osfamily' do
let(:facts) { { :osfamily => 'invalid' } }
let(:params) { { :env => 'production' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <invalid>./)
end
end
end
describe 'with symlink_puppet_binary' do
['true',true].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/usr/local/bin/puppet',
'target' => '/usr/bin/puppet',
'ensure' => 'link',
})
}
end
end
['false',false].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it { should_not contain_file('puppet_symlink') }
end
end
context 'enabled with all params specified' do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => '/bar',
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/bar',
'target' => '/foo/bar',
'ensure' => 'link',
})
}
end
context 'enabled with invalid puppet_binary' do
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => 'true',
:symlink_puppet_binary_target => '/bar' } }
it do
expect { should }.to raise_error(Puppet::Error)
end
end
context 'enabled with invalid symlink_puppet_binary_target' do
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => 'undef' } }
it do
expect { should }.to raise_error(Puppet::Error)
end
end
end
describe 'with run_method' do
context 'set to disable' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'disable',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => false,
})
}
end
context 'set to service' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'service',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => true,
})
}
end
context 'set to cron' do
context 'with run_in_noop set to non-string and non-boolean' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => ['invalid_type','not_a_string','not_a_boolean'],
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
context 'with run_in_noop set to invalid string' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => 'invalid_string',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
# iterate through a matrix of setting true and false as booleans and
# strings for both run_in_noop and run_at_boot.
['true',true,'false',false].each do |rin_value|
context "with run_in_noop => #{rin_value}" do
['true',true,'false',false].each do |rab_value|
context "and run_at_boot => #{rab_value}" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => rin_value,
:run_at_boot => rab_value,
}
end
if rin_value == true or rin_value == 'true' then
command = "#{cron_command} --noop"
else
command = cron_command
end
if rab_value == true or rab_value == 'true' then
at_boot_ensure = 'present'
else
at_boot_ensure = 'absent'
end
it { should contain_class('puppet::agent') }
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'user' => 'root',
'command' => command,
})
}
it { should contain_cron('puppet_agent_once_at_boot').with({
'ensure' => at_boot_ensure,
'user' => 'root',
'command' => command,
'special' => 'reboot',
})
}
end
end
end
end
end
end
describe 'with puppet_masterport' do
context 'set to integer' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => '8888',
- :env => 'production',
+ :env => 'production',
}
end
- it {
- should contain_class('puppet::agent')
- should contain_file('puppet_config').with_content(/^\s*masterport = 8888$/)
- }
+
+ it { should contain_class('puppet::agent') }
+ it { should contain_file('puppet_config').with_content(/^\s*masterport = 8888$/) }
end
- context 'set to foo' do
+
+ context 'set to a string that is not an integer (foo)' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :puppet_masterport => 'foo',
- :env => 'production',
+ :env => 'production',
+ }
+ end
+
+ it 'should fail' do
+ expect {
+ should contain_class('puppet::agent')
+ }.to raise_error(Puppet::Error,/puppet::agent::puppet_masterport is set to <foo>. It should be an integer./)
+ end
+ end
+
+ context 'set to an invalid type (non-string)' do
+ let(:facts) { { :osfamily => 'RedHat' } }
+ let(:params) do
+ { :puppet_masterport => ['invalid','type'],
+ :env => 'production',
}
end
+
it 'should fail' do
expect {
should contain_class('puppet::agent')
- }.to raise_error(Puppet::Error,/puppet::agent::puppet_masterport is set to 'foo'. It should be an integer./)
+ }.to raise_error(Puppet::Error)
end
end
end
end
|
ghoneycutt/puppet-module-puppet
|
d552f37a8c236cbe8ec4eafc0c9b10ed053d73b4
|
Add parameter for master's port in agent's config
|
diff --git a/README.md b/README.md
index 1f3fd06..170c6b7 100644
--- a/README.md
+++ b/README.md
@@ -1,631 +1,637 @@
# puppet-module-puppet #
===
[](https://travis-ci.org/ghoneycutt/puppet-module-puppet)
This module handles the various parts of puppet on a given machine.
Dependencies for this module are: apache, common, mysql and passenger
## Components ##
### Agent
---------
- Manages the puppet agent on a client
- Setup of configuration files
- Setup of service or crontask to run the agent periodically
- Ensure puppet agent is run at boottime
### Master
----------
- Manages apache with passenger
- Setup of config files needed to run master
- Calls the `puppet::lint` class
- Calls the `puppet::master::maintenance` class
- Manages firewall rule for puppet if needed
- Maintenance to purge filebucket and reports
### Dashboard
-------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This installation is used by puppet systems, that need access to the dashboard
### Dashboard Server
--------------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This is the actual server running the Dashboard
- Configures the Dashboard MySQL settings
- Creates database for puppet with mysql module
- Calls the `puppet::dashboard::maintenance` class
- Maintenance to clean up old reports, optimize database and dump database
- For the maintenance cron jobs, you should have the following line in your `/etc/sudoers` which is not managed with this module.
<pre>
Defaults:root !requiretty
</pre>
### Lint
--------
- Manages [puppet-lint](http://github.com/rodjek/puppet-lint)
## Compatibility ##
-------------------
Ruby versions 1.8.7, 1.9.3, and 2.0.0 on Puppet 3.x
### Puppet Master
-----------------
* Debian 6
* Debian 7
* EL 6
* Ubuntu 12.04 LTS
### Puppet Agent
----------------
* Debian 6
* Debian 7
* EL 6
* EL 7
* Solaris
* Suse 11
* Ubuntu 12.04 LTS
===
## Class `puppet::agent` ##
### Parameters ###
certname
--------
The certificate name for the client.
- *Default*: $::fqdn
config_path
-----------
The location of the puppet config file.
- *Default*: /etc/puppet/puppet.conf
config_owner
------------
The owner of the config file.
- *Default*: root
config_group
------------
The group for the config file.
- *Default*: root
config_mode
-----------
The mode for the config file.
- *Default*: 0644
env
---
The selected environment for the client.
- *Default*: $::env
puppet_server
-------------
The puppet server the client should connect to.
- *Default*: puppet
+puppet_masterport
+-----------------
+The masterport setting in puppet.conf. By default this line is not set.
+
+- *Default*: UNSET
+
puppet_ca_server
----------------
The puppet CA server the client should use
- *Default*: UNSET
is_puppet_master
----------------
Whether the machine is a puppet master or not.
- *Default*: false
run_method
----------
Whether to run as a service or in cron mode. Valid values are `disable`, `cron`, and `service`. The value `disable` disables automatic puppet runs and assumes you are running as a service.
- *Default*: service
run_interval
------------
The interval with which the client should run (in minutes)
- *Default*: 30
run_in_noop
-----------
Whether the client should run in noop mode or not.
- *Default*: false
cron_command
------------
The command that should be added to the crontab (in cron mode)
- *Default*: /usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay
run_at_boot
-----------
Whether the client should run right after boot
- *Default*: true
puppet_binary
-------------
Path to puppet binary to create symlink from
- *Default*: '/usr/bin/puppet'
symlink_puppet_binary_target
----------------------------
Path to where the symlink should be created
- *Default*: '/usr/local/bin/puppet'
symlink_puppet_binary
---------------------
Boolean for ensuring a symlink for puppet_binary to symlink_puppet_binary_target. This is useful if you install puppet in a non-standard location that is not in your $PATH.
- *Default*: false
agent_sysconfig
---------------
The location of puppet agent sysconfig file.
- *Default*: use defaults based on osfamily
agent_sysconfig_ensure
----------------------
String for 'file' or 'present'. Allows you to not manage the sysconfig file.
- *Default*: use defaults based on osfamily
daemon_name
-----------
The name the puppet agent daemon should run as.
- *Default*: puppet
stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
- *Default*: true
===
## Class `puppet::dashboard` ##
### Parameters ###
dashboard_package
-----------------
String or Array of the dashboard package(s) name.
- *Default*: 'puppet-dashboard'
dashboard_user
--------------
The user for dashboard installation.
- *Default*: use defaults based on osfamily
dashboard_group
--------------
The group for dashboard installation.
- *Default*: use defaults based on osfamily
sysconfig_path
-------------------
The location of puppet dashboard sysconfig file.
- *Default*: use defaults based on osfamily
external_node_script_path
-------------------------
The script to call from puppet to get manifests from dashboard.
- *Default*: /usr/share/puppet-dashboard/bin/external_node
dashboard_fqdn
--------------
The dashboard server FQDN.
- *Default*: puppet.${::domain}
port
----
The port the web server will respond to.
- *Default*: 3000
===
## Class `puppet::dashboard::server` ##
### Usage ###
You can optionally specify a hash of htpasswd entries in Hiera.
<pre>
---
puppet::dashboard::htpasswd:
admin:
cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
puppet:
cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
</pre>
### Parameters ###
dashboard_workers
-----------------
Number of dashboard workers to start. Only used on osfamily Debian.
- *Default*: $::processorcount
database_config_path
--------------------
The path to the database config file.
- *Default*: /usr/share/puppet-dashboard/config/database.yml
database_config_owner
---------------------
The owner of the database config file.
- *Default*: puppet-dashboard
database_config_group
---------------------
The database config file group.
- *Default*: puppet-dashboard
database_config_mode
--------------------
The database config file mode.
- *Default*: 0640
htpasswd
--------
Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
- *Default*: undef
htpasswd_path
-------------
String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
- *Default*: `/etc/puppet/dashboard.htpasswd`
htpasswd_owner
--------------
Owner of htpasswd file.
- *Default*: root
htpasswd_group
--------------
Group of htpasswd file.
- *Default*: use defaults based on osfamily
htpasswd_mode
-------------
Mode of htpasswd file.
- *Default*: 0640
log_dir
-------
The location for the puppet log files.
- *Default*: /var/log/puppet
mysql_user
----------
The user for the mysql connection.
- *Default*: dashboard
mysql_password
--------------
The password for the mysql connection.
- *Default*: puppet
mysql_max_packet_size
---------------------
The mysql max packet size.
- *Default*: 32M
security
--------
String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
- *Default*: 'none'
vhost_path
----------
The location of puppet dashboard vhost file for apache.
- *Default*: use defaults based on osfamily
===
## Class `puppet::dashboard::maintenance` ##
### Parameters ###
db_optimization_command
-----------------------
The command to run to optimize the db.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
db_optimization_user
--------------------
The user to run db optimization.
- *Default*: root
db_optimization_hour
--------------------
The hour on which to run db optimization.
- *Default*: 0
db_optimization_minute
----------------------
The minute at which to run db optimization.
- *Default*: 0
db_optimization_monthday
------------------------
The day of the month on which to run db optimization.
- *Default*: 1
reports_days_to_keep
--------------------
How many days to keep the reports.
- *Default*: 30
purge_old_reports_command
-------------------------
Which command to run to purge old reports.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=30 unit=day >> /var/log/puppet/dashboard_maintenance.log
purge_old_reports_user
----------------------
User to purge reports as.
- *Default*: root
purge_old_reports_hour
----------------------
On which hour to purge old reports.
- *Default*: 0
purge_old_reports_minute
------------------------
At which minute to purge old reports.
- *Default*: 30
remove_old_reports_spool
------------------------
Whether we should remove old dashboard reports that have not been imported
- *Default*: 'True'
reports_spool_dir
-----------------
Path to reports in dashboard spool
- *Default*: '/usr/share/puppet-dashboard/spool'
reports_spool_days_to_keep
--------------------------
How many days to keep the unimported reports.
remove_reports_spool_user
-------------------------
User to remove unimported reports.
- *Default*: root
remove_reports_spool_hour
-------------------------
On which hour to remove unimported reports.
- *Default*: 0
remove_reports_spool_minute
---------------------------
At which minute to remove unimported reports
- *Default*: 45
dump_dir
--------
The directory to use for dumps.
- *Default*: /var/local
dump_database_command
---------------------
The command to run to dump the database.
- *Default*: sudo -u puppet-dashboard /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log
dump_database_user
------------------
User to dump database as.
- *Default*: root
dump_database_hour
------------------
On which hour to dump database.
- *Default*: 1
dump_database_minute
--------------------
At which minute to purge old reports.
- *Default*: 0
days_to_keep_backups
--------------------
Number of days to keep database backups.
- *Default*: 7
purge_old_db_backups_user
-------------------------
User to purge old database dumps as.
- *Default*: root
purge_old_db_backups_hour
-------------------------
On which hour to purge old database dumps.
- *Default*: 2
purge_old_db_backups_minute
---------------------------
At which minute to purge old database dumps.
- *Default*: 0
===
## Class `puppet::lint` ##
### Parameters ###
ensure
------
Whether to install lint.
- *Default*: present
provider
--------
Which provider should supply lint.
- *Default*: gem
version
-------
If you do not want to use the default version of lint, specify which version you want to use here.
- *Default*: undef
lint_args
---------
Which args should be added to the .puppet-lint.rc file
- *Default*: --no-80chars-check
lintrc_path
-----------
The full path to the lint config file.
- *Default*: ${::root_home}/.puppet-lint.rc
lintrc_owner
------------
The owner of the lint config file.
- *Default*: root
lintrc_group
------------
The group of the lint config file.
- *Default*: root
lintrc_mode
-----------
The mode of the lint config file.
- *Default*: 0644
===
## Class `puppet::master` ##
### Usage ###
In Hiera you will need to specify the following.
<pre>
puppet::agent::is_puppet_master: 'true'
</pre>
### Parameters ###
sysconfig_path
--------------
The location of puppet master sysconfig file.
- *Default*: use defaults based on osfamily
vhost_path
----------
The location of puppet master vhost file for apache.
- *Default*: use defaults based on osfamily
rack_dir
--------
The rack directory path.
- *Default*: /usr/share/puppet/rack/puppetmasterd
puppet_user
-----------
The user the puppet master should run as.
- *Default*: puppet
manage_firewall
---------------
Whether to manage the firewall settings on the client
- *Default*: undef
===
## Class `puppet::master::maintenance` ##
### Parameters ###
clientbucket_path
-----------------
Path to where the clientbucket files are stored.
- *Default*: /var/lib/puppet/clientbucket
clientbucket_days_to_keep
-------------------------
diff --git a/manifests/agent.pp b/manifests/agent.pp
index 250b600..e382d4f 100755
--- a/manifests/agent.pp
+++ b/manifests/agent.pp
@@ -1,216 +1,223 @@
# == Class: puppet::agent
#
# Manage Puppet agents
#
# We also run puppet once at boot via cron, regardless of if you normally run
# puppet from cron or as a daemon.
#
class puppet::agent (
$certname = $::fqdn,
$config_path = '/etc/puppet/puppet.conf',
$config_owner = 'root',
$config_group = 'root',
$config_mode = '0644',
$env = $::env,
$puppet_server = 'puppet',
+ $puppet_masterport = 'UNSET',
$puppet_ca_server = 'UNSET',
$is_puppet_master = false,
$run_method = 'service',
$run_interval = '30',
$run_in_noop = false,
$cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay',
$run_at_boot = true,
$puppet_binary = '/usr/bin/puppet',
$symlink_puppet_binary_target = '/usr/local/bin/puppet',
$symlink_puppet_binary = false,
$agent_sysconfig = 'USE_DEFAULTS',
$agent_sysconfig_ensure = 'USE_DEFAULTS',
$daemon_name = 'puppet',
$stringify_facts = true,
) {
if type($run_in_noop) == 'String' {
$run_in_noop_bool = str2bool($run_in_noop)
} else {
$run_in_noop_bool = $run_in_noop
}
validate_bool($run_in_noop_bool)
if type($run_at_boot) == 'String' {
$run_at_boot_bool = str2bool($run_at_boot)
} else {
$run_at_boot_bool = $run_at_boot
}
validate_bool($run_at_boot_bool)
if type($is_puppet_master) == 'String' {
$is_puppet_master_bool = str2bool($is_puppet_master)
} else {
$is_puppet_master_bool = $is_puppet_master
}
validate_bool($is_puppet_master_bool)
# env must be set, else fail, since we use it in the puppet_config template
if ! $env {
fail('puppet::agent::env must be set')
}
+ unless $puppet_masterport == 'UNSET' {
+ unless is_integer($puppet_masterport) {
+ fail("puppet::agent::puppet_masterport is set to '${puppet_masterport}'. It should be an integer.")
+ }
+ }
+
if type($stringify_facts) == 'string' {
$stringify_facts_bool = str2bool($stringify_facts)
} else {
$stringify_facts_bool = $stringify_facts
}
validate_bool($stringify_facts_bool)
case $::osfamily {
'Debian': {
$default_agent_sysconfig = '/etc/default/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'RedHat': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
'Solaris': {
$default_agent_sysconfig = undef
$default_agent_sysconfig_ensure = 'absent'
}
'Suse': {
$default_agent_sysconfig = '/etc/sysconfig/puppet'
$default_agent_sysconfig_ensure = 'file'
}
default: {
fail("puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <${::osfamily}>.")
}
}
if $agent_sysconfig == 'USE_DEFAULTS' {
$agent_sysconfig_real = $default_agent_sysconfig
} else {
$agent_sysconfig_real = $agent_sysconfig
}
if $agent_sysconfig_ensure == 'USE_DEFAULTS' {
$agent_sysconfig_ensure_real = $default_agent_sysconfig_ensure
} else {
$agent_sysconfig_ensure_real = $agent_sysconfig_ensure
}
if $is_puppet_master_bool == false {
$config_content = template('puppet/puppetagent.conf.erb')
} else {
$config_content = undef
}
case $run_method {
'service': {
$daemon_ensure = 'running'
$daemon_enable = true
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
'cron': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_run_one = fqdn_rand($run_interval)
$cron_run_two = fqdn_rand($run_interval) + 30
$cron_ensure = 'present'
$cron_user = 'root'
$cron_hour = '*'
$cron_minute = [$cron_run_one, $cron_run_two]
if $run_in_noop_bool == true {
$my_cron_command = "${cron_command} --noop"
} else {
$my_cron_command = $cron_command
}
}
'disable': {
$daemon_ensure = 'stopped'
$daemon_enable = false
$cron_ensure = 'absent'
$my_cron_command = undef
$cron_user = undef
$cron_hour = undef
$cron_minute = undef
}
default: {
fail("puppet::agent::run_method is ${run_method} and must be 'disable', 'service' or 'cron'.")
}
}
if $run_at_boot_bool == true {
$at_boot_ensure = 'present'
} else {
$at_boot_ensure = 'absent'
}
if type($symlink_puppet_binary) == 'string' {
$symlink_puppet_binary_bool = str2bool($symlink_puppet_binary)
} else {
$symlink_puppet_binary_bool = $symlink_puppet_binary
}
validate_bool($symlink_puppet_binary_bool)
# optionally create symlinks to puppet binary
if $symlink_puppet_binary_bool == true {
# validate params
validate_absolute_path($symlink_puppet_binary_target)
validate_absolute_path($puppet_binary)
file { 'puppet_symlink':
ensure => link,
path => $symlink_puppet_binary_target,
target => $puppet_binary,
}
}
file { 'puppet_config':
path => $config_path,
content => $config_content,
owner => $config_owner,
group => $config_group,
mode => $config_mode,
}
if $default_agent_sysconfig_ensure =~ /(present)|(file)/ {
file { 'puppet_agent_sysconfig':
ensure => $agent_sysconfig_ensure_real,
path => $agent_sysconfig_real,
content => template('puppet/agent_sysconfig.erb'),
owner => 'root',
group => 'root',
mode => '0644',
}
}
service { 'puppet_agent_daemon':
# GH: This service will always show as being running while an agent run is
# taking place, so we no longer ensure its status. Before doing this, there
# would *always* be a logged change and the Console could never be green.
#ensure => $daemon_ensure,
name => $daemon_name,
enable => $daemon_enable,
}
cron { 'puppet_agent':
ensure => $cron_ensure,
command => $my_cron_command,
user => $cron_user,
hour => $cron_hour,
minute => $cron_minute,
}
if $run_method == 'cron' {
cron { 'puppet_agent_once_at_boot':
ensure => $at_boot_ensure,
command => $my_cron_command,
user => $cron_user,
special => 'reboot',
}
}
}
diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb
index 1ebe7ed..df67e5b 100644
--- a/spec/classes/agent_spec.rb
+++ b/spec/classes/agent_spec.rb
@@ -1,478 +1,506 @@
require 'spec_helper'
describe 'puppet::agent' do
describe 'config file' do
context 'with default settings' do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
+ it { should_not contain_file('puppet_config').with_content(/masterport =/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
['false',false].each do |value|
context "with is_puppet_master set to #{value} (default)" do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) do
{ :env => 'production',
:is_puppet_master => value,
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['true',true].each do |value|
context "with is_puppet_master set to #{value}" do
let(:facts) do
{ :osfamily => 'RedHat',
:fqdn => 'agent.example.com',
}
end
let(:params) do
{ :env => 'production',
:is_puppet_master => value,
}
end
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_config').with({
'path' => '/etc/puppet/puppet.conf',
'content' => nil,
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should_not contain_file('puppet_config').with_content(/^\ *logdir = \/var\/log\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *rundir = \/var\/run\/puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *ssldir = \$vardir\/ssl$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_files = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *archive_file_server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *classfile = \$vardir\/classes.txt$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *localconfig = \$vardir\/localconfig$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *certname = agent.example.com$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *server = puppet$/) }
it { should_not contain_file('puppet_config').with_content(/ca_server =/) }
it { should_not contain_file('puppet_config').with_content(/^\ *report = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *graph = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *pluginsync = true$/) }
it { should_not contain_file('puppet_config').with_content(/^\ *noop = false$/) }
it { should_not contain_file('puppet_config').with_content(/environment = production/) }
it { should_not contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
end
describe 'with stringify_facts' do
['true',true].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = true$/) }
end
end
['false',false].each do |value|
context "set to #{value}" do
let(:params) do
{
:stringify_facts => value,
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it { should contain_file('puppet_config').with_content(/^\s*stringify_facts = false$/) }
end
end
context 'set to an invalid setting' do
let(:params) do
{
:stringify_facts => 'invalid',
:env => 'production',
}
end
let(:facts) { { :osfamily => 'RedHat' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
end
describe 'sysconfig file' do
context 'Puppet agent sysconfig file on osfamily RedHat' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Debian' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Debian',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on Ubuntu' do
let(:facts) do
{ :osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
}
end
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/default/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on osfamily Solaris' do
let(:facts) { { :osfamily => 'Solaris' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should_not contain_file('puppet_agent_sysconfig') }
end
context 'Puppet agent sysconfig file on osfamily Suse' do
let(:facts) { { :osfamily => 'Suse' } }
let(:params) { { :env => 'production' } }
it { should contain_class('puppet::agent') }
it { should contain_file('puppet_agent_sysconfig').with({
'path' => '/etc/sysconfig/puppet',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
it { should contain_file('puppet_agent_sysconfig').with_content(/^#PUPPET_SERVER=puppet$/) }
end
context 'Puppet agent sysconfig file on invalid osfamily' do
let(:facts) { { :osfamily => 'invalid' } }
let(:params) { { :env => 'production' } }
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/puppet::agent supports osfamilies Debian, RedHat, Solaris, and Suse. Detected osfamily is <invalid>./)
end
end
end
describe 'with symlink_puppet_binary' do
['true',true].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/usr/local/bin/puppet',
'target' => '/usr/bin/puppet',
'ensure' => 'link',
})
}
end
end
['false',false].each do |value|
context "set to #{value} (default)" do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => value,
}
end
it { should_not contain_file('puppet_symlink') }
end
end
context 'enabled with all params specified' do
let(:facts) { { :osfamily => 'Debian' } }
let(:params) do
{ :env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => '/bar',
}
end
it {
should contain_file('puppet_symlink').with({
'path' => '/bar',
'target' => '/foo/bar',
'ensure' => 'link',
})
}
end
context 'enabled with invalid puppet_binary' do
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => 'true',
:symlink_puppet_binary_target => '/bar' } }
it do
expect { should }.to raise_error(Puppet::Error)
end
end
context 'enabled with invalid symlink_puppet_binary_target' do
let(:params) { {:env => 'production',
:symlink_puppet_binary => true,
:puppet_binary => '/foo/bar',
:symlink_puppet_binary_target => 'undef' } }
it do
expect { should }.to raise_error(Puppet::Error)
end
end
end
describe 'with run_method' do
context 'set to disable' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'disable',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => false,
})
}
end
context 'set to service' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'service',
:env => 'production',
}
end
it { should contain_class('puppet::agent') }
it { should contain_cron('puppet_agent').with({
'ensure' => 'absent'
})
}
it { should_not contain_cron('puppet_agent_once_at_boot') }
it { should contain_service('puppet_agent_daemon').with({
'enable' => true,
})
}
end
context 'set to cron' do
context 'with run_in_noop set to non-string and non-boolean' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => ['invalid_type','not_a_string','not_a_boolean'],
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
context 'with run_in_noop set to invalid string' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => 'invalid_string',
}
end
it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error)
end
end
cron_command = '/usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay'
# iterate through a matrix of setting true and false as booleans and
# strings for both run_in_noop and run_at_boot.
['true',true,'false',false].each do |rin_value|
context "with run_in_noop => #{rin_value}" do
['true',true,'false',false].each do |rab_value|
context "and run_at_boot => #{rab_value}" do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) do
{ :run_method => 'cron',
:env => 'production',
:run_in_noop => rin_value,
:run_at_boot => rab_value,
}
end
if rin_value == true or rin_value == 'true' then
command = "#{cron_command} --noop"
else
command = cron_command
end
if rab_value == true or rab_value == 'true' then
at_boot_ensure = 'present'
else
at_boot_ensure = 'absent'
end
it { should contain_class('puppet::agent') }
it {
should contain_cron('puppet_agent').with({
'ensure' => 'present',
'user' => 'root',
'command' => command,
})
}
it { should contain_cron('puppet_agent_once_at_boot').with({
'ensure' => at_boot_ensure,
'user' => 'root',
'command' => command,
'special' => 'reboot',
})
}
end
end
end
end
end
end
+ describe 'with puppet_masterport' do
+ context 'set to integer' do
+ let(:facts) { { :osfamily => 'RedHat' } }
+ let(:params) do
+ { :puppet_masterport => '8888',
+ :env => 'production',
+ }
+ end
+ it {
+ should contain_class('puppet::agent')
+ should contain_file('puppet_config').with_content(/^\s*masterport = 8888$/)
+ }
+ end
+ context 'set to foo' do
+ let(:facts) { { :osfamily => 'RedHat' } }
+ let(:params) do
+ { :puppet_masterport => 'foo',
+ :env => 'production',
+ }
+ end
+ it 'should fail' do
+ expect {
+ should contain_class('puppet::agent')
+ }.to raise_error(Puppet::Error,/puppet::agent::puppet_masterport is set to 'foo'. It should be an integer./)
+ end
+ end
+ end
end
diff --git a/templates/puppetagent.conf.erb b/templates/puppetagent.conf.erb
index e02fc08..e87d47b 100644
--- a/templates/puppetagent.conf.erb
+++ b/templates/puppetagent.conf.erb
@@ -1,47 +1,48 @@
# This file is being maintained by Puppet.
# DO NOT EDIT
[main]
# The Puppet log directory.
# The default value is '$vardir/log'.
logdir = /var/log/puppet
# Where Puppet PID files are kept.
# The default value is '$vardir/run'.
rundir = /var/run/puppet
# Where SSL certificates are kept.
# The default value is '$confdir/ssl'.
ssldir = $vardir/ssl
archive_files = true
archive_file_server = <%= @puppet_server %>
# If stringify_facts is true, you have the classic facter fact that is
# always a string. If set to false, then you can use structured facts which
# were introduced in Facter v2
stringify_facts = <%= @stringify_facts_bool %>
[agent]
# The file in which puppetd stores a list of the classes
# associated with the retrieved configuratiion. Can be loaded in
# the separate ``puppet`` executable using the ``--loadclasses``
# option.
# The default value is '$confdir/classes.txt'.
classfile = $vardir/classes.txt
# Where puppetd caches the local configuration. An
# extension indicating the cache format is added automatically.
# The default value is '$confdir/localconfig'.
localconfig = $vardir/localconfig
certname = <%= @certname %>
server = <%= @puppet_server %>
+<% if @puppet_masterport != 'UNSET' %> masterport = <%= @puppet_masterport %><% end %>
<% if @puppet_ca_server != 'UNSET' %> ca_server = <%= @puppet_ca_server %><% end %>
report = true
graph = true
pluginsync = true
<% if @run_method == 'service' %> # run in noop mode?
noop = <%= @run_in_noop %>
<% end -%>
<% if @env != 'production' %> environment = <%= @env %><% end -%>
|
ghoneycutt/puppet-module-puppet
|
d1fff625cb4e8ac9a7f92d6c0d6948b084901bb1
|
Release v2.11.3 - Support EL7 for agents
|
diff --git a/Modulefile b/Modulefile
index 40cd2cd..6a4f826 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,17 +1,17 @@
name 'ghoneycutt-puppet'
-version '2.11.2'
+version '2.11.3'
source 'git://github.com/ghoneycutt/puppet-module-puppet.git'
author 'ghoneycutt'
license 'Apache License, Version 2.0'
summary 'Manage Puppet'
description 'Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.'
project_page 'https://github.com/ghoneycutt/puppet-module-puppet'
dependency 'ghoneycutt/common', '>= 1.0.3'
dependency 'leinaddm/htpasswd', '>= 0.0.1'
dependency 'puppetlabs/stdlib', '>= 3.2.0'
dependency 'puppetlabs/mysql', '>= 2.0.0'
dependency 'puppetlabs/passenger', '>= 0.0.4'
dependency 'puppetlabs/apache', '>= 0.5.0'
dependency 'puppetlabs/firewall', '>= 0.2.1'
dependency 'puppetlabs/concat', '>= 1.0.0'
diff --git a/README.md b/README.md
index 64e9cee..1f3fd06 100644
--- a/README.md
+++ b/README.md
@@ -1,578 +1,579 @@
# puppet-module-puppet #
===
[](https://travis-ci.org/ghoneycutt/puppet-module-puppet)
This module handles the various parts of puppet on a given machine.
Dependencies for this module are: apache, common, mysql and passenger
## Components ##
### Agent
---------
- Manages the puppet agent on a client
- Setup of configuration files
- Setup of service or crontask to run the agent periodically
- Ensure puppet agent is run at boottime
### Master
----------
- Manages apache with passenger
- Setup of config files needed to run master
- Calls the `puppet::lint` class
- Calls the `puppet::master::maintenance` class
- Manages firewall rule for puppet if needed
- Maintenance to purge filebucket and reports
### Dashboard
-------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This installation is used by puppet systems, that need access to the dashboard
### Dashboard Server
--------------------
- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This is the actual server running the Dashboard
- Configures the Dashboard MySQL settings
- Creates database for puppet with mysql module
- Calls the `puppet::dashboard::maintenance` class
- Maintenance to clean up old reports, optimize database and dump database
- For the maintenance cron jobs, you should have the following line in your `/etc/sudoers` which is not managed with this module.
<pre>
Defaults:root !requiretty
</pre>
### Lint
--------
- Manages [puppet-lint](http://github.com/rodjek/puppet-lint)
## Compatibility ##
-------------------
Ruby versions 1.8.7, 1.9.3, and 2.0.0 on Puppet 3.x
### Puppet Master
-----------------
* Debian 6
* Debian 7
* EL 6
* Ubuntu 12.04 LTS
### Puppet Agent
----------------
* Debian 6
* Debian 7
* EL 6
+* EL 7
* Solaris
* Suse 11
* Ubuntu 12.04 LTS
===
## Class `puppet::agent` ##
### Parameters ###
certname
--------
The certificate name for the client.
- *Default*: $::fqdn
config_path
-----------
The location of the puppet config file.
- *Default*: /etc/puppet/puppet.conf
config_owner
------------
The owner of the config file.
- *Default*: root
config_group
------------
The group for the config file.
- *Default*: root
config_mode
-----------
The mode for the config file.
- *Default*: 0644
env
---
The selected environment for the client.
- *Default*: $::env
puppet_server
-------------
The puppet server the client should connect to.
- *Default*: puppet
puppet_ca_server
----------------
The puppet CA server the client should use
- *Default*: UNSET
is_puppet_master
----------------
Whether the machine is a puppet master or not.
- *Default*: false
run_method
----------
Whether to run as a service or in cron mode. Valid values are `disable`, `cron`, and `service`. The value `disable` disables automatic puppet runs and assumes you are running as a service.
- *Default*: service
run_interval
------------
The interval with which the client should run (in minutes)
- *Default*: 30
run_in_noop
-----------
Whether the client should run in noop mode or not.
- *Default*: false
cron_command
------------
The command that should be added to the crontab (in cron mode)
- *Default*: /usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay
run_at_boot
-----------
Whether the client should run right after boot
- *Default*: true
puppet_binary
-------------
Path to puppet binary to create symlink from
- *Default*: '/usr/bin/puppet'
symlink_puppet_binary_target
----------------------------
Path to where the symlink should be created
- *Default*: '/usr/local/bin/puppet'
symlink_puppet_binary
---------------------
Boolean for ensuring a symlink for puppet_binary to symlink_puppet_binary_target. This is useful if you install puppet in a non-standard location that is not in your $PATH.
- *Default*: false
agent_sysconfig
---------------
The location of puppet agent sysconfig file.
- *Default*: use defaults based on osfamily
agent_sysconfig_ensure
----------------------
String for 'file' or 'present'. Allows you to not manage the sysconfig file.
- *Default*: use defaults based on osfamily
daemon_name
-----------
The name the puppet agent daemon should run as.
- *Default*: puppet
stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
- *Default*: true
===
## Class `puppet::dashboard` ##
### Parameters ###
dashboard_package
-----------------
String or Array of the dashboard package(s) name.
- *Default*: 'puppet-dashboard'
dashboard_user
--------------
The user for dashboard installation.
- *Default*: use defaults based on osfamily
dashboard_group
--------------
The group for dashboard installation.
- *Default*: use defaults based on osfamily
sysconfig_path
-------------------
The location of puppet dashboard sysconfig file.
- *Default*: use defaults based on osfamily
external_node_script_path
-------------------------
The script to call from puppet to get manifests from dashboard.
- *Default*: /usr/share/puppet-dashboard/bin/external_node
dashboard_fqdn
--------------
The dashboard server FQDN.
- *Default*: puppet.${::domain}
port
----
The port the web server will respond to.
- *Default*: 3000
===
## Class `puppet::dashboard::server` ##
### Usage ###
You can optionally specify a hash of htpasswd entries in Hiera.
<pre>
---
puppet::dashboard::htpasswd:
admin:
cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
puppet:
cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
</pre>
### Parameters ###
dashboard_workers
-----------------
Number of dashboard workers to start. Only used on osfamily Debian.
- *Default*: $::processorcount
database_config_path
--------------------
The path to the database config file.
- *Default*: /usr/share/puppet-dashboard/config/database.yml
database_config_owner
---------------------
The owner of the database config file.
- *Default*: puppet-dashboard
database_config_group
---------------------
The database config file group.
- *Default*: puppet-dashboard
database_config_mode
--------------------
The database config file mode.
- *Default*: 0640
htpasswd
--------
Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
- *Default*: undef
htpasswd_path
-------------
String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
- *Default*: `/etc/puppet/dashboard.htpasswd`
htpasswd_owner
--------------
Owner of htpasswd file.
- *Default*: root
htpasswd_group
--------------
Group of htpasswd file.
- *Default*: use defaults based on osfamily
htpasswd_mode
-------------
Mode of htpasswd file.
- *Default*: 0640
log_dir
-------
The location for the puppet log files.
- *Default*: /var/log/puppet
mysql_user
----------
The user for the mysql connection.
- *Default*: dashboard
mysql_password
--------------
The password for the mysql connection.
- *Default*: puppet
mysql_max_packet_size
---------------------
The mysql max packet size.
- *Default*: 32M
security
--------
String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
- *Default*: 'none'
vhost_path
----------
The location of puppet dashboard vhost file for apache.
- *Default*: use defaults based on osfamily
===
## Class `puppet::dashboard::maintenance` ##
### Parameters ###
db_optimization_command
-----------------------
The command to run to optimize the db.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
db_optimization_user
--------------------
The user to run db optimization.
- *Default*: root
db_optimization_hour
--------------------
The hour on which to run db optimization.
- *Default*: 0
db_optimization_minute
----------------------
The minute at which to run db optimization.
- *Default*: 0
db_optimization_monthday
------------------------
The day of the month on which to run db optimization.
- *Default*: 1
reports_days_to_keep
--------------------
How many days to keep the reports.
- *Default*: 30
purge_old_reports_command
-------------------------
Which command to run to purge old reports.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=30 unit=day >> /var/log/puppet/dashboard_maintenance.log
purge_old_reports_user
----------------------
User to purge reports as.
- *Default*: root
purge_old_reports_hour
----------------------
On which hour to purge old reports.
- *Default*: 0
purge_old_reports_minute
------------------------
At which minute to purge old reports.
- *Default*: 30
remove_old_reports_spool
------------------------
Whether we should remove old dashboard reports that have not been imported
- *Default*: 'True'
reports_spool_dir
-----------------
Path to reports in dashboard spool
- *Default*: '/usr/share/puppet-dashboard/spool'
reports_spool_days_to_keep
--------------------------
How many days to keep the unimported reports.
remove_reports_spool_user
-------------------------
User to remove unimported reports.
- *Default*: root
remove_reports_spool_hour
-------------------------
On which hour to remove unimported reports.
- *Default*: 0
remove_reports_spool_minute
---------------------------
At which minute to remove unimported reports
- *Default*: 45
dump_dir
--------
The directory to use for dumps.
- *Default*: /var/local
dump_database_command
---------------------
The command to run to dump the database.
- *Default*: sudo -u puppet-dashboard /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log
dump_database_user
------------------
User to dump database as.
- *Default*: root
dump_database_hour
------------------
On which hour to dump database.
- *Default*: 1
dump_database_minute
--------------------
At which minute to purge old reports.
- *Default*: 0
days_to_keep_backups
--------------------
Number of days to keep database backups.
- *Default*: 7
purge_old_db_backups_user
-------------------------
User to purge old database dumps as.
- *Default*: root
purge_old_db_backups_hour
-------------------------
On which hour to purge old database dumps.
- *Default*: 2
purge_old_db_backups_minute
---------------------------
At which minute to purge old database dumps.
- *Default*: 0
===
## Class `puppet::lint` ##
### Parameters ###
ensure
------
Whether to install lint.
- *Default*: present
provider
--------
Which provider should supply lint.
- *Default*: gem
version
-------
If you do not want to use the default version of lint, specify which version you want to use here.
- *Default*: undef
lint_args
---------
Which args should be added to the .puppet-lint.rc file
- *Default*: --no-80chars-check
lintrc_path
-----------
The full path to the lint config file.
- *Default*: ${::root_home}/.puppet-lint.rc
lintrc_owner
------------
The owner of the lint config file.
- *Default*: root
lintrc_group
------------
The group of the lint config file.
- *Default*: root
lintrc_mode
-----------
The mode of the lint config file.
- *Default*: 0644
===
## Class `puppet::master` ##
### Usage ###
diff --git a/metadata.json b/metadata.json
index 3fe7f00..6cd0cda 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,88 +1,92 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.11.2",
+ "version": "2.11.3",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"license": "Apache License, Version 2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
- "6"
+ "6",
+ "7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
- "6"
+ "6",
+ "7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
- "6"
+ "6",
+ "7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
- "6"
+ "6",
+ "7"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
a295f71b63ea47bbdd2981190ea6ee50a69cafa1
|
Release v2.11.2 - bugfix for metadata
|
diff --git a/Modulefile b/Modulefile
index 7b301aa..40cd2cd 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,17 +1,17 @@
name 'ghoneycutt-puppet'
-version '2.11.1'
+version '2.11.2'
source 'git://github.com/ghoneycutt/puppet-module-puppet.git'
author 'ghoneycutt'
license 'Apache License, Version 2.0'
summary 'Manage Puppet'
description 'Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.'
project_page 'https://github.com/ghoneycutt/puppet-module-puppet'
dependency 'ghoneycutt/common', '>= 1.0.3'
dependency 'leinaddm/htpasswd', '>= 0.0.1'
dependency 'puppetlabs/stdlib', '>= 3.2.0'
dependency 'puppetlabs/mysql', '>= 2.0.0'
dependency 'puppetlabs/passenger', '>= 0.0.4'
dependency 'puppetlabs/apache', '>= 0.5.0'
dependency 'puppetlabs/firewall', '>= 0.2.1'
dependency 'puppetlabs/concat', '>= 1.0.0'
diff --git a/metadata.json b/metadata.json
index fac615a..3fe7f00 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,88 +1,88 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.11.1",
+ "version": "2.11.2",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"license": "Apache License, Version 2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
{"name":"ghoneycutt/common","version_requirement":">= 1.0.3"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
8fdc57c44e3516f1f36f5bdd5ff8ef8a65d10800
|
Support Puppet v3.7.0
|
diff --git a/.travis.yml b/.travis.yml
index be395a9..00d4941 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,16 +1,17 @@
---
env:
- PUPPET_VERSION=3.3.2
- PUPPET_VERSION=3.4.2
- PUPPET_VERSION=3.5.1
- PUPPET_VERSION=3.6.0
+- PUPPET_VERSION=3.7.0
notifications:
email: false
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
language: ruby
before_script: 'gem install --no-ri --no-rdoc bundler'
script: 'bundle exec rake validate && bundle exec rake lint && SPEC_OPTS="--format documentation" bundle exec rake spec'
gemfile: Gemfile
|
ghoneycutt/puppet-module-puppet
|
7703805657026326b7429597f532ce16fdbd9b19
|
Fix version metadata
|
diff --git a/Modulefile b/Modulefile
index e191a19..7b301aa 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,17 +1,17 @@
name 'ghoneycutt-puppet'
version '2.11.1'
source 'git://github.com/ghoneycutt/puppet-module-puppet.git'
author 'ghoneycutt'
license 'Apache License, Version 2.0'
summary 'Manage Puppet'
description 'Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.'
project_page 'https://github.com/ghoneycutt/puppet-module-puppet'
-dependency 'ghoneycutt/common', '>= v1.0.3'
+dependency 'ghoneycutt/common', '>= 1.0.3'
dependency 'leinaddm/htpasswd', '>= 0.0.1'
dependency 'puppetlabs/stdlib', '>= 3.2.0'
dependency 'puppetlabs/mysql', '>= 2.0.0'
dependency 'puppetlabs/passenger', '>= 0.0.4'
dependency 'puppetlabs/apache', '>= 0.5.0'
dependency 'puppetlabs/firewall', '>= 0.2.1'
dependency 'puppetlabs/concat', '>= 1.0.0'
|
ghoneycutt/puppet-module-puppet
|
9c9dcc7bfa5e787141293bb9d1a91a1aa89183fe
|
Fixup malformed dependency in metadata.json that triggers backtrace in librarian-puppet
|
diff --git a/metadata.json b/metadata.json
index bccc48d..fac615a 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,88 +1,88 @@
{
"name": "ghoneycutt-puppet",
"version": "2.11.1",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"license": "Apache License, Version 2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
- {"name":"ghoneycutt/common","version_requirement":">= v1.0.3"},
+ {"name":"ghoneycutt/common","version_requirement":">= 1.0.3"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
af82a91214db575d37721a76d95a6c355a31e026
|
Add dependency of ghoneycutt/common to metadata
|
diff --git a/Modulefile b/Modulefile
index 3fb926c..e191a19 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,16 +1,17 @@
name 'ghoneycutt-puppet'
-version '2.11.0'
+version '2.11.1'
source 'git://github.com/ghoneycutt/puppet-module-puppet.git'
author 'ghoneycutt'
license 'Apache License, Version 2.0'
summary 'Manage Puppet'
description 'Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.'
project_page 'https://github.com/ghoneycutt/puppet-module-puppet'
+dependency 'ghoneycutt/common', '>= v1.0.3'
dependency 'leinaddm/htpasswd', '>= 0.0.1'
dependency 'puppetlabs/stdlib', '>= 3.2.0'
dependency 'puppetlabs/mysql', '>= 2.0.0'
dependency 'puppetlabs/passenger', '>= 0.0.4'
dependency 'puppetlabs/apache', '>= 0.5.0'
dependency 'puppetlabs/firewall', '>= 0.2.1'
dependency 'puppetlabs/concat', '>= 1.0.0'
diff --git a/metadata.json b/metadata.json
index e4e7c76..bccc48d 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,87 +1,88 @@
{
"name": "ghoneycutt-puppet",
- "version": "2.11.0",
+ "version": "2.11.1",
"author": "ghoneycutt",
"summary": "Manage Puppet",
"license": "Apache License, Version 2.0",
"source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
"project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
"issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
+ {"name":"ghoneycutt/common","version_requirement":">= v1.0.3"},
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
]
}
|
ghoneycutt/puppet-module-puppet
|
a02377dbec2dbbbe61520ce09e298e902188be81
|
replaced dead links for dashboard
|
diff --git a/README.md b/README.md
index 836aee4..64e9cee 100644
--- a/README.md
+++ b/README.md
@@ -1,547 +1,547 @@
# puppet-module-puppet #
===
[](https://travis-ci.org/ghoneycutt/puppet-module-puppet)
This module handles the various parts of puppet on a given machine.
Dependencies for this module are: apache, common, mysql and passenger
## Components ##
### Agent
---------
- Manages the puppet agent on a client
- Setup of configuration files
- Setup of service or crontask to run the agent periodically
- Ensure puppet agent is run at boottime
### Master
----------
- Manages apache with passenger
- Setup of config files needed to run master
- Calls the `puppet::lint` class
- Calls the `puppet::master::maintenance` class
- Manages firewall rule for puppet if needed
- Maintenance to purge filebucket and reports
### Dashboard
-------------
-- Manages [Puppet Dashboard](https://puppetlabs.com/puppet/related-projects/dashboard/)
+- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This installation is used by puppet systems, that need access to the dashboard
### Dashboard Server
--------------------
-- Manages [Puppet Dashboard](https://puppetlabs.com/puppet/related-projects/dashboard/)
+- Manages [Puppet Dashboard](https://github.com/sodabrew/puppet-dashboard)
- This is the actual server running the Dashboard
- Configures the Dashboard MySQL settings
- Creates database for puppet with mysql module
- Calls the `puppet::dashboard::maintenance` class
- Maintenance to clean up old reports, optimize database and dump database
- For the maintenance cron jobs, you should have the following line in your `/etc/sudoers` which is not managed with this module.
<pre>
Defaults:root !requiretty
</pre>
### Lint
--------
- Manages [puppet-lint](http://github.com/rodjek/puppet-lint)
## Compatibility ##
-------------------
Ruby versions 1.8.7, 1.9.3, and 2.0.0 on Puppet 3.x
### Puppet Master
-----------------
* Debian 6
* Debian 7
* EL 6
* Ubuntu 12.04 LTS
### Puppet Agent
----------------
* Debian 6
* Debian 7
* EL 6
* Solaris
* Suse 11
* Ubuntu 12.04 LTS
===
## Class `puppet::agent` ##
### Parameters ###
certname
--------
The certificate name for the client.
- *Default*: $::fqdn
config_path
-----------
The location of the puppet config file.
- *Default*: /etc/puppet/puppet.conf
config_owner
------------
The owner of the config file.
- *Default*: root
config_group
------------
The group for the config file.
- *Default*: root
config_mode
-----------
The mode for the config file.
- *Default*: 0644
env
---
The selected environment for the client.
- *Default*: $::env
puppet_server
-------------
The puppet server the client should connect to.
- *Default*: puppet
puppet_ca_server
----------------
The puppet CA server the client should use
- *Default*: UNSET
is_puppet_master
----------------
Whether the machine is a puppet master or not.
- *Default*: false
run_method
----------
Whether to run as a service or in cron mode. Valid values are `disable`, `cron`, and `service`. The value `disable` disables automatic puppet runs and assumes you are running as a service.
- *Default*: service
run_interval
------------
The interval with which the client should run (in minutes)
- *Default*: 30
run_in_noop
-----------
Whether the client should run in noop mode or not.
- *Default*: false
cron_command
------------
The command that should be added to the crontab (in cron mode)
- *Default*: /usr/bin/puppet agent --onetime --ignorecache --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay
run_at_boot
-----------
Whether the client should run right after boot
- *Default*: true
puppet_binary
-------------
Path to puppet binary to create symlink from
- *Default*: '/usr/bin/puppet'
symlink_puppet_binary_target
----------------------------
Path to where the symlink should be created
- *Default*: '/usr/local/bin/puppet'
symlink_puppet_binary
---------------------
Boolean for ensuring a symlink for puppet_binary to symlink_puppet_binary_target. This is useful if you install puppet in a non-standard location that is not in your $PATH.
- *Default*: false
agent_sysconfig
---------------
The location of puppet agent sysconfig file.
- *Default*: use defaults based on osfamily
agent_sysconfig_ensure
----------------------
String for 'file' or 'present'. Allows you to not manage the sysconfig file.
- *Default*: use defaults based on osfamily
daemon_name
-----------
The name the puppet agent daemon should run as.
- *Default*: puppet
stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
- *Default*: true
===
## Class `puppet::dashboard` ##
### Parameters ###
dashboard_package
-----------------
String or Array of the dashboard package(s) name.
- *Default*: 'puppet-dashboard'
dashboard_user
--------------
The user for dashboard installation.
- *Default*: use defaults based on osfamily
dashboard_group
--------------
The group for dashboard installation.
- *Default*: use defaults based on osfamily
sysconfig_path
-------------------
The location of puppet dashboard sysconfig file.
- *Default*: use defaults based on osfamily
external_node_script_path
-------------------------
The script to call from puppet to get manifests from dashboard.
- *Default*: /usr/share/puppet-dashboard/bin/external_node
dashboard_fqdn
--------------
The dashboard server FQDN.
- *Default*: puppet.${::domain}
port
----
The port the web server will respond to.
- *Default*: 3000
===
## Class `puppet::dashboard::server` ##
### Usage ###
You can optionally specify a hash of htpasswd entries in Hiera.
<pre>
---
puppet::dashboard::htpasswd:
admin:
cryptpasswd: $apr1$kVPL28B8$1LggacK2dvrOf4SkOCxyO0
puppet:
cryptpasswd: $apr1$F2redFE9$FCyxK2cJuHXphfeQugXBi1
</pre>
### Parameters ###
dashboard_workers
-----------------
Number of dashboard workers to start. Only used on osfamily Debian.
- *Default*: $::processorcount
database_config_path
--------------------
The path to the database config file.
- *Default*: /usr/share/puppet-dashboard/config/database.yml
database_config_owner
---------------------
The owner of the database config file.
- *Default*: puppet-dashboard
database_config_group
---------------------
The database config file group.
- *Default*: puppet-dashboard
database_config_mode
--------------------
The database config file mode.
- *Default*: 0640
htpasswd
--------
Hash of htpasswd entries. See leinaddm/htpasswd module for more information. Only used if security is set to 'htpasswd'.
- *Default*: undef
htpasswd_path
-------------
String of path to htpasswd file to be used by Dashboard. Only used if security is set to 'htpasswd'.
- *Default*: `/etc/puppet/dashboard.htpasswd`
htpasswd_owner
--------------
Owner of htpasswd file.
- *Default*: root
htpasswd_group
--------------
Group of htpasswd file.
- *Default*: use defaults based on osfamily
htpasswd_mode
-------------
Mode of htpasswd file.
- *Default*: 0640
log_dir
-------
The location for the puppet log files.
- *Default*: /var/log/puppet
mysql_user
----------
The user for the mysql connection.
- *Default*: dashboard
mysql_password
--------------
The password for the mysql connection.
- *Default*: puppet
mysql_max_packet_size
---------------------
The mysql max packet size.
- *Default*: 32M
security
--------
String to indicate security type used. Valid values are 'none' and 'htpasswd'. Using 'htpasswd' will use Apache basic auth with a htpasswd file. See htpasswd and htpasswd_path parameters.
- *Default*: 'none'
vhost_path
----------
The location of puppet dashboard vhost file for apache.
- *Default*: use defaults based on osfamily
===
## Class `puppet::dashboard::maintenance` ##
### Parameters ###
db_optimization_command
-----------------------
The command to run to optimize the db.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production db:raw:optimize >> /var/log/puppet/dashboard_maintenance.log
db_optimization_user
--------------------
The user to run db optimization.
- *Default*: root
db_optimization_hour
--------------------
The hour on which to run db optimization.
- *Default*: 0
db_optimization_minute
----------------------
The minute at which to run db optimization.
- *Default*: 0
db_optimization_monthday
------------------------
The day of the month on which to run db optimization.
- *Default*: 1
reports_days_to_keep
--------------------
How many days to keep the reports.
- *Default*: 30
purge_old_reports_command
-------------------------
Which command to run to purge old reports.
- *Default*: /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production reports:prune upto=30 unit=day >> /var/log/puppet/dashboard_maintenance.log
purge_old_reports_user
----------------------
User to purge reports as.
- *Default*: root
purge_old_reports_hour
----------------------
On which hour to purge old reports.
- *Default*: 0
purge_old_reports_minute
------------------------
At which minute to purge old reports.
- *Default*: 30
remove_old_reports_spool
------------------------
Whether we should remove old dashboard reports that have not been imported
- *Default*: 'True'
reports_spool_dir
-----------------
Path to reports in dashboard spool
- *Default*: '/usr/share/puppet-dashboard/spool'
reports_spool_days_to_keep
--------------------------
How many days to keep the unimported reports.
remove_reports_spool_user
-------------------------
User to remove unimported reports.
- *Default*: root
remove_reports_spool_hour
-------------------------
On which hour to remove unimported reports.
- *Default*: 0
remove_reports_spool_minute
---------------------------
At which minute to remove unimported reports
- *Default*: 45
dump_dir
--------
The directory to use for dumps.
- *Default*: /var/local
dump_database_command
---------------------
The command to run to dump the database.
- *Default*: sudo -u puppet-dashboard /usr/bin/rake -f /usr/share/puppet-dashboard/Rakefile RAILS_ENV=production FILE=/var/local/dashboard-`date -I`.sql db:raw:dump >> /var/log/puppet/dashboard_maintenance.log && bzip2 -v9 /var/local/dashboard-`date -I`.sql >> /var/log/puppet/dashboard_maintenance.log
dump_database_user
------------------
User to dump database as.
- *Default*: root
dump_database_hour
------------------
On which hour to dump database.
- *Default*: 1
dump_database_minute
--------------------
At which minute to purge old reports.
- *Default*: 0
days_to_keep_backups
--------------------
Number of days to keep database backups.
- *Default*: 7
purge_old_db_backups_user
-------------------------
User to purge old database dumps as.
- *Default*: root
purge_old_db_backups_hour
-------------------------
On which hour to purge old database dumps.
- *Default*: 2
purge_old_db_backups_minute
---------------------------
At which minute to purge old database dumps.
- *Default*: 0
===
## Class `puppet::lint` ##
### Parameters ###
ensure
------
Whether to install lint.
- *Default*: present
provider
--------
Which provider should supply lint.
- *Default*: gem
version
-------
If you do not want to use the default version of lint, specify which version you want to use here.
- *Default*: undef
lint_args
---------
Which args should be added to the .puppet-lint.rc file
- *Default*: --no-80chars-check
|
ghoneycutt/puppet-module-puppet
|
2478609e780f3768cfea65122762432b02ee3a28
|
Release v2.11.0 - Support for structured facts
|
diff --git a/Modulefile b/Modulefile
index 5d9d28b..3fb926c 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,16 +1,16 @@
name 'ghoneycutt-puppet'
-version '2.10.0'
+version '2.11.0'
source 'git://github.com/ghoneycutt/puppet-module-puppet.git'
author 'ghoneycutt'
license 'Apache License, Version 2.0'
summary 'Manage Puppet'
description 'Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.'
project_page 'https://github.com/ghoneycutt/puppet-module-puppet'
dependency 'leinaddm/htpasswd', '>= 0.0.1'
dependency 'puppetlabs/stdlib', '>= 3.2.0'
dependency 'puppetlabs/mysql', '>= 2.0.0'
dependency 'puppetlabs/passenger', '>= 0.0.4'
dependency 'puppetlabs/apache', '>= 0.5.0'
dependency 'puppetlabs/firewall', '>= 0.2.1'
dependency 'puppetlabs/concat', '>= 1.0.0'
diff --git a/metadata.json b/metadata.json
index 37239d9..e4e7c76 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,87 +1,87 @@
{
+ "name": "ghoneycutt-puppet",
+ "version": "2.11.0",
+ "author": "ghoneycutt",
+ "summary": "Manage Puppet",
+ "license": "Apache License, Version 2.0",
+ "source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
+ "project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
+ "issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES"
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
- "name": "ghoneycutt-puppet",
- "version": "2.10.0",
- "author": "ghoneycutt",
- "summary": "Manage Puppet",
- "license": "Apache License, Version 2.0",
- "source": "git://github.com/ghoneycutt/puppet-module-puppet.git",
- "project_page": "https://github.com/ghoneycutt/puppet-module-puppet",
- "issues_url": "https://github.com/ghoneycutt/puppet-module-puppet/issues",
"description": "Manages Puppet, including Master, Agent, Dashboard and maintenance tasks.",
"dependencies": [
{"name":"leinaddm/htpasswd","version_requirement":">= 0.0.1"},
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"},
{"name":"puppetlabs/mysql","version_requirement":">= 2.0.0"},
{"name":"puppetlabs/passenger","version_requirement":">= 0.0.4"},
{"name":"puppetlabs/apache","version_requirement":">= 0.5.0"},
{"name":"puppetlabs/firewall","version_requirement":">= 0.2.1"},
{"name":"puppetlabs/concat","version_requirement":">= 1.0.0"}
]
}
|
ushakov/mapsoft
|
27e9850dff9e3f6f7dd1dede185feaaa44a070a7
|
vector/data/styles.m4: fix error in fig format
|
diff --git a/vector/data/styles.m4 b/vector/data/styles.m4
index 4c2638a..ccf8b2d 100644
--- a/vector/data/styles.m4
+++ b/vector/data/styles.m4
@@ -1,723 +1,723 @@
divert(-1)
# Source for mmb and hr style files. Same types but different colors
define(VYS_COL, ifelse(STYLE,hr, 24,0)) # ÑÐ²ÐµÑ Ð¾ÑмеÑок вÑÑоÑ
define(HOR_COL, ifelse(STYLE,hr, 30453904,26)) # ÑÐ²ÐµÑ Ð³Ð¾ÑизонÑалей
define(VOD_COL, ifelse(STYLE,hr, 11,3)) # ÑÐ²ÐµÑ Ñек
define(HRE_COL, ifelse(STYLE,hr, 26,24)) # ÑÐ²ÐµÑ Ñ
ÑебÑа
define(TRE_PIC, ifelse(STYLE,hr, trig_hr,trig)) # ÑÐ²ÐµÑ Ñ
ÑебÑа
divert
-
name: деÑевнÑ
mp: POI 0x0700 0 0
fig: 2 1 0 5 18 7 50 -1 -1 0.000 1 1 7 0 0 1
txt: 4 0 0 40 -1 18 8 0.0000 4
ocad_txt: 770000
-
name: кÑÑÐ¿Ð½Ð°Ñ Ð´ÐµÑевнÑ
mp: POI 0x0800 0 0
fig: 2 1 0 4 18 7 50 -1 -1 0.000 1 1 7 0 0 1
txt: 4 0 0 40 -1 18 8 0.0000 4
ocad_txt: 790000
-
name: гоÑод
mp: POI 0x0900 0 0
fig: 2 1 0 3 18 7 50 -1 -1 0.000 1 1 7 0 0 1
txt: 4 0 0 40 -1 18 8 0.0000 4
ocad_txt: 790000
-
name: ÑÑиангÑлÑÑионнÑй знак
mp: POI 0x0F00 0 0
fig: 2 1 0 2 VYS_COL 7 57 -1 20 0.000 1 1 -1 0 0 1
pic: TRE_PIC
txt: 4 0 VYS_COL 40 -1 18 7 0.0000 4
ocad: 196000
ocad_txt: 710000
-
name: оÑмеÑка вÑÑоÑÑ
mp: POI 0x1100 0 0
fig: 2 1 0 4 VYS_COL 7 57 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 VYS_COL 40 -1 18 7 0.0000 4
ocad: 110000
ocad_txt: 710000
-
name: маленÑÐºÐ°Ñ Ð¾ÑмеÑка вÑÑоÑÑ
desc: взÑÑÐ°Ñ Ð°Ð²ÑомаÑиÑеÑки из srtm и Ñ.п.
mp: POI 0x0D00 0 0
fig: 2 1 0 3 VYS_COL 7 57 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 VYS_COL 40 -1 18 6 0.0000 4
-
name: оÑмеÑка ÑÑеза водÑ
mp: POI 0x1000 0 0
fig: 2 1 0 4 1 7 57 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 1 40 -1 18 6 0.0000 4
ocad: 100000
ocad_txt: 700000
move_to: 0x100026 0x100015 0x100018 0x10001F 0x200029 0x20003B 0x200053
pic: ur_vod
-
name: магазин
mp: POI 0x2E00 0 0
fig: 2 1 0 2 4 7 50 -1 -1 0.000 1 0 7 0 0 1
-
name: подпиÑÑ Ð»ÐµÑного кваÑÑала, ÑÑоÑиÑа
mp: POI 0x2800 0 0
fig: 2 1 0 4 12 7 55 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 1 0 40 -1 3 8 0.0000 4
ocad_txt: 780000
-
name: памÑÑник
mp: POI 0x2c04 0 0
fig: 2 1 0 1 4 7 157 -1 -1 0.000 0 1 -1 0 0 1
pic: pam
txt: 4 0 0 40 -1 3 6 0.0000 4
ocad: 293004
ocad_txt: 780000
-
name: ÑеÑковÑ
mp: POI 0x2C0B 0 0
fig: 2 1 0 1 11 7 157 -1 -1 0.000 0 1 -1 0 0 1
pic: cerkov
txt: 4 0 0 40 -1 3 8 0.0000 4
ocad: 293009
ocad_txt: 780000
-
name: оÑÑановка авÑобÑÑа
mp: POI 0x2F08 0 0
fig: 2 1 0 4 4 7 57 -1 -1 0.000 0 1 -1 0 0 1
pic: avt
ocad: 296008
-
name: ж/д ÑÑанÑиÑ
mp: POI 0x5905 0 0
fig: 2 1 0 4 4 7 57 -1 -1 0.000 0 0 -1 0 0 1
txt: 4 0 0 40 -1 3 8 0.0000 4
pic: zd
ocad: 590005
ocad_txt: 780000
rotate_to: 0x10000D 0x100027
-
name: пеÑевал неизвеÑÑной ÑложноÑÑи
mp: POI 0x6406 0 0
fig: 2 1 0 1 1 7 158 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 15 40 -1 18 7 0.0000 4
pic: per
rotate_to: 0x10000C
-
name: пеÑевал н/к
mp: POI 0x6700 0 0
fig: 2 1 0 1 2 7 158 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 15 40 -1 18 7 0.0000 4
pic: pernk
rotate_to: 0x10000C
-
name: пеÑевал 1Ð
mp: POI 0x6701 0 0
fig: 2 1 0 1 3 7 158 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 15 40 -1 18 7 0.0000 4
pic: per1a
rotate_to: 0x10000C
-
name: пеÑевал 1Ð
mp: POI 0x6702 0 0
fig: 2 1 0 1 4 7 158 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 15 40 -1 18 7 0.0000 4
pic: per1b
rotate_to: 0x10000C
-
name: пеÑевал 2Ð
mp: POI 0x6703 0 0
fig: 2 1 0 1 5 7 158 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 15 40 -1 18 7 0.0000 4
pic: per2a
rotate_to: 0x10000C
-
name: пеÑевал 2Ð
mp: POI 0x6704 0 0
fig: 2 1 0 1 6 7 158 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 15 40 -1 18 7 0.0000 4
pic: per2b
rotate_to: 0x10000C
-
name: пеÑевал 3Ð
mp: POI 0x6705 0 0
fig: 2 1 0 1 7 7 158 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 15 40 -1 18 7 0.0000 4
pic: per3a
rotate_to: 0x10000C
-
name: пеÑевал 3Ð
mp: POI 0x6706 0 0
fig: 2 1 0 1 8 7 158 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 15 40 -1 18 7 0.0000 4
pic: per3b
rotate_to: 0x10000C
-
name: канÑон
mp: POI 0x660B 0 0
fig: 2 1 0 1 9 7 158 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 24 40 -1 18 6 0.0000 4
pic: kan
-
name: ледопад
mp: POI 0x650A 0 0
fig: 2 1 0 1 10 7 158 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 1 40 -1 3 6 0.0000 4
pic: ldp
-
name: Ð½Ð¾Ð¼ÐµÑ Ð»ÐµÐ´Ð½Ð¸ÐºÐ°
mp: POI 0x650B 0 0
fig: 2 1 0 3 8 7 57 -1 -1 0.000 0 1 7 0 0 1
txt: 4 1 1 40 -1 3 5 0.0000 4
-
name: название ледника
mp: POI 0x650C 0 0
fig: 2 1 0 4 8 7 57 -1 -1 0.000 0 1 7 0 0 1
txt: 4 0 1 40 -1 3 7 0.0000 4
-
name: дом
mp: POI 0x6402 0 1
fig: 2 1 0 4 0 7 57 -1 -1 0.000 0 0 -1 0 0 1
txt: 4 0 0 40 -1 3 8 0.0000 4
pic: dom
ocad: 640002
ocad_txt: 780000
-
name: кладбиÑе
mp: POI 0x6403 0 1
fig: 2 1 0 1 12 7 157 -1 -1 0.000 0 1 -1 0 0 1
pic: kladb
ocad: 640003
-
name: баÑнÑ
mp: POI 0x6411 0 0
fig: 2 1 0 1 5 7 157 -1 -1 0.000 0 1 -1 0 0 1
pic: bash
ocad: 641001
-
name: Ñодник
mp: POI 0x6414 0 0
fig: 2 1 0 4 5269247 7 57 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 1 40 -1 3 6 0.0000 4
ocad: 641004
ocad_txt: 729000
-
name: ÑазвалинÑ
mp: POI 0x6415 0 1
fig: 2 1 0 1 0 7 156 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 0 40 -1 3 8 0.0000 4
pic: razv
ocad: 641005
ocad_txt: 780000
-
name: ÑаÑ
ÑÑ
mp: POI 0x640C 0 1
fig: 2 1 0 1 0 7 155 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 0 40 -1 3 6 0.0000 4
pic: shaht
ocad_txt: 780000
-
name: водопад
mp: POI 0x6508 0 0
fig: 2 1 0 4 17 7 57 -1 -1 0.000 0 0 -1 0 0 1
txt: 4 0 1 40 -1 3 6 0.0000 4
ocad_txt: 729000
rotate_to: 0x100026 0x100015 0x100018 0x10001F
pic: vdp
-
name: поÑог /не иÑполÑзоваÑÑ!/
mp: POI 0x650E 0 0
fig: 2 1 0 4 8 7 57 -1 -1 0.000 0 0 -1 0 0 1
txt: 4 0 1 40 -1 3 6 0.0000 4
ocad_txt: 729000
rotate_to: 0x100026 0x100015 0x100018 0x10001F
replace_by: 0x6508
pic: por
-
name: пеÑеÑа
mp: POI 0x6601 0 0
fig: 2 1 0 1 24 7 157 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 1 40 -1 3 6 0.0000 4
pic: pesch
ocad: 660001
-
name: Ñма
mp: POI 0x6603 0 0
fig: 2 1 0 1 25 7 157 -1 -1 0.000 0 1 -1 0 0 1
pic: yama
ocad: 660003
-
name: оÑ
оÑниÑÑÑ Ð²ÑÑка, коÑмÑÑка и Ñ.п.
mp: POI 0x6606 0 0
fig: 2 1 0 1 6 7 157 -1 -1 0.000 0 1 -1 0 0 1
pic: ohotn
ocad: 660006
-
name: кÑÑган
mp: POI 0x6613 0 0
fig: 2 1 0 1 26 7 157 -1 -1 0.000 0 1 -1 0 0 1
pic: pupyr
ocad: 661003
-
name: Ñкала-оÑÑанеÑ
mp: POI 0x6616 0 0
fig: 2 1 0 1 20 7 157 -1 -1 0.000 0 1 -1 0 0 1
pic: skala
txt: 4 0 0 40 -1 3 6 0.0000 4
ocad: 661006
ocad_txt: 780000
-
name: меÑÑо ÑÑоÑнки
mp: POI 0x2B03 0 0
fig: 2 1 0 1 21 7 157 -1 -1 0.000 0 1 -1 0 0 1
pic: camp
txt: 4 0 0 40 -1 3 6 0.0000 4
-
name: одиноÑное деÑево, внемаÑÑÑабнÑй леÑ
mp: POI 0x660A 0 0
fig: 2 1 0 4 14 7 57 -1 -1 0.000 0 1 -1 0 0 1
txt: 4 0 0 40 -1 18 6 0.0000 4
-
name: леÑ
mp: POLYGON 0x16 0 1
fig: 2 3 0 0 12 11206570 100 -1 20 0.000 0 1 -1 0 0 0
ocad: 916000
-
name: поле
mp: POLYGON 0x52 0 1
fig: 2 3 0 0 12 11206570 99 -1 40 0.000 0 1 -1 0 0 0
ocad: 952000
-
name: оÑÑÑов леÑа
mp: POLYGON 0x15 0 1
fig: 2 3 0 0 12 11206570 97 -1 20 0.000 0 1 -1 0 0 0
ocad: 915000
-
name: ÑÐ²ÐµÐ¶Ð°Ñ Ð²ÑÑÑбка
mp: POLYGON 0x4F 0 1
fig: 2 3 0 0 12 7 98 -1 43 0.000 0 0 -1 0 0 0
txt: 4 1 0 40 -1 3 8 0.0000 4
ocad: 949006
ocad_txt: 780000
pic: vyr_n
pic_type: fill
-
name: ÑÑаÑ.вÑÑÑбка
mp: POLYGON 0x50 0 1
fig: 2 3 0 0 12 11206570 98 -1 43 0.000 0 0 -1 0 0 0
txt: 4 1 0 40 -1 3 8 0.0000 4
ocad: 950000
ocad_txt: 780000
pic: vyr_o
pic_type: fill
-
name: ÑедколеÑÑе
mp: POLYGON 0x14 0 1
fig: 2 3 0 0 11206570 7 98 -1 43 0.000 0 0 -1 0 0 0
txt: 4 1 0 40 -1 3 8 0.0000 4
ocad: 914000
ocad_txt: 780000
pic: redk
pic_type: fill
-
name: закÑÑÑÑе ÑеÑÑиÑоÑии
mp: POLYGON 0x04 0 1
fig: 2 3 0 1 0 7 95 -1 15 0.000 0 0 -1 0 0 0
txt: 4 0 0 40 -1 3 8 0.0000 4
ocad: 904000
ocad_txt: 780000
-
name: деÑевни
mp: POLYGON 0x0E 0 1
fig: 2 3 0 1 0 27 94 -1 20 0.000 0 0 -1 0 0 0
txt: 4 0 0 40 -1 18 8 0.0000 4
ocad: 909005
ocad_txt: 790000
-
name: гоÑода
mp: POLYGON 0x01 0 2
fig: 2 3 0 1 0 27 94 -1 15 0.000 0 0 -1 0 0 0
txt: 4 0 0 40 -1 18 8 0.0000 4
ocad: 901000
ocad_txt: 770000
-
name: даÑи, Ñад.ÑÑ., д/о, п/л
mp: POLYGON 0x4E 0 1
fig: 2 3 0 1 0 11206570 93 -1 10 0.000 0 0 -1 0 0 0
txt: 4 0 0 40 -1 3 8 0.0000 4
ocad: 949005
ocad_txt: 780000
-
name: кладбиÑе
mp: POLYGON 0x1A 0 1
fig: 2 3 0 1 0 11206570 92 -1 5 0.000 0 0 -1 0 0 0
txt: 4 0 0 40 -1 3 8 0.0000 4
ocad: 919001
ocad_txt: 780000
pic: cross
-
name: водоемÑ
mp: POLYGON 0x29 0 1
fig: 2 3 0 1 5269247 VOD_COL 85 -1 20 0.000 0 0 -1 0 0 0
txt: 4 1 1 40 -1 3 8 0.0000 4
ocad: 929000
ocad_txt: 729000
-
name: кÑÑпнÑе водоемÑ
mp: POLYGON 0x3B 0 2
fig: 2 3 0 1 5269247 VOD_COL 85 -1 15 0.000 0 0 -1 0 0 0
txt: 4 1 1 40 -1 3 8 0.0000 4
ocad_txt: 729000
-
name: оÑÑÑов
mp: POLYGON 0x53 0 1
fig: 2 3 0 1 5269247 VOD_COL 84 -1 40 0.000 0 0 -1 0 0 0
txt: 4 0 0 40 -1 3 8 0.0000 4
ocad: 953000
ocad_txt: 729000
-
name: заболоÑенноÑÑÑ
mp: POLYGON 0x51 0 1
fig: 2 3 0 0 5269247 VOD_COL 87 -1 49 0.000 0 0 -1 0 0 0
txt: 4 1 0 40 -1 3 8 0.0000 4
ocad: 951000
ocad_txt: 780000
pic: bol_l
pic_type: fill
-
name: болоÑо
mp: POLYGON 0x4C 0 1
fig: 2 3 0 0 VOD_COL 5269247 87 -1 49 0.000 0 0 -1 0 0 0
txt: 4 1 0 40 -1 3 8 0.0000 4
ocad: 310000
ocad_txt: 780000
pic: bol_h
pic_type: fill
-
name: ледник
mp: POLYGON 0x4D 0 1
fig: 2 3 0 0 11 11 96 -1 35 0.000 0 0 7 0 0 1
txt: 4 1 1 40 -1 3 8 0.0000 4
ocad_txt: 780000
pic: ledn
pic_type: fill
-
name: кÑÑÑой Ñклон
mp: POLYGON 0x19 0 1
fig: 2 3 0 0 0 24 91 -1 20 0.000 0 0 -1 0 0 0
txt: 4 1 0 40 -1 3 8 0.0000 4
ocad_txt: 780000
-
name: дÑÑка в srtm-даннÑÑ
mp: POLYGON 0xA 0 1
fig: 2 3 0 0 0 4 110 -1 20 0.000 0 0 -1 0 0 0
txt: 4 1 0 40 -1 3 8 0.0000 4
ocad_txt: 780000
-
name: оÑÑпÑ, галÑка, пеÑок
mp: POLYGON 0x8 0 1
- fig: 2 2 0 0 26 26 95 -1 35 0.000 0 0 7 0 0 0
+ fig: 2 3 0 0 26 26 95 -1 35 0.000 0 0 7 0 0 0
txt: 4 1 0 40 -1 3 8 0.0000 4
pic: sand
pic_type: fill
ocad_txt: 780000
-
name: пеÑок
mp: POLYGON 0xD 0 1
- fig: 2 2 0 0 26 26 95 -1 35 0.000 0 0 7 0 0 0
+ fig: 2 3 0 0 26 26 95 -1 35 0.000 0 0 7 0 0 0
txt: 4 1 0 40 -1 3 8 0.0000 4
pic: sand_ov
pic_type: fill
ocad_txt: 780000
-
name: оÑлиÑнÑй пÑÑÑ
mp: POLYLINE 0x35 0 0
fig: 2 1 0 3 31 7 88 -1 -1 6.000 0 2 -1 0 0 0
ocad: 835000
curve: 50
-
name: Ñ
оÑоÑий пÑÑÑ
mp: POLYLINE 0x34 0 0
fig: 2 1 2 3 31 7 88 -1 -1 6.000 0 2 -1 0 0 0
ocad: 834000
curve: 50
-
name: ÑдовлеÑвоÑиÑелÑнÑй пÑÑÑ
mp: POLYLINE 0x33 0 0
fig: 2 1 2 3 13 7 88 -1 -1 6.000 0 2 -1 0 0 0
ocad: 833000
curve: 50
-
name: плоÑ
ой пÑÑÑ
mp: POLYLINE 0x32 0 0
fig: 2 1 0 3 13 7 88 -1 -1 6.000 0 2 -1 0 0 0
ocad: 832000
curve: 50
-
name: кÑÐ¸Ð²Ð°Ñ Ð½Ð°Ð´Ð¿Ð¸ÑÑ
mp: POLYLINE 0x00 0 0
fig: 2 1 0 4 1 7 55 -1 -1 0.000 0 0 0 0 0 0
-
name: авÑомагиÑÑÑалÑ
mp: POLYLINE 0x01 0 2
fig: 2 1 0 7 4210752 27 80 -1 -1 0.000 1 0 0 0 0 0
ocad: 801000
curve: 100
-
name: болÑÑое ÑоÑÑе
mp: POLYLINE 0x0B 0 2
fig: 2 1 0 5 4210752 27 80 -1 -1 0.000 1 0 0 0 0 0
ocad: 809002
curve: 100
-
name: ÑоÑÑе
mp: POLYLINE 0x02 0 2
fig: 2 1 0 4 4210752 27 80 -1 -1 0.000 1 0 0 0 0 0
ocad: 802000
curve: 100
-
name: веÑÑ
ний кÑай обÑÑва
mp: POLYLINE 0x03 0 0
fig: 2 1 0 1 18 7 79 -1 -1 0.000 1 1 7 0 0 0
ocad: 803000
-
name: пÑоезжий гÑейдеÑ
mp: POLYLINE 0x04 0 1
fig: 2 1 0 3 4210752 7 80 -1 -1 0.000 1 0 0 0 0 0
ocad: 804000
curve: 100
-
name: оÑделÑнÑе ÑÑÑоениÑ
mp: POLYLINE 0x05 0 1
fig: 2 1 0 3 0 7 81 -1 -1 0.000 0 0 0 0 0 0
txt: 4 0 0 40 -1 3 8 0.0000 4
ocad: 805000
ocad_txt: 780000
-
name: пÑÐ¾ÐµÐ·Ð¶Ð°Ñ Ð³ÑÑнÑовка
mp: POLYLINE 0x06 0 1
fig: 2 1 0 1 0 7 80 -1 -1 0.000 1 0 0 0 0 0
ocad: 806000
curve: 50
-
name: непÑоезжий гÑейдеÑ
mp: POLYLINE 0x07 0 1
fig: 2 1 1 3 4210752 7 80 -1 -1 4.000 1 0 0 0 0 0
ocad: 807000
curve: 100
-
name: моÑÑ-1 (пеÑеÑ
однÑй)
mp: POLYLINE 0x08 0 1
fig: 2 1 0 1 7 7 77 -1 -1 0.000 0 0 0 0 0 0
txt: 4 0 0 40 -1 3 8 0.0000 4
ocad: 808000
ocad_txt: 780000
-
name: моÑÑ-2 (авÑомобилÑнÑй)
mp: POLYLINE 0x09 0 1
fig: 2 1 0 2 7 7 77 -1 -1 0.000 0 0 0 0 0 0
txt: 4 0 0 40 -1 3 8 0.0000 4
ocad: 809000
ocad_txt: 780000
-
name: моÑÑ-5 (на авÑомагиÑÑÑалÑÑ
)
mp: POLYLINE 0x0E 0 1
fig: 2 1 0 5 7 7 77 -1 -1 0.000 0 0 0 0 0 0
txt: 4 0 0 40 -1 3 8 0.0000 4
ocad: 809005
ocad_txt: 780000
-
name: непÑÐ¾ÐµÐ·Ð¶Ð°Ñ Ð³ÑÑнÑовка
mp: POLYLINE 0x0A 0 1
fig: 2 1 0 1 4210752 7 80 -1 -1 0.000 1 0 0 0 0 0
ocad: 809001
curve: 50
-
name: Ñ
ÑебеÑ
mp: POLYLINE 0x0C 0 1
fig: 2 1 0 2 HRE_COL 7 89 -1 -1 0.000 1 1 0 0 0 0
curve: 50
-
name: малÑй Ñ
ÑебеÑ
mp: POLYLINE 0x0F 0 1
fig: 2 1 0 1 HRE_COL 7 89 -1 -1 0.000 1 1 0 0 0 0
curve: 50
-
name: пеÑеÑÑÑ
аÑÑий ÑÑÑей
mp: POLYLINE 0x26 0 0
fig: 2 1 1 1 5269247 7 86 -1 -1 4.000 1 1 0 0 0 0
txt: 4 1 1 40 -1 3 8 0.0000 4
ocad: 826000
ocad_txt: 718000
-
name: Ñека-1
mp: POLYLINE 0x15 0 1
fig: 2 1 0 1 5269247 7 86 -1 -1 0.000 1 1 0 0 0 0
txt: 4 1 1 40 -1 3 8 0.0000 4
ocad: 815000
ocad_txt: 718000
-
name: Ñека-2
mp: POLYLINE 0x18 0 2
fig: 2 1 0 2 5269247 7 86 -1 -1 0.000 1 1 0 0 0 0
txt: 4 1 1 40 -1 3 8 0.0000 4
ocad: 818000
ocad_txt: 718000
-
name: Ñека-3
mp: POLYLINE 0x1F 0 2
fig: 2 1 0 3 5269247 VOD_COL 86 -1 -1 0.000 1 1 0 0 0 0
txt: 4 1 1 40 -1 3 8 0.0000 4
ocad: 819006
ocad_txt: 718000
-
name: пÑоÑека
mp: POLYLINE 0x16 0 1
fig: 2 1 1 1 0 7 80 -1 -1 4.000 1 0 0 0 0 0
ocad: 816000
-
name: забоÑ
mp: POLYLINE 0x19 0 0
fig: 2 1 0 1 20 7 81 -1 -1 0.000 0 0 0 1 0 0 0 0 2.00 90.00 90.00
ocad: 819000
-
name: маленÑÐºÐ°Ñ ÐÐÐ
mp: POLYLINE 0x1A 0 0
fig: 2 1 0 2 8947848 7 83 -1 -1 0.000 0 0 0 0 0 0
ocad: 819001
-
name: пеÑеÑ
однÑй ÑоннелÑ
mp: POLYLINE 0x1B 0 0
fig: 2 1 0 1 3 7 77 -1 -1 0.000 0 0 0 0 0 0
ocad: 819002
-
name: пÑоÑека ÑиÑокаÑ
mp: POLYLINE 0x1C 0 1
fig: 2 1 1 2 0 7 80 -1 -1 6.000 1 0 0 0 0 0
ocad: 819003
-
name: гÑаниÑа ÑÑÑан, облаÑÑей
mp: POLYLINE 0x1D 0 2
fig: 2 1 0 7 4 7 91 -1 -1 4.000 1 1 0 0 0 0
ocad: 819004
-
name: гÑаниÑа облаÑÑей, Ñайонов
mp: POLYLINE 0x36 0 2
fig: 2 1 0 5 4 7 91 -1 -1 4.000 1 1 0 0 0 0
ocad: 819004
-
name: гÑаниÑа заповедников, паÑков
mp: POLYLINE 0x37 0 2
fig: 2 1 0 5 2 7 91 -1 -1 4.000 1 1 0 0 0 0
txt: 4 1 0 40 -1 3 8 0.0000 4
ocad: 819004
-
name: нижний кÑай обÑÑва
mp: POLYLINE 0x1E 0 0
fig: 2 1 2 1 18 7 79 -1 -1 2.000 1 1 7 0 0 0
-
name: пÑнкÑиÑÐ½Ð°Ñ Ð³Ð¾ÑизонÑалÑ
mp: POLYLINE 0x20 0 0
fig: 2 1 1 1 HOR_COL 7 90 -1 -1 4.000 1 1 0 0 0 0
ocad: 820000
curve: 100
-
name: гоÑизонÑали, беÑгÑÑÑиÑ
и
mp: POLYLINE 0x21 0 0
fig: 2 1 0 1 HOR_COL 7 90 -1 -1 0.000 1 1 0 0 0 0
ocad: 821000
curve: 100
-
name: жиÑÐ½Ð°Ñ Ð³Ð¾ÑизонÑалÑ
mp: POLYLINE 0x22 0 0
fig: 2 1 0 2 HOR_COL 7 90 -1 -1 0.000 1 1 0 0 0 0
ocad: 822000
curve: 100
-
name: конÑÑÑ Ð»ÐµÑа
mp: POLYLINE 0x23 0 0
fig: 2 1 2 1 12 7 96 -1 -1 2.000 1 1 0 0 0 0
ocad: 823000
-
name: болоÑо
mp: POLYLINE 0x24 0 0
fig: 2 1 0 1 5269247 7 87 -1 -1 0.000 0 1 0 0 0 0
ocad: 824000
-
name: овÑаг
mp: POLYLINE 0x25 0 0
fig: 2 1 0 2 25 7 89 -1 -1 0.000 1 1 0 0 0 0
ocad: 825000
curve: 50
-
name: УÐÐ
mp: POLYLINE 0x0D 0 2
fig: 2 1 0 3 0 7 80 -1 -1 0.000 1 0 0 0 0 0
curve: 100
-
name: Ð¶ÐµÐ»ÐµÐ·Ð½Ð°Ñ Ð´Ð¾Ñога
mp: POLYLINE 0x27 0 2
fig: 2 1 0 4 0 7 80 -1 -1 0.000 1 0 0 0 0 0
ocad: 827000
curve: 100
-
name: газопÑовод
mp: POLYLINE 0x28 0 1
fig: 2 1 1 3 8947848 7 83 -1 -1 4.000 1 0 0 0 0 0
ocad: 828000
-
name: ÐÐÐ
mp: POLYLINE 0x29 0 1
fig: 2 1 0 3 8947848 7 83 -1 -1 0.000 1 0 0 0 0 0
ocad: 829000
-
name: ÑÑопа
mp: POLYLINE 0x2A 0 0
fig: 2 1 2 1 0 7 80 -1 -1 2.000 1 0 0 0 0 0
ocad: 829001
curve: 50
-
name: ÑÑÑ
Ð°Ñ ÐºÐ°Ð½Ð°Ð²Ð°
mp: POLYLINE 0x2B 0 0
fig: 2 1 2 1 26 7 82 -1 -1 2.000 1 1 0 0 0 0
ocad: 829002
-
name: вал
mp: POLYLINE 0x2C 0 0
fig: 2 1 2 3 26 7 81 -1 -1 2.000 1 1 0 0 0 0
ocad: 829003
-
name: заÑоÑÑÐ°Ñ Ð´Ð¾Ñога
mp: POLYLINE 0x2D 0 0
fig: 2 1 1 1 4210752 7 80 -1 -1 4.000 1 0 7 0 0 0
ocad: 829004
curve: 50
-
name: заÑоÑÑÐ°Ñ Ð·Ð°Ð¼ÐµÑÐ½Ð°Ñ Ð´Ð¾Ñога (знак ÐÐÐ)
mp: POLYLINE 0x2E 0 0
fig: 2 1 3 1 4210752 7 80 -1 -1 0.000 1 0 0 0 0 0
ocad: 829004
curve: 50
-
name: bad route /не иÑполÑзоваÑÑ!/
mp: POLYLINE 0x50 0 0
fig: 2 1 1 1 4210700 7 80 -1 -1 4.000 0 0 -1 0 0 0
curve: 50
replace_by: 0x10002D
-
# note: 0x7F is also hardcoded in core/vmap/vmap.c
name: text object
mp: POLYLINE 0x7F 0 0
fig: 2 1 0 1 4 7 42 -1 -1 0.000 0 0 7 0 0 0
-
# note: 0x7E is also hardcoded in core/vmap/vmap.c
name: border object
mp: POLYLINE 0x7E 0 0
fig: 2 1 0 1 5 7 41 -1 -1 0.000 0 0 7 0 0 0
ocad: 507000
|
ushakov/mapsoft
|
b78921e8d7450947ac2d5d818d44663a53b1a02e
|
core/vmap/vmap_labels.cpp: remove debug output
|
diff --git a/core/vmap/vmap_labels.cpp b/core/vmap/vmap_labels.cpp
index daf5c58..09e7b9b 100644
--- a/core/vmap/vmap_labels.cpp
+++ b/core/vmap/vmap_labels.cpp
@@ -1,303 +1,302 @@
#include <list>
#include <vector>
#include <string>
#include <map>
#include <iostream>
#include <algorithm>
#include "2d/line_utils.h"
#include "2d/line_rectcrop.h"
#include "geo_io/geofig.h"
#include "geo/geo_convs.h"
#include "geo/geo_nom.h"
#include "vmap/zn.h"
#include "vmap.h"
namespace vmap {
using namespace std;
const double label_search_dist1 = 1.0; // cm
const double label_search_dist2 = 1.0;
const double label_search_dist3 = 0.1;
const double label_len = 0.3;
const double label_new_dist = 0.1;
const double move_to_dist = 0.002; // deg; -- inaccurate...
/***************************************/
std::map<std::string,std::string> cnv_lable_map = {
{"`A", "\u00C0"}, {"`a", "\u00E0"},
{"\'A", "\u00C1"}, {"\'a", "\u00E1"},
{"^A", "\u00C3"}, {"^a", "\u00E2"},
{"~A", "\u00C3"}, {"~a", "\u00E3"},
{"\"A", "\u00C4"}, {"\"a", "\u00E4"},
{"AA", "\u00C5"}, {"aa", "\u00E5"},
{"AE", "\u00C6"}, {"ae", "\u00E6"},
{"cC", "\u00C7"}, {"cc", "\u00E7"},
{"`E", "\u00C8"}, {"\'e", "\u00E8"},
{"\'E", "\u00C9"}, {"\'e", "\u00E9"},
{"^E", "\u00CA"}, {"^e", "\u00EA"},
{"\"E", "\u00CB"}, {"\"e", "\u00EB"},
{"`I", "\u00CC"}, {"\'i", "\u00EC"},
{"\'I", "\u00CD"}, {"\'i", "\u00ED"},
{"^I", "\u00CE"}, {"^i", "\u00EE"},
{"\"I", "\u00CF"}, {"\"i", "\u00EF"},
{"NN", "\u00D1"}, {"nn", "\u00F1"},
{"`O", "\u00D2"}, {"\'o", "\u00F2"},
{"\'O", "\u00D3"}, {"\'o", "\u00F3"},
{"^O", "\u00D4"}, {"^o", "\u00F4"},
{"~O", "\u00D5"}, {"~o", "\u00F5"},
{"\"O", "\u00D6"}, {"\"o", "\u00F6"},
{"OO", "\u00D8"}, {"oo", "\u00F8"},
{"`U", "\u00D9"}, {"\'u", "\u00F9"},
{"\'U", "\u00DA"}, {"\'u", "\u00FA"},
{"^U", "\u00DB"}, {"^u", "\u00FB"},
{"\"U", "\u00DC"}, {"\"u", "\u00FC"},
{"\'Y", "\u00DD"}, {"\'y", "\u00FD"},
{".C", "\u010A"}, {".c", "\u010B"},
{"vC", "\u010C"}, {"vc", "\u010D"},
{"LL", "\u0141"}, {"ll", "\u0142"},
{"\'L", "\u013D"}, {"\'l", "\u013E"},
{"OE", "\u0152"}, {"oe", "\u0153"},
{"vT", "\u0164"}, {"\'t", "\u0165"},
{"\'Z", "\u0179"}, {"\'z", "\u017A"},
{".Z", "\u017B"}, {".z", "\u017C"},
{"vZ", "\u017D"}, {"vz", "\u017E"}
};
std::string
conv_label(const std::string & str){
std::string ret;
for (size_t i = 0; i<str.size(); i++) {
auto c = str[i];
if (c!='#') { ret.push_back(c); continue; }
if (i>=str.size()-1) {
std::cerr << "conv_label: skipping # at the end: "<< str <<"\n";
continue;
}
i++;
if (str[i]=='#') {ret+=c; continue;} // "##"
if (i>=str.size()-1) {
std::cerr << "conv_label: skipping # at the end: "<< str <<"\n";
continue;
}
auto ss = str.substr(i,2);
i++;
auto ii = cnv_lable_map.find(ss);
if (ii==cnv_lable_map.end()){
std::cerr << "conv_label: unknown sequence: #" << ss << " in: "<< str <<"\n";
continue;
} // unknown
ret += ii->second;
}
- std::cerr << ">>> " << ret << "\n";
return ret;
}
void
join_labels(world & W){
std::list<lpos_full>::iterator l, l0;
world::iterator o;
dPoint p, p0;
zn::zn_conv zc(W.style);
// one nearest label with correct text (label_search_dist1 parameter)
for (o=W.begin(); o!=W.end(); o++){
if ((o->text == "") || (zc.get_label_type(o->type)==0)) continue;
double d0=1e99;
for (l=W.lbuf.begin(); l!=W.lbuf.end(); l++){
if (l->text != o->text) continue;
double d = dist_pt_l(l->ref, *o, p);
if ( d < d0){ d0=d; p0=p; l0=l;}
}
if (d0 * 100 / W.rscale < label_search_dist1){
l0->fsize -= zc.get_label_template(o->type).font_size;
o->labels.push_back(*l0);
W.lbuf.erase(l0);
}
}
// labels with correct text (label_search_dist2 parameter)
for (o=W.begin(); o!=W.end(); o++){
if ((o->text == "") || (zc.get_label_type(o->type)==0)) continue;
l=W.lbuf.begin();
while (l!=W.lbuf.end()){
// near ref or near pos
if ( ((l->text == o->text) &&
(dist_pt_l(l->ref, *o, p)* 100 / W.rscale < label_search_dist2)) ||
((l->text == o->text) &&
(dist_pt_l(l->pos, *o, p)* 100 / W.rscale < label_search_dist2)) ){
l->fsize -= zc.get_label_template(o->type).font_size;
o->labels.push_back(*l);
l = W.lbuf.erase(l);
continue;
}
l++;
}
}
// labels with changed text (label_search_dist3 parameter)
for (o=W.begin(); o!=W.end(); o++){
if ((o->text == "") || (zc.get_label_type(o->type)==0)) continue;
l=W.lbuf.begin();
while (l!=W.lbuf.end()){
if (dist_pt_l(l->ref, *o, p)* 100 / W.rscale < label_search_dist3){
l->fsize -= zc.get_label_template(o->type).font_size;
o->labels.push_back(*l);
l = W.lbuf.erase(l);
continue;
}
l++;
}
}
// clear unused labels
W.lbuf.clear();
}
/***************************************/
void
split_labels(world & W){
zn::zn_conv zc(W.style);
for (world::iterator o = W.begin(); o!=W.end(); o++){
for (std::list<lpos>::iterator l=o->labels.begin(); l!=o->labels.end(); l++){
lpos_full ll;
ll.lpos::operator=(*l);
ll.fsize += zc.get_label_template(o->type).font_size;
ll.text = o->text;
dist_pt_l(l->pos, *o, ll.ref);
W.lbuf.push_back(ll);
}
o->labels.clear();
}
}
/***************************************/
dPoint
max_xmy(const dLine & l){
if (l.size()<1) return dPoint(0,0);
dPoint p(l[0]);
double max = p.x-p.y;
for (dLine::const_iterator i = l.begin(); i!=l.end(); i++){
if (i->x - i->y > max) {
max = i->x - i->y;
p = *i;
}
}
return p;
}
dPoint
max_xpy(const dLine & l){
if (l.size()<1) return dPoint(0,0);
dPoint p(l[0]);
double max = p.x+p.y;
for (dLine::const_iterator i = l.begin(); i!=l.end(); i++){
if (i->x + i->y > max) {
max = i->x + i->y;
p = *i;
}
}
return p;
}
/***************************************/
// create new labels
void
create_labels(world & W){
zn::zn_conv zc(W.style);
for (world::iterator o=W.begin(); o!=W.end(); o++){
if ((o->labels.size()>0) || (o->text=="")) continue;
int lt = zc.get_label_type(o->type);
int ld = zc.get_label_dir(o->type);
if (lt==0) continue; // no label for this object
for (dMultiLine::iterator i=o->begin(); i!=o->end(); i++){
if (i->size()<1) continue;
if (o->type >= zn::line_mask && i->size()<2) continue;
// do not create labels for >2pt line and area objects
lpos l;
l.ang = 0;
l.dir = ld;
l.hor = true;
switch (lt){
case 1: // TR side of object (max x-y point + (1,-1)*td)
l.pos = max_xpy(*i) +
v_m2deg(W.rscale / 100.0 * dPoint(1,1) * label_new_dist/sqrt(2.0), (*i)[0].y);
break;
case 2: // TL side of object
l.pos = max_xmy(*i) +
v_m2deg(W.rscale / 100.0 * dPoint(-1,1) * label_new_dist/sqrt(2.0), (*i)[0].y);
break;
case 3: // object center
l.pos = i->range().CNT();
break;
case 4: // along the line
if (i->size()>=2){
dPoint cp = ((*i)[i->size()/2-1] + (*i)[i->size()/2]) / 2;
dPoint dp = (*i)[i->size()/2-1] - (*i)[i->size()/2];
if ((dp.x == 0) && (dp.y == 0)) dp.x = 1;
dPoint v = pnorm(dp);
if (v.x<0) v=-v;
l.ang = 180.0/M_PI*atan2(v.y, v.x);
l.pos = cp +
v_m2deg(W.rscale / 100.0 * dPoint(-v.y, v.x)*label_new_dist, (*i)[0].y);
l.hor = false;
}
else if (i->size()==1) l.pos = (*i)[0];
break;
}
o->labels.push_back(l);
}
}
}
/***************************************/
void
remove_labels(world & W){
W.lbuf.clear();
for (world::iterator o = W.begin(); o!=W.end(); o++)
o->labels.clear();
}
/***************************************/
void
move_pics(world & W){
zn::zn_conv zc(W.style);
for (map<int, zn::zn>::const_iterator z=zc.znaki.begin(); z!=zc.znaki.end(); z++){
const vector<int> & mt = z->second.move_to;
if (mt.size()==0) continue;
bool rotate = z->second.rotate;
int type = z->first;
dMultiLine lines;
for (world::const_iterator o=W.begin(); o!=W.end(); o++){
if (std::find(mt.begin(), mt.end(), o->type) != mt.end())
lines.insert(lines.end(), o->begin(), o->end());
}
for (world::iterator o=W.begin(); o!=W.end(); o++){
if (o->type!=type) continue;
if (o->size()!=1) continue;
if ((*o)[0].size()!=1) continue; // only 1-segment, 1-point objects!
dPoint & p = (*o)[0][0];
dPoint t(1,0);
nearest_pt(lines, t, p, move_to_dist);
if (rotate)
o->opts.put<int>("Angle", lround(180/M_PI*atan2(t.y, t.x)));
}
}
}
} // namespace
|
ushakov/mapsoft
|
d6d689326933a6779909821c4fe7d711724c8847
|
add missing declaration for the previous commit
|
diff --git a/core/vmap/vmap.h b/core/vmap/vmap.h
index e48e330..dab479b 100644
--- a/core/vmap/vmap.h
+++ b/core/vmap/vmap.h
@@ -1,173 +1,174 @@
#ifndef VMAP_H
#define VMAP_H
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include "2d/line.h"
#include "options/options.h"
#include "fig/fig.h"
#include "vmap/zn.h"
#include "ocad/ocad_file.h"
// Class for vector map representation
// TODO - пÑовеÑиÑÑ ÑÑÑелки
// TODO - пÑовеÑиÑÑ ÑглÑ
namespace vmap {
/*****************************************************************/
extern const int label_type;
extern const int border_type;
extern const double label_search_dist1;
extern const double label_search_dist2;
extern const double label_search_dist3;
extern const double label_len;
extern const double label_new_dist;
extern const double default_rscale;
extern const std::string default_style;
// Label position
struct lpos {
int dir; // 0: left, 1: center, 2: right
double ang; // angle, degrees
int fsize; // Font size. Before connection to an object it is
// an absolute fig size.
// After connection it is a correction, 0, -1, +2 etc.
dPoint pos;
bool hor; // horizontal text (angle is not modified when the map rotates)
bool operator< (const lpos & o) const;
lpos();
};
// Separate label.
// Used when label is detached from an object
// Additional fields: Reference point (nearest object point)
// and label text.
struct lpos_full : public lpos { // for internal use
dPoint ref;
std::string text;
bool operator< (const lpos_full & o) const;
};
typedef enum{
POI = 0,
POLYLINE = 1,
POLYGON = 2
} object_class;
struct object: public dMultiLine {
int type; // MP type + 0x100000 for lines, 0x200000 for polygons
int dir; // direction from mp, arrows from fig
std::string text; // label text
std::list<lpos> labels;
Options opts; // some Key=Value fields
std::vector<std::string> comm; // comments
object_class get_class() const;
bool operator< (const object & o) const;
object();
};
struct world : std::list<object> {
int mp_id;
std::string name;
std::string style;
double rscale;
dLine brd;
std::list<lpos_full> lbuf; // buffer for ownerless labels
world();
dRect range() const;
// Add objects and lbuf from the world W, set style etc from W
void add(const world & W);
};
// Reading and writing fig (see vmap_fig.cpp):
world read(const fig::fig_world & F);
int write(fig::fig_world & F, const world & W, const Options & O = Options());
// Reading and writing mp (see vmap_mp.cpp):
world read(const mp::mp_world & M);
int write(mp::mp_world & M, const world & W, const Options & O = Options());
// Reading and writing ocad (see vmap_ocad.cpp) -- EXPERIMENTAL:
world read(const ocad::ocad_file & F);
int write(ocad::ocad_file & F, const world & W, const Options & O = Options());
// note: fig and mp write functions can't write lbuf yet. It is not
// a problem becouse vmap_copy always do add_labels
// Reading and writitng native format
world read(std::istream & IN);
int write(std::ostream & OUT, const world & W);
// Reading and writing any file (see vmap_file.cpp).
// Format is determined by extension (fig, mp).
// Options are passed to corresponding write() function.
world read(const char * fname);
int write(const char * fname, const world & W, const Options & O = Options());
// Functions for labels and pics handling (see vmap_labels.cpp):
+std::string conv_label(const std::string & s); ///< convert object label to a printable form
void join_labels(world & W); ///< join labels from lbuf to objects
void split_labels(world & W); ///< split labels from objects to lbuf
void create_labels(world & W); ///< create new labels
void remove_labels(world & W); ///< remove all lables
void move_pics(world & W); ///< move and rotate some signs
// make legend (see vmap_legend.cpp):
world make_legend(std::string style);
// filtering and statistics (see vmap_filt.cpp):
void filter(world & W, const Options & O);
void join_objects(world & W, double dist);
void remove_tails(world & W, double dist, const dRect & cutter, Conv * cnv = NULL);
void range_action(world & W, std::string action, const dRect & cutter, Conv * cnv = NULL);
// remove empty lines and objects
// (polygons with < 3pt, lines with < 2pt, points with < 1pt, lines and polygons with zero length)
// note: remove_tails and range_action do remove_empty
void remove_empty(world & W);
//remove repeated points
void remove_dups(world & W, double dist);
// remove inessential changes between WOLD and WNEW:
void fix_diff(const world & WOLD, world & WNEW, double dist);
/// create tmerc ref from brd or from map range (see vmap_ref.h):
g_map mk_tmerc_ref(const world & W, double u_per_cm, bool yswap=false);
// put source to options if it is not empty
void set_source(Options & o, const std::string & source);
// convert vector between meters and degrees (approximate)
// move to lib2d?
dPoint v_m2deg(const dPoint & v, const double lat);
dPoint v_deg2m(const dPoint & v, const double lat);
// approximate distance in m
double dist_pt(const dPoint & v, double lat);
// approximate distance in m
double dist_pt_pt(const dPoint & p1, const dPoint & p2);
// Find point n in the line l which is nearest to the point p.
// Return distance in m
double dist_pt_l(const dPoint & p, const dMultiLine & l, dPoint & n);
} // namespace
#endif
|
ushakov/mapsoft
|
8777c007744f8ab4515a2b41e9ca22e82a02b43f
|
vmap: add label conversion: two-character sequences to represent some unicode characters. They should be used when creating fig labels or rendering maps
|
diff --git a/core/vmap/vmap_fig.cpp b/core/vmap/vmap_fig.cpp
index 849a488..45ebcce 100644
--- a/core/vmap/vmap_fig.cpp
+++ b/core/vmap/vmap_fig.cpp
@@ -1,283 +1,283 @@
#include <list>
#include <vector>
#include <string>
#include <map>
#include <iostream>
#include "2d/line_utils.h"
#include "geo_io/geofig.h"
#include "geo/geo_convs.h"
#include "geo/geo_nom.h"
#include "vmap/zn.h"
#include "vmap.h"
namespace vmap {
using namespace std;
/***************************************/
// get vmap objects and labels from fig
world
read(const fig::fig_world & F){
world ret;
// get fig reference
g_map ref = fig::get_ref(F);
if (ref.size()<3){
std::cerr << "ERR: not a GEO-fig\n"; return ret;
}
convs::map2wgs cnv(ref);
// get map data
ret.rscale = 100 * convs::map_mpp(ref, Proj("tmerc")) * fig::cm2fig;
ret.rscale = F.opts.get<double>("rscale", ret.rscale);
ret.style = F.opts.get<string>("style", default_style);
ret.name = F.opts.get<string>("name");
ret.mp_id = F.opts.get<int>("mp_id", 0);
// get map objects and labels:
zn::zn_conv zconverter(ret.style);
std::vector<std::string> cmp_comm, comm;
for (fig::fig_world::const_iterator i=F.begin(); i!=F.end(); i++){
if (i->type==6) cmp_comm = i->comment;
if (i->type==-6) cmp_comm.clear();
if (zn::is_to_skip(*i)) continue;
// find normal labels
if ((i->opts.exists("MapType")) &&
(i->opts.get("MapType", std::string())=="label") &&
(i->opts.exists("RefPt")) &&
(i->is_text()) &&
(i->size()>0) ){
lpos_full l;
l.pos = (*i)[0]; cnv.frw(l.pos);
l.ref = i->opts.get("RefPt", l.pos); cnv.frw(l.ref);
l.dir = i->sub_type;
l.fsize = i->font_size; // now it is absolute value
l.text = i->text;
if (i->angle!=0){
// angle is inverted becouse of y inversion
l.ang = -cnv.angd_frw((*i)[0], 180/M_PI*i->angle, 1000);
l.hor = false;
}
else {
l.ang = 0;
l.hor = true;
}
ret.lbuf.push_back(l);
continue;
}
// read map objects
if (!zconverter.is_map_depth(*i)) continue;
int type = zconverter.get_type(*i);
if (!type) continue;
// copy comment from compound to the first object:
if (cmp_comm.size()>0){
comm=cmp_comm;
cmp_comm.clear();
}
else{
comm=i->comment;
}
// special type -- border
if (type==border_type){
ret.brd = cnv.line_frw(*i);
continue;
}
// special type -- label objects
if (type==label_type){
if (i->size()<2) continue;
if (comm.size()<1) continue;
lpos_full l;
l.text = comm[0];
l.ref = (*i)[0]; cnv.frw(l.ref);
l.pos = (*i)[1]; cnv.frw(l.pos);
l.dir = zn::fig_arr2dir(*i, true);
/* if (i->size()>=3){
dPoint dp=(*i)[2]-(*i)[1];
l.ang=cnv.angd_frw((*i)[0], 180/M_PI*atan2(dp.y, dp.x), 1000);
l.hor=false;
}*/
if (i->opts.exists("TxtAngle")){
double angle = i->opts.get<double>("TxtAngle", 0);
l.ang=cnv.angd_frw((*i)[0], angle, 1000);
l.hor=false;
}
else{
l.ang=0;
l.hor=true;
}
ret.lbuf.push_back(l);
continue;
}
// normal objects
object o;
o.type = type;
set_source(o.opts, i->opts.get<string>("Source"));
if (comm.size()>0){
o.text = comm[0];
o.comm.insert(o.comm.begin(),
comm.begin()+1, comm.end());
}
dLine pts = cnv.line_frw(*i);
// if closed polyline -> add one more point
if ((o.get_class() == POLYLINE) &&
(i->is_closed()) &&
(i->size()>0) &&
((*i)[0]!=(*i)[i->size()-1])) pts.push_back(pts[0]);
o.push_back(pts);
o.dir=zn::fig_arr2dir(*i);
if (o.size()>0) ret.push_back(o);
}
return ret;
}
/***************************************/
const double brd_fig_acc = 10; // border generalization accuracy in fig units
// put vmap to referenced fig
int
write(fig::fig_world & F, const world & W, const Options & O){
// get options
int append = O.get<int>("append", 0); // OPTION append 0
int fig_text_labels = O.get<int>("fig_text_labels", 1); // OPTION fig_text_labels 1
int keep_labels = O.get<int>("keep_labels", 0); // OPTION keep_labels 0
int keep_border = O.get<int>("keep_border", 0); // OPTION keep_border 0
zn::zn_conv zconverter(W.style);
g_map ref = fig::get_ref(F);
if (ref.size()<3){
ref = vmap::mk_tmerc_ref(W, fig::cm2fig, true);
fig::rem_ref(F);
fig::set_ref(F, ref, Options());
}
convs::map2wgs cnv(ref);
// cleanup fig if not in append mode
if (!append){
fig::fig_world::iterator i = F.begin();
while (i!=F.end()){
if ((i->type==6) || (i->type==-6)) // compounds
i=F.erase(i);
else if (zn::is_to_skip(*i)) // inessential sign parts
i=F.erase(i);
else if (!keep_labels && (i->opts.get<string>("MapType") == "label")) // labels
i=F.erase(i);
else if (!keep_border && (zconverter.get_type(*i) == border_type)) // border
i=F.erase(i);
else if ((zconverter.get_type(*i) != border_type) &&
zconverter.is_map_depth(*i)) // other objects
i=F.erase(i);
else i++;
}
}
// save map parameters
F.opts.put("style", W.style);
F.opts.put("rscale", W.rscale);
F.opts.put("name", W.name);
F.opts.put("mp_id", W.mp_id);
// add border
if (!keep_border && (W.brd.size()>0)){
fig::fig_object brd_o = zconverter.get_fig_template(border_type);
// convert and reduce point number
dLine brd=cnv.line_bck(W.brd);
brd.push_back(*brd.begin());
brd=generalize(brd, brd_fig_acc, -1);
brd.resize(brd.size()-1);
brd_o.set_points(brd);
brd_o.close();
brd_o.comment.push_back("BRD " + W.name);
if (W.brd.size()!=0) F.push_back(brd_o);
}
// add other objects
for (world::const_iterator o = W.begin(); o!=W.end(); o++){
if (o->size()==0) continue;
fig::fig_object fig = zconverter.get_fig_template(o->type);
set_source(fig.opts, o->opts.get<string>("Source"));
fig.comment.push_back(o->text);
fig.comment.insert(fig.comment.end(), o->comm.begin(), o->comm.end());
if (o->opts.exists("Angle")){
double a = o->opts.get<double>("Angle");
a=-cnv.angd_bck((*o)[0].center(), -a, 0.01);
fig.opts.put<double>("Angle", a);
}
if (o->get_class() == POLYGON){
fig.set_points(cnv.line_bck(join_polygons(*o)));
F.push_back(fig);
} else {
dMultiLine::const_iterator l;
for (l=o->begin(); l!=o->end(); l++){
fig.clear();
fig.open(); // previous part can be closed!
fig.set_points(cnv.line_bck(*l));
// closed polyline
if ((o->get_class() == POLYLINE) &&
(fig.size()>2) && (fig[0]==fig[fig.size()-1])){
fig.resize(fig.size()-1);
fig.close();
}
zn::fig_dir2arr(fig, o->dir); // arrows
// pictures
std::list<fig::fig_object> tmp=zconverter.make_pic(fig, o->type);
F.insert(F.end(), tmp.begin(), tmp.end());
}
}
// labels connected to the object
if (keep_labels || (o->text == "")) continue;
std::list<lpos>::const_iterator l;
for (l=o->labels.begin(); l!=o->labels.end(); l++){
dPoint ref; dist_pt_l(l->pos, *o, ref);
cnv.bck(ref);
dPoint pos = l->pos;
cnv.bck(pos);
double angle = l->hor ? 0 : cnv.angd_bck(l->pos, -l->ang, 0.01);
fig::fig_object txt;
if (fig_text_labels){
txt=zconverter.get_label_template(o->type);
- txt.text=o->text;
+ txt.text=conv_label(o->text);
txt.sub_type=l->dir;
txt.angle=M_PI/180*angle;
txt.font_size += l->fsize;
txt.push_back(pos);
txt.opts.put<iPoint>("RefPt", ref);
txt.opts.put<string>("MapType", "label");
}
else {
txt.clear();
txt=zconverter.get_fig_template(label_type);
zn::fig_dir2arr(txt, l->dir, true);
txt.push_back(ref);
txt.push_back(pos);
if (!l->hor) txt.opts.put<double>("TxtAngle", angle);
txt.comment.push_back(o->text);
}
F.push_back(txt);
}
}
// TODO: write detached labels (lbuf)!
return 1;
}
} // namespace
diff --git a/core/vmap/vmap_labels.cpp b/core/vmap/vmap_labels.cpp
index 36ea356..daf5c58 100644
--- a/core/vmap/vmap_labels.cpp
+++ b/core/vmap/vmap_labels.cpp
@@ -1,233 +1,303 @@
#include <list>
#include <vector>
#include <string>
#include <map>
#include <iostream>
#include <algorithm>
#include "2d/line_utils.h"
#include "2d/line_rectcrop.h"
#include "geo_io/geofig.h"
#include "geo/geo_convs.h"
#include "geo/geo_nom.h"
#include "vmap/zn.h"
#include "vmap.h"
namespace vmap {
using namespace std;
const double label_search_dist1 = 1.0; // cm
const double label_search_dist2 = 1.0;
const double label_search_dist3 = 0.1;
const double label_len = 0.3;
const double label_new_dist = 0.1;
const double move_to_dist = 0.002; // deg; -- inaccurate...
/***************************************/
+std::map<std::string,std::string> cnv_lable_map = {
+ {"`A", "\u00C0"}, {"`a", "\u00E0"},
+ {"\'A", "\u00C1"}, {"\'a", "\u00E1"},
+ {"^A", "\u00C3"}, {"^a", "\u00E2"},
+ {"~A", "\u00C3"}, {"~a", "\u00E3"},
+ {"\"A", "\u00C4"}, {"\"a", "\u00E4"},
+ {"AA", "\u00C5"}, {"aa", "\u00E5"},
+ {"AE", "\u00C6"}, {"ae", "\u00E6"},
+ {"cC", "\u00C7"}, {"cc", "\u00E7"},
+ {"`E", "\u00C8"}, {"\'e", "\u00E8"},
+ {"\'E", "\u00C9"}, {"\'e", "\u00E9"},
+ {"^E", "\u00CA"}, {"^e", "\u00EA"},
+ {"\"E", "\u00CB"}, {"\"e", "\u00EB"},
+ {"`I", "\u00CC"}, {"\'i", "\u00EC"},
+ {"\'I", "\u00CD"}, {"\'i", "\u00ED"},
+ {"^I", "\u00CE"}, {"^i", "\u00EE"},
+ {"\"I", "\u00CF"}, {"\"i", "\u00EF"},
+ {"NN", "\u00D1"}, {"nn", "\u00F1"},
+ {"`O", "\u00D2"}, {"\'o", "\u00F2"},
+ {"\'O", "\u00D3"}, {"\'o", "\u00F3"},
+ {"^O", "\u00D4"}, {"^o", "\u00F4"},
+ {"~O", "\u00D5"}, {"~o", "\u00F5"},
+ {"\"O", "\u00D6"}, {"\"o", "\u00F6"},
+ {"OO", "\u00D8"}, {"oo", "\u00F8"},
+ {"`U", "\u00D9"}, {"\'u", "\u00F9"},
+ {"\'U", "\u00DA"}, {"\'u", "\u00FA"},
+ {"^U", "\u00DB"}, {"^u", "\u00FB"},
+ {"\"U", "\u00DC"}, {"\"u", "\u00FC"},
+ {"\'Y", "\u00DD"}, {"\'y", "\u00FD"},
+
+ {".C", "\u010A"}, {".c", "\u010B"},
+ {"vC", "\u010C"}, {"vc", "\u010D"},
+ {"LL", "\u0141"}, {"ll", "\u0142"},
+ {"\'L", "\u013D"}, {"\'l", "\u013E"},
+ {"OE", "\u0152"}, {"oe", "\u0153"},
+ {"vT", "\u0164"}, {"\'t", "\u0165"},
+ {"\'Z", "\u0179"}, {"\'z", "\u017A"},
+ {".Z", "\u017B"}, {".z", "\u017C"},
+ {"vZ", "\u017D"}, {"vz", "\u017E"}
+};
+
+std::string
+conv_label(const std::string & str){
+ std::string ret;
+ for (size_t i = 0; i<str.size(); i++) {
+ auto c = str[i];
+ if (c!='#') { ret.push_back(c); continue; }
+ if (i>=str.size()-1) {
+ std::cerr << "conv_label: skipping # at the end: "<< str <<"\n";
+ continue;
+ }
+ i++;
+ if (str[i]=='#') {ret+=c; continue;} // "##"
+ if (i>=str.size()-1) {
+ std::cerr << "conv_label: skipping # at the end: "<< str <<"\n";
+ continue;
+ }
+ auto ss = str.substr(i,2);
+ i++;
+ auto ii = cnv_lable_map.find(ss);
+ if (ii==cnv_lable_map.end()){
+ std::cerr << "conv_label: unknown sequence: #" << ss << " in: "<< str <<"\n";
+ continue;
+ } // unknown
+ ret += ii->second;
+ }
+ std::cerr << ">>> " << ret << "\n";
+ return ret;
+}
+
void
join_labels(world & W){
std::list<lpos_full>::iterator l, l0;
world::iterator o;
dPoint p, p0;
zn::zn_conv zc(W.style);
// one nearest label with correct text (label_search_dist1 parameter)
for (o=W.begin(); o!=W.end(); o++){
if ((o->text == "") || (zc.get_label_type(o->type)==0)) continue;
double d0=1e99;
for (l=W.lbuf.begin(); l!=W.lbuf.end(); l++){
if (l->text != o->text) continue;
double d = dist_pt_l(l->ref, *o, p);
if ( d < d0){ d0=d; p0=p; l0=l;}
}
if (d0 * 100 / W.rscale < label_search_dist1){
l0->fsize -= zc.get_label_template(o->type).font_size;
o->labels.push_back(*l0);
W.lbuf.erase(l0);
}
}
// labels with correct text (label_search_dist2 parameter)
for (o=W.begin(); o!=W.end(); o++){
if ((o->text == "") || (zc.get_label_type(o->type)==0)) continue;
l=W.lbuf.begin();
while (l!=W.lbuf.end()){
// near ref or near pos
if ( ((l->text == o->text) &&
(dist_pt_l(l->ref, *o, p)* 100 / W.rscale < label_search_dist2)) ||
((l->text == o->text) &&
(dist_pt_l(l->pos, *o, p)* 100 / W.rscale < label_search_dist2)) ){
l->fsize -= zc.get_label_template(o->type).font_size;
o->labels.push_back(*l);
l = W.lbuf.erase(l);
continue;
}
l++;
}
}
// labels with changed text (label_search_dist3 parameter)
for (o=W.begin(); o!=W.end(); o++){
if ((o->text == "") || (zc.get_label_type(o->type)==0)) continue;
l=W.lbuf.begin();
while (l!=W.lbuf.end()){
if (dist_pt_l(l->ref, *o, p)* 100 / W.rscale < label_search_dist3){
l->fsize -= zc.get_label_template(o->type).font_size;
o->labels.push_back(*l);
l = W.lbuf.erase(l);
continue;
}
l++;
}
}
// clear unused labels
W.lbuf.clear();
}
/***************************************/
void
split_labels(world & W){
zn::zn_conv zc(W.style);
for (world::iterator o = W.begin(); o!=W.end(); o++){
for (std::list<lpos>::iterator l=o->labels.begin(); l!=o->labels.end(); l++){
lpos_full ll;
ll.lpos::operator=(*l);
ll.fsize += zc.get_label_template(o->type).font_size;
ll.text = o->text;
dist_pt_l(l->pos, *o, ll.ref);
W.lbuf.push_back(ll);
}
o->labels.clear();
}
}
/***************************************/
dPoint
max_xmy(const dLine & l){
if (l.size()<1) return dPoint(0,0);
dPoint p(l[0]);
double max = p.x-p.y;
for (dLine::const_iterator i = l.begin(); i!=l.end(); i++){
if (i->x - i->y > max) {
max = i->x - i->y;
p = *i;
}
}
return p;
}
dPoint
max_xpy(const dLine & l){
if (l.size()<1) return dPoint(0,0);
dPoint p(l[0]);
double max = p.x+p.y;
for (dLine::const_iterator i = l.begin(); i!=l.end(); i++){
if (i->x + i->y > max) {
max = i->x + i->y;
p = *i;
}
}
return p;
}
/***************************************/
// create new labels
void
create_labels(world & W){
zn::zn_conv zc(W.style);
for (world::iterator o=W.begin(); o!=W.end(); o++){
if ((o->labels.size()>0) || (o->text=="")) continue;
int lt = zc.get_label_type(o->type);
int ld = zc.get_label_dir(o->type);
if (lt==0) continue; // no label for this object
for (dMultiLine::iterator i=o->begin(); i!=o->end(); i++){
if (i->size()<1) continue;
if (o->type >= zn::line_mask && i->size()<2) continue;
// do not create labels for >2pt line and area objects
lpos l;
l.ang = 0;
l.dir = ld;
l.hor = true;
switch (lt){
case 1: // TR side of object (max x-y point + (1,-1)*td)
l.pos = max_xpy(*i) +
v_m2deg(W.rscale / 100.0 * dPoint(1,1) * label_new_dist/sqrt(2.0), (*i)[0].y);
break;
case 2: // TL side of object
l.pos = max_xmy(*i) +
v_m2deg(W.rscale / 100.0 * dPoint(-1,1) * label_new_dist/sqrt(2.0), (*i)[0].y);
break;
case 3: // object center
l.pos = i->range().CNT();
break;
case 4: // along the line
if (i->size()>=2){
dPoint cp = ((*i)[i->size()/2-1] + (*i)[i->size()/2]) / 2;
dPoint dp = (*i)[i->size()/2-1] - (*i)[i->size()/2];
if ((dp.x == 0) && (dp.y == 0)) dp.x = 1;
dPoint v = pnorm(dp);
if (v.x<0) v=-v;
l.ang = 180.0/M_PI*atan2(v.y, v.x);
l.pos = cp +
v_m2deg(W.rscale / 100.0 * dPoint(-v.y, v.x)*label_new_dist, (*i)[0].y);
l.hor = false;
}
else if (i->size()==1) l.pos = (*i)[0];
break;
}
o->labels.push_back(l);
}
}
}
/***************************************/
void
remove_labels(world & W){
W.lbuf.clear();
for (world::iterator o = W.begin(); o!=W.end(); o++)
o->labels.clear();
}
/***************************************/
void
move_pics(world & W){
zn::zn_conv zc(W.style);
for (map<int, zn::zn>::const_iterator z=zc.znaki.begin(); z!=zc.znaki.end(); z++){
const vector<int> & mt = z->second.move_to;
if (mt.size()==0) continue;
bool rotate = z->second.rotate;
int type = z->first;
dMultiLine lines;
for (world::const_iterator o=W.begin(); o!=W.end(); o++){
if (std::find(mt.begin(), mt.end(), o->type) != mt.end())
lines.insert(lines.end(), o->begin(), o->end());
}
for (world::iterator o=W.begin(); o!=W.end(); o++){
if (o->type!=type) continue;
if (o->size()!=1) continue;
if ((*o)[0].size()!=1) continue; // only 1-segment, 1-point objects!
dPoint & p = (*o)[0][0];
dPoint t(1,0);
nearest_pt(lines, t, p, move_to_dist);
if (rotate)
o->opts.put<int>("Angle", lround(180/M_PI*atan2(t.y, t.x)));
}
}
}
} // namespace
|
ushakov/mapsoft
|
e51645da7bbb7f6ca6505dd6e6f9a009556a78c1
|
20220624-alt1
|
diff --git a/mapsoft.spec b/mapsoft.spec
index e4a6113..e2fde59 100644
--- a/mapsoft.spec
+++ b/mapsoft.spec
@@ -1,210 +1,217 @@
Name: mapsoft
-Version: 20210121
+Version: 20220624
Release: alt1
License: GPL3.0
Summary: mapsoft - programs for working with maps and geodata
Group: Sciences/Geosciences
Url: http://github.org/ushakov/mapsoft
Packager: Vladislav Zavjalov <[email protected]>
Source: %name-%version.tar
BuildRequires: boost-devel gcc-c++ libcurl-devel libzip-devel zlib-devel
BuildRequires: libcairomm-devel libpixman-devel libgtkmm2-devel
BuildRequires: libpng-devel libjpeg-devel libtiff-devel libgif-devel
BuildRequires: libusb-devel libyaml-devel libxml2-devel proj-devel
BuildRequires: libjansson-devel libshape-devel
BuildRequires: python-devel scons swig m4
BuildRequires: /usr/bin/gs netpbm transfig ImageMagick-tools /usr/bin/pod2man
BuildRequires: boost-geometry-devel perl-Text-Iconv
%package tools
Summary: mapsoft-tools - rarely-used tools from mapsoft package
Group: Sciences/Geosciences
Requires: %name = %version-%release
%package vmap
Summary: mapsoft-vmap - programs for working with vector maps
Group: Sciences/Geosciences
Requires: %name = %version-%release
%description
mapsoft - programs for working with maps and geodata
%description tools
mapsoft-tools - rarely-used tools from mapsoft package
%description vmap
mapsoft-vmap - programs for working with vector maps
%prep
%setup -q
%build
# boost::spirit crashes with -O2 on 32-bit systems
%if "%_lib" == "lib64"
export CCFLAGS=-O2
%endif
scons -Q minimal=1
%install
scons -Q minimal=1 -Q prefix=%buildroot install
%files
%_bindir/mapsoft_convert
%_bindir/mapsoft_mapview
%_mandir/man1/mapsoft_convert.*
%_mandir/man1/mapsoft_mapview.*
%_desktopdir/mapsoft_mapview.*
%files tools
%_bindir/convs_*
%_bindir/mapsoft_toxyz
%_bindir/mapsoft_geofig
%_bindir/mapsoft_mkmap
%_mandir/man1/mapsoft_geofig.*
%_libdir/gimp/2.0/plug-ins/map-helper.py
%files vmap
%_bindir/mapsoft_vmap
%_bindir/vmap_copy
%_bindir/vmap_render
%dir %_datadir/mapsoft
%_datadir/mapsoft/*
%_datadir/xfig/Libraries/*
%_mandir/man1/mapsoft_vmap.*
%_bindir/map_rescale
%_bindir/*.sh
%_bindir/map_*_gk
%_bindir/map_*_nom
%_bindir/mapsoft_wp_parse
%changelog
+* Fri Jun 24 2022 Vladislav Zavjalov <[email protected]> 20220624-alt1
+- fix build with gcc12.1.1: std::ws set failbit on eof
+- scripts: install mapsoft_map.sh to fix script deps
+- do not install convs_gtiles
+- small updates in map styles
+- mapsoft_srtm2fig: sctn operation (finding slope contours)
+
* Thu Jan 21 2021 Vladislav Zavjalov <[email protected]> 20210121-alt1
- scripts/mapsoft_wp_parse: fix name conversions
- skip convs_gtiles program in Altlinux build (build problem with new boost)
- vector/data: add new types: point 0x650B, 0x650C (glacier names)
- vector/vmap3/vmap_mmb_filter: convert glacier names to points
- vector/vmap3: add vmap_put_track and vmap_get_track programs
- programs/mapsoft_map2fig: put images into compound object; add 50px margins
* Sat Dec 12 2020 Vladislav Zavjalov <[email protected]> 20201212-alt1
- img_io/gobj_vmap: draw pattens with solid color at small scales (A.Kazantsev)
- fix for gcc-10
- fix a few compilation warnings (with -Wall) and a couple of possible related errors
- remove -O2 flag on i586 and armh (problem with new boost::spirit)
* Sun Dec 01 2019 Vladislav Zavjalov <[email protected]> 20191201-alt1
- fix a few problems in vmap_render and convs_gtiles (thanks to A.Kazantsev)
- add GPL3.0 license (Altlinux requires ambiguous license for all packages)
- fix python shebang (python -> python2)
* Sun Nov 10 2019 Vladislav Zavjalov <[email protected]> 20191110-alt1
- add more scripts to mapsoft_vmap package
* Fri Oct 04 2019 Vladislav Zavjalov <[email protected]> 20190916-alt2
- fix build with libproj 6.2.0 (use DACCEPT_USE_OF_DEPRECATED_PROJ_API_H)
* Mon Sep 16 2019 Vladislav Zavjalov <[email protected]> 20190916-alt1
- Fix build with new scons/python
- mapsoft_geofig: --raw option
- mapsoft_mapview: add desktop file
- mapsoft_vmap: fix error in label creation introduced in 2018-06-16
* Fri Feb 15 2019 Vladislav Zavjalov <[email protected]> 20190213-alt2
- rebuild with libproj 5.2.0
* Wed Feb 13 2019 Vladislav Zavjalov <[email protected]> 20190213-alt1
- current snapshot
* Sun Jul 22 2018 Vladislav Zavjalov <[email protected]> 20180722-alt1
- current snapshot
* Wed Feb 03 2016 Vladislav Zavjalov <[email protected]> 20160202-alt1.1
- rebuild with new libproj
* Tue Feb 02 2016 Vladislav Zavjalov <[email protected]> 20160202-alt1
- build fix (man page extensions, .gz -> .*)
* Mon Oct 19 2015 Anton V. Boyarshinov <[email protected]> 20150103-alt1.2
- build fixed
* Fri Jun 12 2015 Gleb F-Malinovskiy <[email protected]> 20150103-alt1.1
- Rebuilt for gcc5 C++11 ABI.
* Sat Jan 03 2015 Vladislav Zavjalov <[email protected]> 20150103-alt1
- current snapshot
* Wed Mar 05 2014 Vladislav Zavjalov <[email protected]> 20140305-alt2
- current snapshot
* Wed Mar 05 2014 Vladislav Zavjalov <[email protected]> 20140305-alt1
- current snapshot
* Tue Apr 09 2013 Vladislav Zavjalov <[email protected]> 20130409-alt1
- current snapshot:
* Thu Nov 29 2012 Vladislav Zavjalov <[email protected]> 20121129-alt1
- current snapshot
- viewer projection change from menu
- conic projection support
- improve large maps handling
- kml read/write support
- some fixes
* Tue Oct 09 2012 Vladislav Zavjalov <[email protected]> 20121009-alt2
- one more fix for new gcc
* Tue Oct 09 2012 Vladislav Zavjalov <[email protected]> 20121009-alt1
- current snapshot, fix for new gcc
* Wed Sep 19 2012 Vladislav Zavjalov <[email protected]> 20120919-alt1
- rebuld with libpng15
- current snapshot:
- partial read/write kml support
- fix errors in save_image action
* Mon Jun 25 2012 Vladislav Zavjalov <[email protected]> 20120625-alt1
- current snapshot
- simple navigation mode
- support for tiled maps, some examples
- faster map rescaling
- support for finnish KKJ maps
- add map-helper and mapsoft_mkmap to mapsoft-tools package
- increase thickness of viewer marks
* Wed Jun 20 2012 Vladislav Zavjalov <[email protected]> 20120620-alt1
- current snapshot (more bugs fixed)
* Wed Jun 20 2012 Vladislav Zavjalov <[email protected]> 20120619-alt1
- build current snapshot (some bugs fixed)
* Sun Jun 17 2012 Vladislav Zavjalov <[email protected]> 20120617-alt1
- build current snapshot
* Sun May 06 2012 Vladislav Zavjalov <[email protected]> 20120506-alt1
- build current snapshot
* Mon Mar 05 2012 Vladislav Zavjalov <[email protected]> 20120304-alt1
- build current snapshot
* Thu Feb 16 2012 Vladislav Zavjalov <[email protected]> 20120222-alt1
- build current snapshot (16-02-2012)
* Sun Feb 12 2012 Vladislav Zavjalov <[email protected]> 20120221-alt1
- build current snapshot (12-02-2012)
* Wed Feb 08 2012 Vladislav Zavjalov <[email protected]> 20120220-alt1
- build current snapshot (08-02-2012)
* Tue Jan 10 2012 Vladislav Zavjalov <[email protected]> 20120110-alt1
- build current snapshot
* Tue Nov 22 2011 Vladislav Zavjalov <[email protected]> 20111122-alt1
- build current snapshot
* Thu Nov 19 2009 Vladislav Zavjalov <[email protected]> 20091119-alt1
- first build for altlinux
|
ushakov/mapsoft
|
97a2865141749c6e2fa9f5c4c2c179e6656b95d8
|
2d/point.h: fix build with gcc12.1.1: std::ws set failbit on eof
|
diff --git a/core/2d/point.h b/core/2d/point.h
index 367680d..30fdb63 100644
--- a/core/2d/point.h
+++ b/core/2d/point.h
@@ -1,194 +1,195 @@
#ifndef POINT_H
#define POINT_H
#include <boost/operators.hpp>
#include <ios> // for << and >> operators
#include <iomanip> // for setprecision
#include <istream> // for std::ws
#include <cmath> // for rint
///\addtogroup lib2d
///@{
///\defgroup point
///@{
/// 2-d point
template <typename T>
struct Point
#ifndef SWIG
: public boost::additive<Point<T> >,
public boost::multiplicative<Point<T>,T>,
public boost::less_than_comparable<Point<T> >,
public boost::equality_comparable<Point<T> >
#endif
{
T x; ///< x coordinate
T y; ///< y coordinate
/// Constructors
Point(T _x, T _y): x(_x), y(_y) { }
Point(): x(0), y(0) { }
/// Swap point with other one.
void
swap (Point & other)
{
std::swap (x, other.x);
std::swap (y, other.y);
}
/// Subtract corresponding coordinates: p=Point(p.x-other.x, p.y-other.y).
Point<T> & operator-= (Point const & other)
{
x -= other.x;
y -= other.y;
return *this;
}
/// Add corresponding coordinates: p=Point(p.x+other.x, p.y+other.y).
Point<T> & operator+= (Point const & other)
{
x += other.x;
y += other.y;
return *this;
}
/// Divide coordinates by k: p=Point(p.x/k, p.y/k).
Point<T> & operator/= (T k)
{
x /= k;
y /= k;
return *this;
}
/// Multiply coordinates by k: p=Point(p.x*k, p.y*k).
Point<T> & operator*= (T k)
{
x *= k;
y *= k;
return *this;
}
/// Invert point coordinates.
Point<T> & operator- ()
{
x = -x;
y = -y;
return *this;
}
#ifndef SWIG
/// Less then operator: (x < other.x) || ((x == other.x) && (y < other.y)).
bool operator< (const Point<T> & other) const
{
return (x<other.x) || ((x==other.x)&&(y<other.y));
}
/// Equal opertator: (x==other.x) && (y==other.y).
bool operator== (const Point<T> & other) const
{
return (x==other.x)&&(y==other.y);
}
/// Cast to Point<double>.
operator Point<double>() const{
return Point<double>(double(this->x), double(this->y));
}
/// Cast to Point<int>.
operator Point<int>() const{
return Point<int>(int(rint(this->x)), int(rint(this->y)));
}
#else // SWIG
// Replace boost added standalone operators.
%extend {
Point<T> operator+ (Point<T> const & t) { return *$self + t; }
Point<T> operator- (Point<T> const & t) { return *$self - t; }
Point<T> operator/ (T k) { return *$self / k; }
Point<T> operator* (T k) { return *$self * k; }
swig_cmp(Point<T>);
swig_str();
}
#endif // SWIG
/// Calculate manhattan length: abs(x)+abs(y).
/** \todo remove -- NOT USED!
*/
T manhattan_length () const
{
return abs(x) + abs(y);
}
};
/// \relates Point
/// \brief Output operator: print point as a comma-separated pair of coordinartes.
template <typename T>
std::ostream & operator<< (std::ostream & s, const Point<T> & p){
s << std::noshowpos << std::setprecision(9) << p.x << "," << p.y;
return s;
}
/// \relates Point
/// \brief Input operator: read point from a comma-separated pair of coordainates.
template <typename T>
std::istream & operator>> (std::istream & s, Point<T> & p){
char sep;
s >> std::ws >> p.x >> std::ws >> sep;
if (sep!=','){
s.setstate(std::ios::failbit);
return s;
}
- s >> std::ws >> p.y >> std::ws;
+ s >> std::ws >> p.y;
+ if (!s.eof()) s >> std::ws;
s.setstate(std::ios::goodbit);
return s;
}
/// \relates Point
/// \brief Scalar multiplication: p1.x*p2.x + p1.y*p2.y.
template <typename T>
double pscal(const Point<T> & p1, const Point<T> & p2){
return p1.x*p2.x + p1.y*p2.y;
}
/// \relates Point
/// \brief Length: sqrt(double(p.x*p.x + p.y*p.y)).
/// \todo move to Point class?
template <typename T>
double pdist(const Point<T> & p){
return sqrt((double)(pscal(p,p)));
}
/// \relates Point
/// \brief Distance: pdist(p1-p2).
template <typename T>
double pdist(const Point<T> & p1, const Point<T> & p2){
return pdist(p1-p2);
}
/// \relates Point
/// \brief Normalize.
/// \todo move to Point class?
template <typename T>
Point<double> pnorm(const Point<T> & p){
double l = pdist(p);
return Point<double>(double(p.x)/l, double(p.y/l));
}
/// \relates Point
/// \brief Absolute value.
/// \todo move to Point class?
template <typename T>
Point<T> pabs(const Point<T> & p){
return Point<T>(
p.x>0?p.x:-p.x,
p.y>0?p.y:-p.y
);
}
/// \relates Point
/// \brief Point with double coordinates
typedef Point<double> dPoint;
/// \relates Point
/// \brief Point with int coordinates
typedef Point<int> iPoint;
#endif /* POINT_H */
|
ushakov/mapsoft
|
5c7837bc38b552aedafdfaea1c0e882238e44c57
|
scripts: install mapsoft_map.sh to have all script deps
|
diff --git a/scripts/SConscript b/scripts/SConscript
index 19cae92..8712164 100644
--- a/scripts/SConscript
+++ b/scripts/SConscript
@@ -1,24 +1,25 @@
Import ('env')
# Making map reference in GIMP
env.Install(env.libdir + '/gimp/2.0/plug-ins', 'map-helper.py')
env.Install(env.bindir, 'map_rescale')
env.Install(env.bindir, 'mapsoft_crd.sh')
+env.Install(env.bindir, 'mapsoft_map.sh')
# Updating glaciers from GLIMS catalog
env.Install(env.bindir, 'mapsoft_gl.sh')
env.Install(env.bindir, 'map_gl_upd_gk')
env.Install(env.bindir, 'map_gl_upd_nom')
# Updating mountain passes from Westra catalog
env.Install(env.bindir, 'mapsoft_wp.sh')
env.Install(env.bindir, 'map_wp_upd_gk')
env.Install(env.bindir, 'map_wp_upd_nom')
env.Install(env.bindir, 'mapsoft_wp_parse')
# Downloading Wikimapia data
env.Install(env.bindir, 'mapsoft_wm.sh')
env.Install(env.bindir, 'map_wm_nom')
|
ushakov/mapsoft
|
0fbf1e39f3d7fbe3f5c67f56997745ac6526c8b4
|
remove 0001-skip-convs_gtiles.patch
|
diff --git a/.gear-rules b/.gear-rules
index 4aac8f5..461a5cb 100644
--- a/.gear-rules
+++ b/.gear-rules
@@ -1,2 +1 @@
tar: .
-copy: *.patch
\ No newline at end of file
diff --git a/0001-skip-convs_gtiles.patch b/0001-skip-convs_gtiles.patch
deleted file mode 100644
index 16f42d9..0000000
--- a/0001-skip-convs_gtiles.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From ec23abf1536ff4e6b65fb66aef990a7a129629bb Mon Sep 17 00:00:00 2001
-From: Vladislav Zavjalov <[email protected]>
-Date: Thu, 21 Jan 2021 21:41:44 +0000
-Subject: [PATCH] skip convs_gtiles program
-
----
- programs/SConscript | 2 --
- 1 file changed, 2 deletions(-)
-
-diff --git a/programs/SConscript b/programs/SConscript
-index ca350a71..c91a2229 100644
---- a/programs/SConscript
-+++ b/programs/SConscript
-@@ -14,7 +14,6 @@ progs = Split("""
- convs_pt2pt
- convs_map2pt
- convs_nom
-- convs_gtiles
- mapsoft_vmap
- """)
-
-@@ -30,7 +29,6 @@ env.Install(env.bindir, Split("""
- convs_pt2pt
- convs_map2pt
- convs_nom
-- convs_gtiles
- """))
-
- env.SymLink("mapsoft_vmap", "vmap_copy", env.bindir)
---
-2.24.1
-
diff --git a/mapsoft.spec b/mapsoft.spec
index f1d14fb..e4a6113 100644
--- a/mapsoft.spec
+++ b/mapsoft.spec
@@ -1,212 +1,210 @@
Name: mapsoft
Version: 20210121
Release: alt1
License: GPL3.0
Summary: mapsoft - programs for working with maps and geodata
Group: Sciences/Geosciences
Url: http://github.org/ushakov/mapsoft
Packager: Vladislav Zavjalov <[email protected]>
Source: %name-%version.tar
-Patch1: 0001-skip-convs_gtiles.patch
BuildRequires: boost-devel gcc-c++ libcurl-devel libzip-devel zlib-devel
BuildRequires: libcairomm-devel libpixman-devel libgtkmm2-devel
BuildRequires: libpng-devel libjpeg-devel libtiff-devel libgif-devel
BuildRequires: libusb-devel libyaml-devel libxml2-devel proj-devel
BuildRequires: libjansson-devel libshape-devel
BuildRequires: python-devel scons swig m4
BuildRequires: /usr/bin/gs netpbm transfig ImageMagick-tools /usr/bin/pod2man
BuildRequires: boost-geometry-devel perl-Text-Iconv
%package tools
Summary: mapsoft-tools - rarely-used tools from mapsoft package
Group: Sciences/Geosciences
Requires: %name = %version-%release
%package vmap
Summary: mapsoft-vmap - programs for working with vector maps
Group: Sciences/Geosciences
Requires: %name = %version-%release
%description
mapsoft - programs for working with maps and geodata
%description tools
mapsoft-tools - rarely-used tools from mapsoft package
%description vmap
mapsoft-vmap - programs for working with vector maps
%prep
%setup -q
-%patch1 -p1
%build
# boost::spirit crashes with -O2 on 32-bit systems
%if "%_lib" == "lib64"
export CCFLAGS=-O2
%endif
scons -Q minimal=1
%install
scons -Q minimal=1 -Q prefix=%buildroot install
%files
%_bindir/mapsoft_convert
%_bindir/mapsoft_mapview
%_mandir/man1/mapsoft_convert.*
%_mandir/man1/mapsoft_mapview.*
%_desktopdir/mapsoft_mapview.*
%files tools
%_bindir/convs_*
%_bindir/mapsoft_toxyz
%_bindir/mapsoft_geofig
%_bindir/mapsoft_mkmap
%_mandir/man1/mapsoft_geofig.*
%_libdir/gimp/2.0/plug-ins/map-helper.py
%files vmap
%_bindir/mapsoft_vmap
%_bindir/vmap_copy
%_bindir/vmap_render
%dir %_datadir/mapsoft
%_datadir/mapsoft/*
%_datadir/xfig/Libraries/*
%_mandir/man1/mapsoft_vmap.*
%_bindir/map_rescale
%_bindir/*.sh
%_bindir/map_*_gk
%_bindir/map_*_nom
%_bindir/mapsoft_wp_parse
%changelog
* Thu Jan 21 2021 Vladislav Zavjalov <[email protected]> 20210121-alt1
- scripts/mapsoft_wp_parse: fix name conversions
- skip convs_gtiles program in Altlinux build (build problem with new boost)
- vector/data: add new types: point 0x650B, 0x650C (glacier names)
- vector/vmap3/vmap_mmb_filter: convert glacier names to points
- vector/vmap3: add vmap_put_track and vmap_get_track programs
- programs/mapsoft_map2fig: put images into compound object; add 50px margins
* Sat Dec 12 2020 Vladislav Zavjalov <[email protected]> 20201212-alt1
- img_io/gobj_vmap: draw pattens with solid color at small scales (A.Kazantsev)
- fix for gcc-10
- fix a few compilation warnings (with -Wall) and a couple of possible related errors
- remove -O2 flag on i586 and armh (problem with new boost::spirit)
* Sun Dec 01 2019 Vladislav Zavjalov <[email protected]> 20191201-alt1
- fix a few problems in vmap_render and convs_gtiles (thanks to A.Kazantsev)
- add GPL3.0 license (Altlinux requires ambiguous license for all packages)
- fix python shebang (python -> python2)
* Sun Nov 10 2019 Vladislav Zavjalov <[email protected]> 20191110-alt1
- add more scripts to mapsoft_vmap package
* Fri Oct 04 2019 Vladislav Zavjalov <[email protected]> 20190916-alt2
- fix build with libproj 6.2.0 (use DACCEPT_USE_OF_DEPRECATED_PROJ_API_H)
* Mon Sep 16 2019 Vladislav Zavjalov <[email protected]> 20190916-alt1
- Fix build with new scons/python
- mapsoft_geofig: --raw option
- mapsoft_mapview: add desktop file
- mapsoft_vmap: fix error in label creation introduced in 2018-06-16
* Fri Feb 15 2019 Vladislav Zavjalov <[email protected]> 20190213-alt2
- rebuild with libproj 5.2.0
* Wed Feb 13 2019 Vladislav Zavjalov <[email protected]> 20190213-alt1
- current snapshot
* Sun Jul 22 2018 Vladislav Zavjalov <[email protected]> 20180722-alt1
- current snapshot
* Wed Feb 03 2016 Vladislav Zavjalov <[email protected]> 20160202-alt1.1
- rebuild with new libproj
* Tue Feb 02 2016 Vladislav Zavjalov <[email protected]> 20160202-alt1
- build fix (man page extensions, .gz -> .*)
* Mon Oct 19 2015 Anton V. Boyarshinov <[email protected]> 20150103-alt1.2
- build fixed
* Fri Jun 12 2015 Gleb F-Malinovskiy <[email protected]> 20150103-alt1.1
- Rebuilt for gcc5 C++11 ABI.
* Sat Jan 03 2015 Vladislav Zavjalov <[email protected]> 20150103-alt1
- current snapshot
* Wed Mar 05 2014 Vladislav Zavjalov <[email protected]> 20140305-alt2
- current snapshot
* Wed Mar 05 2014 Vladislav Zavjalov <[email protected]> 20140305-alt1
- current snapshot
* Tue Apr 09 2013 Vladislav Zavjalov <[email protected]> 20130409-alt1
- current snapshot:
* Thu Nov 29 2012 Vladislav Zavjalov <[email protected]> 20121129-alt1
- current snapshot
- viewer projection change from menu
- conic projection support
- improve large maps handling
- kml read/write support
- some fixes
* Tue Oct 09 2012 Vladislav Zavjalov <[email protected]> 20121009-alt2
- one more fix for new gcc
* Tue Oct 09 2012 Vladislav Zavjalov <[email protected]> 20121009-alt1
- current snapshot, fix for new gcc
* Wed Sep 19 2012 Vladislav Zavjalov <[email protected]> 20120919-alt1
- rebuld with libpng15
- current snapshot:
- partial read/write kml support
- fix errors in save_image action
* Mon Jun 25 2012 Vladislav Zavjalov <[email protected]> 20120625-alt1
- current snapshot
- simple navigation mode
- support for tiled maps, some examples
- faster map rescaling
- support for finnish KKJ maps
- add map-helper and mapsoft_mkmap to mapsoft-tools package
- increase thickness of viewer marks
* Wed Jun 20 2012 Vladislav Zavjalov <[email protected]> 20120620-alt1
- current snapshot (more bugs fixed)
* Wed Jun 20 2012 Vladislav Zavjalov <[email protected]> 20120619-alt1
- build current snapshot (some bugs fixed)
* Sun Jun 17 2012 Vladislav Zavjalov <[email protected]> 20120617-alt1
- build current snapshot
* Sun May 06 2012 Vladislav Zavjalov <[email protected]> 20120506-alt1
- build current snapshot
* Mon Mar 05 2012 Vladislav Zavjalov <[email protected]> 20120304-alt1
- build current snapshot
* Thu Feb 16 2012 Vladislav Zavjalov <[email protected]> 20120222-alt1
- build current snapshot (16-02-2012)
* Sun Feb 12 2012 Vladislav Zavjalov <[email protected]> 20120221-alt1
- build current snapshot (12-02-2012)
* Wed Feb 08 2012 Vladislav Zavjalov <[email protected]> 20120220-alt1
- build current snapshot (08-02-2012)
* Tue Jan 10 2012 Vladislav Zavjalov <[email protected]> 20120110-alt1
- build current snapshot
* Tue Nov 22 2011 Vladislav Zavjalov <[email protected]> 20111122-alt1
- build current snapshot
* Thu Nov 19 2009 Vladislav Zavjalov <[email protected]> 20091119-alt1
- first build for altlinux
|
ushakov/mapsoft
|
aeab9a8f0a862a27d5c665ead4aca64f0481cebf
|
SConscript: remove old vmap4 folder
|
diff --git a/vector/SConscript b/vector/SConscript
index d62b7ef..6512ac5 100644
--- a/vector/SConscript
+++ b/vector/SConscript
@@ -1,7 +1,6 @@
subdirs = Split ("""
libzn-utils
vmap3
- vmap4
data
""")
SConscript (list(map(lambda s: s+"/SConscript", subdirs)))
|
ushakov/mapsoft
|
d8cf5292f0e955807ffc365c971fa32ab8cc572f
|
remove convs_gtiles from install rule
|
diff --git a/programs/SConscript b/programs/SConscript
index 4301739..bcdf484 100644
--- a/programs/SConscript
+++ b/programs/SConscript
@@ -1,39 +1,40 @@
Import ('env')
progs = Split("""
mapsoft_convert
mapsoft_mkmap
mapsoft_ref
mapsoft_toxyz
mapsoft_map2fig
mapsoft_srtm2fig
mapsoft_fig2fig
mapsoft_pano
mapsoft_geofig
convs_pt2pt
convs_map2pt
convs_nom
mapsoft_vmap
""")
# convs_gtiles
for p in progs:
env.Program(p + '.cpp')
env.Install(env.bindir, Split("""
mapsoft_convert
mapsoft_vmap
mapsoft_geofig
mapsoft_toxyz
mapsoft_mkmap
convs_pt2pt
convs_map2pt
convs_nom
- convs_gtiles
"""))
+# convs_gtiles
+
env.SymLink("mapsoft_vmap", "vmap_copy", env.bindir)
|
ushakov/mapsoft
|
9f6bfff9ab82fc3dafa370c99b1bbbd9c025b6cf
|
fix errors in vmap_get_track/vmap_put_track
|
diff --git a/vector/vmap3/vmap_get_track.cpp b/vector/vmap3/vmap_get_track.cpp
index 6c5ba1c..1629996 100644
--- a/vector/vmap3/vmap_get_track.cpp
+++ b/vector/vmap3/vmap_get_track.cpp
@@ -1,81 +1,81 @@
#include <string>
#include <cstring>
#include "options/m_getopt.h"
#include "vmap/vmap.h"
#include "vmap/zn.h"
#include "fig/fig.h"
#include "geo_io/io.h"
using namespace std;
// extract objects of a single type
// and write as geodata
int
main(int argc, char **argv){
try{
if (argc!=5) {
std::cerr << "usage: vmap_get_track <class> <type> <in map> <out geodata>\n";
return 1;
}
std::string cl(argv[1]);
int type = atoi(argv[2]);
const char * ifile = argv[3];
const char * ofile = argv[4];
bool skip_names = true;
const char wpts_pref = '=';
if (cl == "POI"){ }
else if (cl == "POLYLINE") type |= zn::line_mask;
else if (cl == "POLYGON") type |= zn::area_mask;
else throw Err() << "unknown object class: " << cl;
vmap::world V = vmap::read(ifile);
geo_data data;
g_waypoint_list wpts;
for (auto const & o:V) {
if (o.type != type) continue;
if (o.size()<1) continue;
if (cl == "POI"){
for (auto const & l:o) {
for (auto const & p:l) {
g_waypoint pt;
pt.x = p.x;
pt.y = p.y;
if (wpts_pref!=0 && o.text != "") pt.name = wpts_pref + o.text;
- else pt.name = o.text
+ else pt.name = o.text;
wpts.push_back(pt);
}
}
}
else {
for (auto const & l:o) {
// skip tracks with names:
if (skip_names && o.text!="") continue;
g_track tr;
- tr.name = o.text;
+ tr.comm = o.text;
for (auto const & p:l) {
g_trackpoint pt;
pt.x = p.x;
pt.y = p.y;
tr.push_back(pt);
}
data.trks.push_back(tr);
}
}
}
if (wpts.size()) data.wpts.push_back(wpts);
io::out(ofile, data, Options());
}
catch (Err e) {
cerr << e.get_error() << endl;
return 1;
}
return 0;
}
diff --git a/vector/vmap3/vmap_put_track.cpp b/vector/vmap3/vmap_put_track.cpp
index 11c23d7..ce75c1b 100644
--- a/vector/vmap3/vmap_put_track.cpp
+++ b/vector/vmap3/vmap_put_track.cpp
@@ -1,109 +1,110 @@
#include <string>
#include <cstring>
#include "options/m_getopt.h"
#include "vmap/vmap.h"
#include "vmap/zn.h"
#include "fig/fig.h"
#include "geo_io/io.h"
using namespace std;
// replace objects of a single type
// in a map using geodata
int
main(int argc, char **argv){
try{
if (argc!=5) {
std::cerr << "usage: vmap_put_track <class> <type> <in geodata> <out map> \n";
return 1;
}
std::string cl(argv[1]);
int type = atoi(argv[2]);
const char * ifile = argv[3];
const char * ofile = argv[4];
bool skip_names = true;
const char wpts_pref = '=';
if (cl == "POI"){ }
else if (cl == "POLYLINE") type |= zn::line_mask;
else if (cl == "POLYGON") type |= zn::area_mask;
else throw Err() << "unknown object class: " << cl;
vmap::world V = vmap::read(ofile);
geo_data data;
io::in(ifile, data);
// put objects
if (cl == "POI"){
split_labels(V);
// remove old objects:
vmap::world::iterator i=V.begin();
while (i!=V.end()){
if (i->type != type) {i++; continue;}
i=V.erase(i);
}
for (auto const & pts:data.wpts) {
for (auto const & pt:pts) {
vmap::object o;
dLine l;
l.push_back(pt);
o.push_back(l);
if (wpts_pref != 0) {
- if (pt.name.size()>0 pt.name[0]==wpts_pref)
- o.text=pt.name.substr(1);
+ if (pt.name.size()>0 && pt.name[0]==wpts_pref)
+ o.text=pt.name.substr(1);
+ }
else
o.text=pt.name;
o.type=type;
V.push_back(o);
}
}
join_labels(V);
}
else {
// remove old objects:
vmap::world::iterator i=V.begin();
while (i!=V.end()){
if (i->type != type) {i++; continue;}
if (skip_names && i->text != "") {i++; continue;}
i=V.erase(i);
}
for (auto const & t:data.trks) {
vmap::object o;
if (!skip_names) o.text=t.comm;
o.type=type;
dLine l;
for (auto const & pt:t) {
if (pt.start && l.size()){
o.push_back(l);
V.push_back(o);
l.clear();
o.clear();
}
l.push_back(pt);
}
if (l.size()){
o.push_back(l);
V.push_back(o);
}
}
}
vmap::write(ofile, V);
}
catch (Err e) {
cerr << e.get_error() << endl;
return 1;
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.