|
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 | 49 | $puppet_agent_service = $::puppet::params::puppet_agent_service,
|
50 | 50 | $puppet_agent_package = $::puppet::params::puppet_agent_package,
|
51 | 51 | $version = 'present',
|
52 | 52 | $puppet_run_style = 'service',
|
53 |
| - $puppet_run_interval = 30, |
54 | 53 | $puppet_run_command = '/usr/bin/puppet agent --no-daemonize --onetime --logdest syslog > /dev/null 2>&1',
|
55 | 54 | $user_id = undef,
|
56 | 55 | $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] |
62 | 63 | $srv_domain = undef,
|
63 | 64 | $ordering = undef,
|
64 |
| - $templatedir = undef, |
65 | 65 | $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, |
66 | 74 | $listen = false,
|
67 | 75 | $reportserver = '$server',
|
68 | 76 | $digest_algorithm = $::puppet::params::digest_algorithm,
|
69 | 77 | $configtimeout = '2m',
|
70 | 78 | $stringify_facts = undef,
|
71 |
| - $serialization_format = undef, |
72 |
| - $serialization_package = undef, |
73 | 79 | ) inherits puppet::params {
|
74 | 80 |
|
75 | 81 | if ! defined(User[$::puppet::params::puppet_user]) {
|
|
127 | 133 | $service_ensure = 'stopped'
|
128 | 134 | $service_enable = false
|
129 | 135 |
|
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 | + } |
135 | 145 |
|
136 | 146 | cron { 'puppet-client':
|
137 | 147 | command => $puppet_run_command,
|
138 | 148 | 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, |
142 | 151 | }
|
143 | 152 | }
|
144 | 153 | # Run Puppet through external tooling, like MCollective
|
|
340 | 349 | ini_setting {'puppetagentserializationformatagent':
|
341 | 350 | setting => 'preferred_serialization_format',
|
342 | 351 | 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, |
343 | 408 | }
|
344 | 409 | }
|
345 | 410 | }
|
0 commit comments