Skip to content

Commit bb78635

Browse files
author
Ben Fairless
committed
Merge branch 'master' of github.com:stephenrjohnson/puppetmodule into feature-nginx
Conflicts: manifests/agent.pp manifests/master.pp
2 parents b077c69 + 9f61425 commit bb78635

File tree

10 files changed

+154
-41
lines changed

10 files changed

+154
-41
lines changed

.fixtures.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ fixtures:
77
puppetdb: "git://github.com/puppetlabs/puppetlabs-puppetdb.git"
88
inifile: "git://github.com/puppetlabs/puppetlabs-inifile.git"
99
concat: "git://github.com/ripienaar/puppet-concat.git"
10+
'file_concat':
11+
repo: 'git://github.com/electrical/puppet-lib-file_concat.git'
12+
ref: '1.0.1'
1013
apt: "git://github.com/puppetlabs/puppetlabs-apt.git"
1114
symlinks:
1215
puppet: "#{source_dir}"

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# A sample Gemfile
22
source "https://rubygems.org"
33

4-
gem 'puppet'
4+
gem 'puppet', '< 4.0.0'
55

66
gem 'rake'
7-
gem 'rspec', '< 3.0.0'
7+
gem 'rspec'
88
gem 'puppet-lint'
99
gem 'beaker'
1010
gem 'beaker-rspec'

README.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ If you have a working Vagrant setup you can run the rspec-system tests:
8888
bundle exec rake beaker
8989

