|
29 | 29 | # ['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)
|
30 | 30 | # ['serialization_format'] - defaults to undef, otherwise it sets the preferred_serialization_format param (currently only msgpack is supported)
|
31 | 31 | # ['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 |
32 | 34 | #
|
33 | 35 | # Actions:
|
34 | 36 | # - Install and configures the puppet agent
|
|
44 | 46 | # }
|
45 | 47 | #
|
46 | 48 | 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, |
73 | 89 | ) inherits puppet::params {
|
74 | 90 |
|
75 | 91 | if ! defined(User[$::puppet::params::puppet_user]) {
|
|
127 | 143 | $service_ensure = 'stopped'
|
128 | 144 | $service_enable = false
|
129 | 145 |
|
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 | + } |
135 | 155 |
|
136 | 156 | cron { 'puppet-client':
|
137 | 157 | command => $puppet_run_command,
|
138 | 158 | 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, |
142 | 161 | }
|
143 | 162 | }
|
144 | 163 | # Run Puppet through external tooling, like MCollective
|
|
320 | 339 | if $serialization_format == 'msgpack' {
|
321 | 340 | unless defined(Package[$::puppet::params::ruby_dev]) {
|
322 | 341 | package {$::puppet::params::ruby_dev:
|
323 |
| - ensure => 'latest', |
| 342 | + ensure => 'latest', |
324 | 343 | }
|
325 | 344 | }
|
326 | 345 | unless defined(Package['gcc']) {
|
327 | 346 | package {'gcc':
|
328 |
| - ensure => 'latest', |
| 347 | + ensure => 'latest', |
329 | 348 | }
|
330 | 349 | }
|
331 | 350 | unless defined(Package['msgpack']) {
|
332 | 351 | 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'], |
336 | 355 | }
|
337 | 356 | }
|
338 | 357 | }
|
|
342 | 361 | value => $serialization_format,
|
343 | 362 | }
|
344 | 363 | }
|
| 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 | + } |
345 | 423 | }
|
0 commit comments