Skip to content

Commit 3e1c82a

Browse files
author
Phil Friderici
committed
Satisfy puppet-lint
1 parent dfdcb3d commit 3e1c82a

File tree

2 files changed

+95
-23
lines changed

2 files changed

+95
-23
lines changed

manifests/init.pp

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,63 @@
22
#
33
# Manages puppet agent
44
#
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+
#
557
class puppet (
6-
String $certname = $::fqdn,
58+
String $certname = $facts['networking']['fqdn'],
759
Variant[Enum['true', 'false'], Boolean] $run_every_thirty = true, #lint:ignore:quoted_booleans
860
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
1062
Variant[Enum['true', 'false'], Boolean] $run_at_boot = true, #lint:ignore:quoted_booleans
1163
String $config_path = '/etc/puppetlabs/puppet/puppet.conf',
1264
String $server = 'puppet',
@@ -16,7 +68,6 @@
1668
String $agent_sysconfig_path = '/etc/sysconfig/puppet',
1769
Hash $custom_settings = {},
1870
) {
19-
2071
if $config_path != undef {
2172
validate_absolute_path($config_path)
2273
}
@@ -46,7 +97,7 @@
4697
if $run_every_thirty_bool == true {
4798
$cron_run_one = fqdn_rand(30)
4899
$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]
50101
$cron_ensure = 'present'
51102
} else {
52103
$cron_ensure = 'absent'
@@ -82,18 +133,18 @@
82133

83134
$ini_defaults = {
84135
ensure => 'present',
85-
path => $::puppet::config_path,
136+
path => $puppet::config_path,
86137
section => 'main',
87138
require => File['puppet_config'],
88139
}
89140

90141
$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 },
97148
}
98149
create_resources('ini_setting', $ini_settings, $ini_defaults)
99150
create_resources('ini_setting', $custom_settings, $ini_defaults)

manifests/server.pp

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,60 @@
22
#
33
# Manages puppetserver
44
#
5-
class puppet::server(
5+
# @param autosign_entries
6+
# Optional array of entries that will be autosigned.
7+
#
8+
# @param ca
9+
# Determines if the system is a puppet CA (certificate authority).
10+
# There should be only one CA per cluster of puppet masters.
11+
#
12+
# @param dns_alt_names
13+
# Value of the dns_alt_names option in puppet.conf.
14+
#
15+
# @param enc
16+
# The absolute path to an ENC. If this is set, it will be the value
17+
# for the external_nodes option in puppet.conf and the node_terminus
18+
# option will be set to 'exec'.
19+
#
20+
# @param memory_size
21+
# The amount of memory allocated to the puppetserver. This is passed
22+
# to the Xms and Xmx arguments for java. It must be a whole number
23+
# followed by the unit 'm' for MB or 'g' for GB.
24+
#
25+
# @param sysconfig_path
26+
# The absolute path to the puppetserver sysconfig file.
27+
#
28+
class puppet::server (
629
Variant[Enum['true', 'false'], Boolean] $ca = false, #lint:ignore:quoted_booleans
730
Variant[Array[String, 1], Undef] $autosign_entries = undef,
831
String $sysconfig_path = '/etc/sysconfig/puppetserver',
932
String $memory_size = '2g', # only m and g are appropriate for unit
1033
Optional[String] $enc = undef,
1134
Optional[String] $dns_alt_names = undef,
1235
) {
13-
14-
include ::puppet
36+
include puppet
1537

1638
if $sysconfig_path != undef {
1739
validate_absolute_path($sysconfig_path)
1840
}
1941

20-
validate_re($memory_size, '^\d+(m|g)$',
21-
"puppet::memory_size is <${memory_size}> and must be an integer following by the unit 'm' or 'g'.")
42+
validate_re($memory_size, '^\d+(m|g)$', "puppet::memory_size is <${memory_size}> and must be an integer following by the unit 'm' or 'g'.") #lint:ignore:140chars
2243

2344
$ini_defaults = {
2445
ensure => 'present',
25-
path => $::puppet::config_path,
46+
path => $puppet::config_path,
2647
section => 'master',
2748
require => File['puppet_config'],
2849
notify => Service['puppetserver'],
2950
}
3051

3152
$non_conditional_ini_settings = {
32-
'vardir' => { setting => 'vardir', value => '/opt/puppetlabs/server/data/puppetserver',},
33-
'logdir' => { setting => 'logdir', value => '/var/log/puppetlabs/puppetserver',},
34-
'rundir' => { setting => 'rundir', value => '/var/run/puppetlabs/puppetserver',},
35-
'pidfile' => { setting => 'pidfile', value => '/var/run/puppetlabs/puppetserver/puppetserver.pid',},
36-
'codedir' => { setting => 'codedir', value =>'/etc/puppetlabs/code',},
37-
'ca' => { setting => 'ca', value => $ca,},
53+
'vardir' => { setting => 'vardir', value => '/opt/puppetlabs/server/data/puppetserver' },
54+
'logdir' => { setting => 'logdir', value => '/var/log/puppetlabs/puppetserver' },
55+
'rundir' => { setting => 'rundir', value => '/var/run/puppetlabs/puppetserver' },
56+
'pidfile' => { setting => 'pidfile', value => '/var/run/puppetlabs/puppetserver/puppetserver.pid' },
57+
'codedir' => { setting => 'codedir', value => '/etc/puppetlabs/code' },
58+
'ca' => { setting => 'ca', value => $ca },
3859
}
3960

4061
if $enc != undef {

0 commit comments

Comments
 (0)