9090
To use different base boxes than the default pass the name of the box to
91-
the rake command with the ```RSPEC_SET``` environment variable (check out
91+
the rake command with the ```BEAKER_set``` environment variable (check out
9292
.nodelist.yml for box names):
9393

9494
BEAKER_set=ubuntu-server-1404-x64 bundle exec rake beaker

manifests/agent.pp

Lines changed: 84 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
# ['stringify_facts'] - Wether puppet transforms structured facts in strings or no. Defaults to true in puppet < 4, deprecated in puppet >=4 (and will default to false)
3030
# ['serialization_format'] - defaults to undef, otherwise it sets the preferred_serialization_format param (currently only msgpack is supported)
3131
# ['serialization_package'] - defaults to undef, if provided, we install this package, otherwise we fall back to the gem from 'serialization_format'
32+
# ['cron_hour'] - What hour to run if puppet_run_style is cron
33+
# ['cron_minute'] - What minute to run if puppet_run_style is cron
3234
#
3335
# Actions:
3436
# - Install and configures the puppet agent
@@ -44,32 +46,36 @@
4446
# }
4547
#
4648
class puppet::agent(
47-
$puppet_server = $::puppet::params::puppet_server,
48-
$puppet_server_port = $::puppet::params::puppet_server_port,
4949
$puppet_agent_service = $::puppet::params::puppet_agent_service,
5050
$puppet_agent_package = $::puppet::params::puppet_agent_package,
5151
$version = 'present',
5252
$puppet_run_style = 'service',
53-
$puppet_run_interval = 30,
5453
$puppet_run_command = '/usr/bin/puppet agent --no-daemonize --onetime --logdest syslog > /dev/null 2>&1',
5554
$user_id = undef,
5655
$group_id = undef,
57-
$splay = false,
58-
$environment = 'production',
59-
$report = true,
60-
$pluginsync = true,
61-
$use_srv_records = false,
56+
57+
#[main]
58+
$templatedir = undef,
59+
$syslogfacility = undef,
60+
$priority = undef,
61+
62+
#[agent]
6263
$srv_domain = undef,
6364
$ordering = undef,
64-
$templatedir = undef,
6565
$trusted_node_data = undef,
66+
$environment = 'production',
67+
$puppet_server = $::puppet::params::puppet_server,
68+
$use_srv_records = false,
69+
$puppet_run_interval = 30,
70+
$splay = false,
71+
$puppet_server_port = $::puppet::params::puppet_server_port,
72+
$report = true,
73+
$pluginsync = true,
6674
$listen = false,
6775
$reportserver = '$server',
6876
$digest_algorithm = $::puppet::params::digest_algorithm,
6977
$configtimeout = '2m',
7078
$stringify_facts = undef,
71-
$serialization_format = undef,
72-
$serialization_package = undef,
7379
) inherits puppet::params {
7480

7581
if ! defined(User[$::puppet::params::puppet_user]) {
@@ -127,18 +133,21 @@
127133
$service_ensure = 'stopped'
128134
$service_enable = false
129135

130-
# Run puppet as a cron - this saves memory and avoids the whole problem
131-
# where puppet locks up for no reason. Also spreads out the run intervals
132-
# more uniformly.
133-
$time1 = fqdn_rand($puppet_run_interval)
134-
$time2 = fqdn_rand($puppet_run_interval) + 30
136+
# Default to every 30 minutes - random around the clock
137+
if $cron_minute == undef {
138+
$time1 = fqdn_rand(30)
139+
$time2 = $time1 + 30
140+
$minute = [ $time1, $time2 ]
141+
}
142+
else {
143+
$minute = $cron_minute
144+
}
135145

136146
cron { 'puppet-client':
137147
command => $puppet_run_command,
138148
user => 'root',
139-
# run twice an hour, at a random minute in order not to collectively stress the puppetmaster
140-
hour => '*',
141-
minute => [ $time1, $time2 ],
149+
hour => $cron_hour,
150+
minute => $minute,
142151
}
143152
}
144153
# Run Puppet through external tooling, like MCollective
@@ -340,6 +349,62 @@
340349
ini_setting {'puppetagentserializationformatagent':
341350
setting => 'preferred_serialization_format',
342351
value => $serialization_format,
352+
if $verbose != undef {
353+
ini_setting {'puppetagentverbose':
354+
ensure => present,
355+
setting => 'verbose',
356+
value => $verbose,
357+
}
358+
}
359+
if $agent_noop != undef {
360+
ini_setting {'puppetagentnoop':
361+
ensure => present,
362+
setting => 'noop',
363+
value => $agent_noop,
364+
}
365+
}
366+
if $usecacheonfailure != undef {
367+
ini_setting {'puppetagentusecacheonfailure':
368+
ensure => present,
369+
setting => 'usecacheonfailure',
370+
value => $usecacheonfailure,
371+
}
372+
}
373+
if $syslogfacility != undef {
374+
ini_setting {'puppetagentsyslogfacility':
375+
ensure => present,
376+
setting => 'syslogfacility',
377+
value => $syslogfacility,
378+
section => 'main',
379+
}
380+
}
381+
if $certname != undef {
382+
ini_setting {'puppetagentcertname':
383+
ensure => present,
384+
setting => 'certname',
385+
value => $certname,
386+
}
387+
}
388+
if $priority != undef {
389+
ini_setting {'puppetagentpriority':
390+
ensure => present,
391+
setting => 'priority',
392+
value => $priority,
393+
section => 'main',
394+
}
395+
}
396+
if $http_proxy_host != undef {
397+
ini_setting {'puppetagenthttpproxyhost':
398+
ensure => present,
399+
setting => 'http_proxy_host',
400+
value => $http_proxy_host,
401+
}
402+
}
403+
if $http_proxy_port != undef {
404+
ini_setting {'puppetagenthttpproxyport':
405+
ensure => present,
406+
setting => 'http_proxy_port',
407+
value => $http_proxy_port,
343408
}
344409
}
345410
}

manifests/master.pp

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# This class installs and configures a Puppet master
44
#
5+
<<<<<<< HEAD
56
# Parameters:
67
# ['user_id'] - The userid of the puppet user
78
# ['group_id'] - The groupid of the puppet group
@@ -43,6 +44,10 @@
4344
# ['upstream'] - define additional masters reachable via tcp as an array, currently only supported by nginx
4445
# ['backend_process_number'] - number of processes to start on the backebd webserver (unicorn/passenger), currently only supported by unicorn
4546
# ['serialization_format'] - defaults to undef, otherwise it sets the preferred_serialization_format param (currently only msgpack is supported)
47+
# ['strict_variables'] - Makes the parser raise errors when referencing unknown variables
48+
# ['always_cache_features'] - if false (default), always try to load a feature even if a previous load failed
49+
50+
>>>>>>> 9f614250618d124231791e9dbee41ecca22581e7
4651
#
4752
# Requires:
4853
#
@@ -85,6 +90,7 @@
8590
$puppet_vardir = $::puppet::params::puppet_vardir,
8691
$puppet_proxy_port = $::puppet::params::puppet_proxy_port,
8792
$puppet_passenger_tempdir = false,
93+
$puppet_passenger_cfg_addon = '',
8894
$puppet_master_package = $::puppet::params::puppet_master_package,
8995
$puppet_master_service = $::puppet::params::puppet_master_service,
9096
$version = 'present',
@@ -102,11 +108,13 @@
102108
$unicorn_path = $::puppet::params::unicorn_path,
103109
$unicorn_package = $::puppet::params::unicorn_package,
104110
$generate_ssl_certs = true,
111+
$strict_variables = undef,
105112
$puppetdb_version = 'present',
106113
$disable_master = $::puppet::params::disable_master,
107114
$upstream = $::puppet::params::upstream,
108115
$backend_process_number = $::puppet::params::backend_process_number,
109116
$serialization_format = undef,
117+
$always_cache_features = false,
110118
) inherits puppet::params {
111119

112120
anchor { 'puppet::master::begin': }
@@ -175,11 +183,12 @@
175183
dns_alt_names => join($dns_alt_names,','),
176184
generate_ssl_certs => $generate_ssl_certs,
177185
puppet_passenger_tempdir => $puppet_passenger_tempdir,
186+
config_addon => $puppet_passenger_cfg_addon,
178187
} ->
179188
Anchor['puppet::master::end']
180189
}
181-
182190
}
191+
183192
service { $puppet_master_service:
184193
ensure => stopped,
185194
enable => false,
@@ -345,16 +354,26 @@
345354
}
346355

347356
ini_setting {'puppetmasterdnsaltnames':
348-
ensure => present,
349-
setting => 'dns_alt_names',
350-
value => join($dns_alt_names, ','),
357+
ensure => present,
358+
setting => 'dns_alt_names',
359+
value => join($dns_alt_names, ','),
351360
}
352361

