Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for using a custom puppet agent via cron #103

Open
wants to merge 1 commit into
base: production
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ The `puppet` class is responsible for validating some of our parameters, and ins

This param accepts any value accepted by the [cron native type](http://docs.puppetlabs.com/references/latest/type.html#cron-attribute-minute), as well as two special options: `two_times_an_hour`, and `four_times_an_hour`. These specials use [fqdn_rand](http://docs.puppetlabs.com/references/latest/function.html#fqdnrand) to generate a random minute array on the selected interval. This should distribute the load more evenly on your puppetmasters.

* **agent_custom_cron_command**: (*string* Default: `undef`)

Optional custom puppet agent cron command

* **agent_version**: (*string* Default: `installed`)

Declares the version of the puppet-agent all-in-one package to install.
Expand Down
8 changes: 7 additions & 1 deletion manifests/agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
$cron_enablement = 'present'
$service_enablement = false
$start_enablement = 'no'
if $::puppet::agent_custom_cron_command {
$cron_command = $::puppet::agent_custom_cron_command
}
else {
$cron_command = "${bin_dir}/puppet agent --no-daemonize --onetime"
}
}
default: {
#noop. should never happen.
Expand All @@ -40,7 +46,7 @@

cron {'run_puppet_agent':
ensure => $cron_enablement,
command => "${bin_dir}/puppet agent --no-daemonize --onetime",
command => $cron_command,
special => 'absent',
minute => $::puppet::agent_cron_min_interpolated,
hour => $::puppet::agent_cron_hour_interpolated,
Expand Down
21 changes: 12 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# The main puppet class is responsible for validating some of our parameters,
# The main puppet class is responsible for validating some of our parameters,
# and instantiating the puppet::facts, puppet::repo, pupppet::install,
# puppet::config and puppet::agent classes.
#
# @puppet when declaring the puppet class
# include puppet
#
# @param allinone [Boolean] Default: false
# @param allinone [Boolean] Default: false
# Whether to use the new collections
# @param agent_cron_hour [String] Default: '*'
# @param agent_cron_hour [String] Default: '*'
# The hour to run the agent cron. Valid values are `0-23`
# @param agent_cron_min [String/Array] Default: 'two_times_an_hour'
# This param accepts any value accepted by the [cron native type](http://docs.puppetlabs.com/references/latest/type.html#cron-attribute-minute),
# as well as two special options: `two_times_an_hour`, and `four_times_an_hour`.
# as well as two special options: `two_times_an_hour`, and `four_times_an_hour`.
# These specials use [fqdn_rand](http://docs.puppetlabs.com/references/latest/function.html#fqdnrand)
# to generate a random minute array on the selected interval.
# to generate a random minute array on the selected interval.
# This should distribute the load more evenly on your puppetmasters.
# @param agent_custom_cron_command [String] Default: undef
# Custom puppet agent cron command
# @param agent_version [String] Default: 'installed'
# Declares the version of the puppet-agent all-in-one package to install.
# @param ca_server [String] Default: undef
Expand All @@ -32,7 +34,7 @@
# @param enable_devel_repo [Boolean] Default: false
# This param will replace `devel_repo` in 2.x.
# It conveys to puppet::repo::apt whether or not to add the devel apt repo source.
# When `devel_repo` is false, `enable_devel_repo` is consulted for enablement.
# When `devel_repo` is false, `enable_devel_repo` is consulted for enablement.
# This gives `devel_repo` backwards compatability at the cost of some confusion if you set `devel_repo` to true, and `enable_devel_repo` to false.
# @param enable_mechanism [String] Default: 'service'
# A toggle which permits the option of running puppet as a service, or as a cron job.
Expand Down Expand Up @@ -67,17 +69,18 @@
# @param runinterval [String] Default: '30m'
# Sets the runinterval in puppet.conf
# @param structured_facts [Boolean] Default: false
# Sets whether or not to enable [structured_facts](http://docs.puppetlabs.com/facter/2.0/fact_overview.html)
# by setting the [stringify_facts](http://docs.puppetlabs.com/references/3.6.latest/configuration.html#stringifyfacts)
# Sets whether or not to enable [structured_facts](http://docs.puppetlabs.com/facter/2.0/fact_overview.html)
# by setting the [stringify_facts](http://docs.puppetlabs.com/references/3.6.latest/configuration.html#stringifyfacts)
# variable in puppet.conf.
# **It is important to note that this boolean operates in reverse.
# ** Setting stringify_facts to **false** is required to **permit** structured facts.
# ** Setting stringify_facts to **false** is required to **permit** structured facts.
# This is why this parameter does not directly correlate with the configuration key.

class puppet (
$allinone = false,
$agent_cron_hour = '*',
$agent_cron_min = 'two_times_an_hour',
$agent_custom_cron_command = undef,
$agent_version = 'installed',
$ca_server = undef,
$cfacter = false,
Expand Down
20 changes: 12 additions & 8 deletions manifests/profile/agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
# @puppet::profile::agent when declaring the puppet::profile::agent class
# include puppet::profile::agent
#
# @param allinone [Boolean] Default: false
# @param allinone [Boolean] Default: false
# Whether to use the new collections
# @param agent_cron_hour [String] Default: '*'
# @param agent_cron_hour [String] Default: '*'
# The hour to run the agent cron. Valid values are `0-23`
# @param agent_cron_min [String/Array] Default: 'two_times_an_hour'
# This param accepts any value accepted by the [cron native type](http://docs.puppetlabs.com/references/latest/type.html#cron-attribute-minute),
# as well as two special options: `two_times_an_hour`, and `four_times_an_hour`.
# as well as two special options: `two_times_an_hour`, and `four_times_an_hour`.
# These specials use [fqdn_rand](http://docs.puppetlabs.com/references/latest/function.html#fqdnrand)
# to generate a random minute array on the selected interval.
# to generate a random minute array on the selected interval.
# This should distribute the load more evenly on your puppetmasters.
# @param agent_custom_cron_command [String] Default: undef
# Custom puppet agent cron command
# @param ca_server [String] Default: undef
# Server to use as the CA server for all agents.
# @param agent_version [String] Default: 'installed'
Expand All @@ -28,7 +30,7 @@
# @param enable_devel_repo [Boolean] Default: false
# This param will replace `devel_repo` in 2.x.
# It conveys to puppet::repo::apt whether or not to add the devel apt repo source.
# When `devel_repo` is false, `enable_devel_repo` is consulted for enablement.
# When `devel_repo` is false, `enable_devel_repo` is consulted for enablement.
# This gives `devel_repo` backwards compatability at the cost of some confusion if you set `devel_repo` to true, and `enable_devel_repo` to false.
# @param enable_mechanism [String] Default: 'service'
# A toggle which permits the option of running puppet as a service, or as a cron job.
Expand Down Expand Up @@ -63,18 +65,19 @@
# @param runinterval [String] Default: '30m'
# Sets the runinterval in puppet.conf
# @param structured_facts [Boolean] Default: false
# Sets whether or not to enable [structured_facts](http://docs.puppetlabs.com/facter/2.0/fact_overview.html)
# by setting the [stringify_facts](http://docs.puppetlabs.com/references/3.6.latest/configuration.html#stringifyfacts)
# Sets whether or not to enable [structured_facts](http://docs.puppetlabs.com/facter/2.0/fact_overview.html)
# by setting the [stringify_facts](http://docs.puppetlabs.com/references/3.6.latest/configuration.html#stringifyfacts)
# variable in puppet.conf.
# **It is important to note that this boolean operates in reverse.
# ** Setting stringify_facts to **false** is required to **permit** structured facts.
# ** Setting stringify_facts to **false** is required to **permit** structured facts.
# This is why this parameter does not directly correlate with the configuration key.


class puppet::profile::agent (
$allinone = false,
$agent_cron_hour = '*',
$agent_cron_min = 'two_times_an_hour',
$agent_custom_cron_command = undef,
$agent_version = 'installed',
$ca_server = undef,
$cfacter = false,
Expand Down Expand Up @@ -103,6 +106,7 @@
allinone => $allinone,
agent_cron_hour => $agent_cron_hour,
agent_cron_min => $agent_cron_min,
agent_custom_cron_command => $agent_custom_cron_command,
agent_version => $agent_version,
ca_server => $ca_server,
cfacter => $cfacter,
Expand Down