summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README12
-rw-r--r--files/master/puppetlast12
-rw-r--r--manifests/puppetmaster.pp12
-rw-r--r--manifests/puppetmaster/checklastrun.pp2
-rw-r--r--manifests/puppetmaster/checklastrun/disable.pp9
5 files changed, 44 insertions, 3 deletions
diff --git a/README b/README
index 72d5d6e..c8e4a9b 100644
--- a/README
+++ b/README
@@ -41,6 +41,18 @@ values:
* 'X', where X is the amount of days you want to keep reports for
* false, to disable reports cleanup
+Check last run:
+---------------
+
+We can check on the last run state of certain clients, to check whether
+they still check in. You can do that by setting the following variables:
+
+$puppetmaster_checklastrun
+
+* any cron time: '20 10,22 * * *' to run the script at a certain time
+ by cron. Default: 40 10,22 * * *
+* false: to disable check for last run
+
Example:
--------
diff --git a/files/master/puppetlast b/files/master/puppetlast
index 752d6ca..0f6c0cc 100644
--- a/files/master/puppetlast
+++ b/files/master/puppetlast
@@ -12,6 +12,16 @@ Puppet.parse_config
Puppet[:name] = "puppetmasterd"
Puppet::Node::Facts.terminus_class = :yaml
+all = false
+timeout = 120
+ARGV.each do |arg|
+ if arg.to_s == '--all'
+ all = true
+ else
+ timeout = arg.to_i
+ end
+end
+
Puppet::Node::Facts.search("*").sort { |a,b| a.name <=> b.name }.each do |node|
- puts "#{node.name} #{node.expired? ? 'cached expired, ' : ''}last checked #{((Time.now - Time.parse(node.values[:_timestamp])) / 60).floor} minutes ago" if (((Time.now - Time.parse(node.values[:_timestamp])) / 60).floor > 120 or (not ARGV[0].nil? and ARGV[0].to_s == '--all'))
+ puts "#{node.name} #{node.expired? ? 'cached expired, ' : ''}last checked #{((Time.now - Time.parse(node.values[:_timestamp])) / 60).floor} minutes ago" if (((Time.now - Time.parse(node.values[:_timestamp])) / 60).floor > timeout or all)
end
diff --git a/manifests/puppetmaster.pp b/manifests/puppetmaster.pp
index a6d5d77..71cab3a 100644
--- a/manifests/puppetmaster.pp
+++ b/manifests/puppetmaster.pp
@@ -11,7 +11,17 @@ class puppet::puppetmaster inherits puppet {
}
include puppet::puppetmaster::base
- include puppet::puppetmaster::checklastrun
+
+
+ case $puppetmaster_checklastrun {
+ '': { $puppetmaster_checklastrun = '40 10,22 * * *'
+ }
+
+ if $puppetmaster_checklastrun {
+ include puppet::puppetmaster::checklastrun
+ } else {
+ include puppet::puppetmaster::checklastrun::disable
+ }
if $puppetmaster_mode == 'passenger' {
include puppet::puppetmaster::pasenger
diff --git a/manifests/puppetmaster/checklastrun.pp b/manifests/puppetmaster/checklastrun.pp
index 96d59d5..a8978f3 100644
--- a/manifests/puppetmaster/checklastrun.pp
+++ b/manifests/puppetmaster/checklastrun.pp
@@ -5,7 +5,7 @@ class puppet::puppetmaster::checklastrun {
owner => root, group => 0, mode => 0700;
}
file{'/etc/cron.d/puppetlast.cron':
- content => "40 10,22 * * * root /usr/local/bin/puppetlast\n",
+ content => "${puppetmaster_checklastrun} root /usr/local/bin/puppetlast ${puppetmaster_checklastrun_timeout}\n",
require => File["/usr/local/bin/puppetlast"],
owner => root, group => 0, mode => 0644,
}
diff --git a/manifests/puppetmaster/checklastrun/disable.pp b/manifests/puppetmaster/checklastrun/disable.pp
new file mode 100644
index 0000000..47c0130
--- /dev/null
+++ b/manifests/puppetmaster/checklastrun/disable.pp
@@ -0,0 +1,9 @@
+class puppet::puppetmaster::checklastrun::disable inherits puppet::puppetmaster::checklastrun {
+ File['/usr/local/bin/puppetlast']{
+ ensure => absent,
+ }
+ File['/etc/cron.d/puppetlast.cron']{
+ ensure => absent,
+ }
+}
+