353362
ini_setting {'puppetmasterdigestalgorithm':
363+
ensure => present,
364+
setting => 'digest_algorithm',
365+
value => $digest_algorithm,
366+
}
367+
368+
if $strict_variables != undef {
369+
validate_bool(str2bool($strict_variables))
370+
ini_setting {'puppetmasterstrictvariables':
354371
ensure => present,
355-
setting => 'digest_algorithm',
356-
value => $digest_algorithm,
372+
setting => 'strict_variables',
373+
value => $strict_variables,
374+
}
357375
}
376+
358377
if $serialization_format != undef {
359378
if $serialization_package != undef {
360379
package { $serialization_package:
@@ -385,6 +404,13 @@
385404
setting => 'preferred_serialization_format',
386405
value => $serialization_format,
387406
}
407+
408+
validate_bool(str2bool($always_cache_features))
409+
ini_setting { 'puppetmasteralwayscachefeatures':
410+
ensure => present,
411+
setting => 'always_cache_features',
412+
value => $always_cache_features,
413+
388414
}
389415
anchor { 'puppet::master::end': }
390416
}

manifests/passenger.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
$puppet_ssldir,
4242
$certname,
4343
$conf_dir,
44-
$dns_alt_names
44+
$dns_alt_names,
45+
$config_addon = ''
4546
){
4647
include apache
4748
include puppet::params

spec/classes/puppet_agent_spec.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@
5050
:puppet_run_style => 'cron',
5151
:splay => 'true',
5252
:environment => 'production',
53-
:puppet_run_interval => 30,
5453
:puppet_server_port => 8140,
54+
:cron_hour => 5,
55+
:cron_minute => '*/30',
5556
}
5657
end
5758
it{
@@ -69,8 +70,9 @@
6970
)
7071
should contain_cron('puppet-client').with(
7172
:command => '/usr/bin/puppet agent --no-daemonize --onetime --logdest syslog > /dev/null 2>&1',
72-
:user => 'root',
73-
:hour => '*'
73+
:user => 'root',
74+
:hour => '5',
75+
:minute => '*/30'
7476
)
7577
}
7678
end
@@ -93,8 +95,8 @@
9395
}
9496
end
9597

96-
it{
97-
expect{ subject }.to raise_error()
98+
it {
99+
should compile.and_raise_error(/puppet has attribute use_srv_records set but has srv_domain unset/)
98100
}
99101
end
100102

@@ -252,8 +254,8 @@
252254
}
253255
end
254256

255-
it{
256-
expect{ subject }.to raise_error()
257+
it {
258+
should compile.and_raise_error(/puppet has attribute use_srv_records set but has srv_domain unset/)
257259
}
258260
end
259261

spec/classes/puppet_master_spec.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
:certname => 'test.example.com',
2525
:storeconfigs => 'true',
2626
:storeconfigs_dbserver => 'test.example.com',
27-
:dns_alt_names => ['puppet']
27+
:dns_alt_names => ['puppet'],
28+
:strict_variables => 'true'
2829

2930
}
3031
end
@@ -156,6 +157,13 @@
156157
:path => '/etc/puppet/puppet.conf',
157158
:value => params[:dns_alt_names].join(',')
158159
)
160+
should contain_ini_setting('puppetmasterstrictvariables').with(
161+
:ensure => 'present',
162+
:section => 'master',
163+
:setting => 'strict_variables',
164+
:path => '/etc/puppet/puppet.conf',
165+
:value => params[:strict_variables]
166+
)
159167
should contain_anchor('puppet::master::begin').with_before(
160168
['Class[Puppet::Passenger]', 'Class[Puppet::Storeconfigs]']
161169
)
@@ -185,7 +193,8 @@
185193
:certname => 'test.example.com',
186194
:storeconfigs => 'true',
187195
:storeconfigs_dbserver => 'test.example.com',
188-
:dns_alt_names => ['puppet']
196+
:dns_alt_names => ['puppet'],
197+
:strict_variables => 'true'
189198

190199
}
191200
end
@@ -315,6 +324,13 @@
315324
:path => '/etc/puppet/puppet.conf',
316325
:value => params[:dns_alt_names].join(',')
317326
)
327+
should contain_ini_setting('puppetmasterstrictvariables').with(
328+
:ensure => 'present',
329+
:section => 'master',
330+
:setting => 'strict_variables',
331+
:path => '/etc/puppet/puppet.conf',
332+
:value => params[:strict_variables]
333+
)
318334
should contain_anchor('puppet::master::begin').with_before(
319335
['Class[Puppet::Passenger]', 'Class[Puppet::Storeconfigs]']
320336
)

spec/classes/puppet_repo_puppetlabs_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@
7575
end
7676
it 'should fail for unsupported os families' do
7777
expect do
78-
subject
79-
end.to raise_error(Puppet::Error, /Unsupported osfamily FreeBSD/)
78+
should compile.and_raise_error(/Unsupported osfamily FreeBSD/)
79+
end
8080
end
8181
end
8282
end

0 commit comments

Comments
 (0)