|
2 | 2 | # |
3 | 3 | # Manages puppet agent |
4 | 4 | # |
| 5 | +# @param agent_sysconfig_path |
| 6 | +# The absolute path to the puppet agent sysconfig file. |
| 7 | +# |
| 8 | +# @param ca_server |
| 9 | +# The name of the puppet CA server. |
| 10 | +# |
| 11 | +# @param certname |
| 12 | +# The certificate name for the client. |
| 13 | +# |
| 14 | +# @param config_path |
| 15 | +# The absolute path to the puppet config file. |
| 16 | +# |
| 17 | +# @param cron_command |
| 18 | +# Command that will be run from cron for the puppet agent. |
| 19 | +# |
| 20 | +# @param custom_settings |
| 21 | +# A hash that allows you to define and set any settings in puppet.conf. |
| 22 | +# For each setting use a nested hash and provide the section and the name |
| 23 | +# and value of the setting. |
| 24 | +# |
| 25 | +# Example: |
| 26 | +# ``` |
| 27 | +# $custom_settings = { |
| 28 | +# 'name' => { 'section' => 'master', 'setting' => 'codedir', 'value' => '/specific/path' }, |
| 29 | +# 'other' => { 'section' => 'agent', 'setting' => 'server', 'value' => 'specific.server.local' }, |
| 30 | +# } |
| 31 | +# ``` |
| 32 | +# |
| 33 | +# @param env |
| 34 | +# Value of environment option in puppet.conf which defaults to the |
| 35 | +# environment of the current puppet run. By setting this parameter, you |
| 36 | +# can specify an environment on the command line (`puppet agent -t |
| 37 | +# --environment foo`) and it will not trigger a change to the puppet.conf. |
| 38 | +# |
| 39 | +# @param graph |
| 40 | +# Value of the graph option in puppet.conf. |
| 41 | +# |
| 42 | +# @param run_at_boot |
| 43 | +# Determine if a cron job should present that will run the puppet agent at |
| 44 | +# boot time. |
| 45 | +# |
| 46 | +# @param run_every_thirty |
| 47 | +# Determines if a cron job to run the puppet agent every thirty minutes |
| 48 | +# should be present. |
| 49 | +# |
| 50 | +# @param run_in_noop |
| 51 | +# Determines if the puppet agent should run in noop mode. This is done by |
| 52 | +# appending '--noop' to the `cron_command` parameter. |
| 53 | +# |
| 54 | +# @param server |
| 55 | +# The name of the puppet server. |
| 56 | +# |
5 | 57 | class puppet ( |
6 | | - String $certname = $::fqdn, |
| 58 | + String $certname = $facts['networking']['fqdn'], |
7 | 59 | Variant[Enum['true', 'false'], Boolean] $run_every_thirty = true, #lint:ignore:quoted_booleans |
8 | 60 | Variant[Enum['true', 'false'], Boolean] $run_in_noop = true, #lint:ignore:quoted_booleans |
9 | | - String $cron_command = '/opt/puppetlabs/bin/puppet agent --onetime --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay', |
| 61 | + String $cron_command = '/opt/puppetlabs/bin/puppet agent --onetime --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay', #lint:ignore:140chars |
10 | 62 | Variant[Enum['true', 'false'], Boolean] $run_at_boot = true, #lint:ignore:quoted_booleans |
11 | 63 | String $config_path = '/etc/puppetlabs/puppet/puppet.conf', |
12 | 64 | String $server = 'puppet', |
|
16 | 68 | String $agent_sysconfig_path = '/etc/sysconfig/puppet', |
17 | 69 | Hash $custom_settings = {}, |
18 | 70 | ) { |
19 | | - |
20 | 71 | if $config_path != undef { |
21 | 72 | validate_absolute_path($config_path) |
22 | 73 | } |
|
46 | 97 | if $run_every_thirty_bool == true { |
47 | 98 | $cron_run_one = fqdn_rand(30) |
48 | 99 | $cron_run_two = fqdn_rand(30) + 30 |
49 | | - $cron_minute = [ $cron_run_one, $cron_run_two] |
| 100 | + $cron_minute = [$cron_run_one, $cron_run_two] |
50 | 101 | $cron_ensure = 'present' |
51 | 102 | } else { |
52 | 103 | $cron_ensure = 'absent' |
|
82 | 133 |
|
83 | 134 | $ini_defaults = { |
84 | 135 | ensure => 'present', |
85 | | - path => $::puppet::config_path, |
| 136 | + path => $puppet::config_path, |
86 | 137 | section => 'main', |
87 | 138 | require => File['puppet_config'], |
88 | 139 | } |
89 | 140 |
|
90 | 141 | $ini_settings = { |
91 | | - 'server' => { setting => 'server', value => $server,}, |
92 | | - 'ca_server' => { setting => 'ca_server', value => $ca_server,}, |
93 | | - 'certname' => { setting => 'certname', value => $certname,}, |
94 | | - 'environment' => { setting => 'environment', value => $env,}, |
95 | | - 'trusted_node_data' => { setting => 'trusted_node_data', value => true,}, |
96 | | - 'graph' => { setting => 'graph', value => $graph,}, |
| 142 | + 'server' => { setting => 'server', value => $server }, |
| 143 | + 'ca_server' => { setting => 'ca_server', value => $ca_server }, |
| 144 | + 'certname' => { setting => 'certname', value => $certname }, |
| 145 | + 'environment' => { setting => 'environment', value => $env }, |
| 146 | + 'trusted_node_data' => { setting => 'trusted_node_data', value => true }, |
| 147 | + 'graph' => { setting => 'graph', value => $graph }, |
97 | 148 | } |
98 | 149 | create_resources('ini_setting', $ini_settings, $ini_defaults) |
99 | 150 | create_resources('ini_setting', $custom_settings, $ini_defaults) |
|
0 commit comments