Skip to content

Commit f0250c8

Browse files
committed
Merge pull request #6 from benfairless/feature-nginx
My contribution so far, refactoring
2 parents b077c69 + d5e63e3 commit f0250c8

14 files changed

+243
-120
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: 117 additions & 39 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,46 @@
4446
# }
4547
#
4648
class puppet::agent(
47-
$puppet_server = $::puppet::params::puppet_server,
48-
$puppet_server_port = $::puppet::params::puppet_server_port,
49-
$puppet_agent_service = $::puppet::params::puppet_agent_service,
50-
$puppet_agent_package = $::puppet::params::puppet_agent_package,
51-
$version = 'present',
52-
$puppet_run_style = 'service',
53-
$puppet_run_interval = 30,
54-
$puppet_run_command = '/usr/bin/puppet agent --no-daemonize --onetime --logdest syslog > /dev/null 2>&1',
55-
$user_id = undef,
56-
$group_id = undef,
57-
$splay = false,
58-
$environment = 'production',
59-
$report = true,
60-
$pluginsync = true,
61-
$use_srv_records = false,
62-
$srv_domain = undef,
63-
$ordering = undef,
64-
$templatedir = undef,
65-
$trusted_node_data = undef,
66-
$listen = false,
67-
$reportserver = '$server',
68-
$digest_algorithm = $::puppet::params::digest_algorithm,
69-
$configtimeout = '2m',
70-
$stringify_facts = undef,
71-
$serialization_format = undef,
72-
$serialization_package = undef,
49+
$puppet_agent_service = $::puppet::params::puppet_agent_service,
50+
$puppet_agent_package = $::puppet::params::puppet_agent_package,
51+
$version = 'present',
52+
$puppet_run_style = 'service',
53+
$puppet_run_command = '/usr/bin/puppet agent --no-daemonize --onetime --logdest syslog > /dev/null 2>&1',
54+
$user_id = undef,
55+
$group_id = undef,
56+
$serialization_format = undef,
57+
$serialization_package = undef,
58+
59+
#[main]
60+
$templatedir = undef,
61+
$syslogfacility = undef,
62+
$priority = undef,
63+
64+
#[agent]
65+
$srv_domain = undef,
66+
$ordering = undef,
67+
$trusted_node_data = undef,
68+
$environment = 'production',
69+
$puppet_server = $::puppet::params::puppet_server,
70+
$use_srv_records = false,
71+
$puppet_run_interval = 30,
72+
$splay = false,
73+
$puppet_server_port = $::puppet::params::puppet_server_port,
74+
$report = true,
75+
$pluginsync = true,
76+
$listen = false,
77+
$reportserver = '$server',
78+
$digest_algorithm = $::puppet::params::digest_algorithm,
79+
$configtimeout = '2m',
80+
$stringify_facts = undef,
81+
$verbose = undef,
82+
$agent_noop = undef,
83+
$usecacheonfailure = undef,
84+
$certname = undef,
85+
$http_proxy_host = undef,
86+
$http_proxy_port = undef,
87+
$cron_hour = '*',
88+
$cron_minute = undef,
7389
) inherits puppet::params {
7490

7591
if ! defined(User[$::puppet::params::puppet_user]) {
@@ -127,18 +143,21 @@
127143
$service_ensure = 'stopped'
128144
$service_enable = false
129145

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
146+
# Default to every 30 minutes - random around the clock
147+
if $cron_minute == undef {
148+
$time1 = fqdn_rand(30)
149+
$time2 = $time1 + 30
150+
$minute = [ $time1, $time2 ]
151+
}
152+
else {
153+
$minute = $cron_minute
154+
}
135155

136156
cron { 'puppet-client':
137157
command => $puppet_run_command,
138158
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 ],
159+
hour => $cron_hour,
160+
minute => $minute,
142161
}
143162
}
144163
# Run Puppet through external tooling, like MCollective
@@ -320,19 +339,19 @@
320339
if $serialization_format == 'msgpack' {
321340
unless defined(Package[$::puppet::params::ruby_dev]) {
322341
package {$::puppet::params::ruby_dev:
323-
ensure => 'latest',
342+
ensure => 'latest',
324343
}
325344
}
326345
unless defined(Package['gcc']) {
327346
package {'gcc':
328-
ensure => 'latest',
347+
ensure => 'latest',
329348
}
330349
}
331350
unless defined(Package['msgpack']) {
332351
package {'msgpack':
333-
ensure => 'latest',
334-
provider => 'gem',
335-
require => Package[$::puppet::params::ruby_dev, 'gcc'],
352+
ensure => 'latest',
353+
provider => 'gem',
354+
require => Package[$::puppet::params::ruby_dev, 'gcc'],
336355
}
337356
}
338357
}
@@ -342,4 +361,63 @@
342361
value => $serialization_format,
343362
}
344363
}
364+
365+
if $verbose != undef {
366+
ini_setting {'puppetagentverbose':
367+
ensure => present,
368+
setting => 'verbose',
369+
value => $verbose,
370+
}
371+
}
372+
if $agent_noop != undef {
373+
ini_setting {'puppetagentnoop':
374+
ensure => present,
375+
setting => 'noop',
376+
value => $agent_noop,
377+
}
378+
}
379+
if $usecacheonfailure != undef {
380+
ini_setting {'puppetagentusecacheonfailure':
381+
ensure => present,
382+
setting => 'usecacheonfailure',
383+
value => $usecacheonfailure,
384+
}
385+
}
386+
if $syslogfacility != undef {
387+
ini_setting {'puppetagentsyslogfacility':
388+
ensure => present,
389+
setting => 'syslogfacility',
390+
value => $syslogfacility,
391+
section => 'main',
392+
}
393+
}
394+
if $certname != undef {
395+
ini_setting {'puppetagentcertname':
396+
ensure => present,
397+
setting => 'certname',
398+
value => $certname,
399+
}
400+
}
401+
if $priority != undef {
402+
ini_setting {'puppetagentpriority':
403+
ensure => present,
404+
setting => 'priority',
405+
value => $priority,
406+
section => 'main',
407+
}
408+
}
409+
if $http_proxy_host != undef {
410+
ini_setting {'puppetagenthttpproxyhost':
411+
ensure => present,
412+
setting => 'http_proxy_host',
413+
value => $http_proxy_host,
414+
}
415+
}
416+
if $http_proxy_port != undef {
417+
ini_setting {'puppetagenthttpproxyport':
418+
ensure => present,
419+
setting => 'http_proxy_port',
420+
value => $http_proxy_port,
421+
}
422+
}
345423
}

0 commit comments

Comments
 (0)