From 2859008efe8f0a75344c7ba1c9c6e4d589f92da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 26 Mar 2018 00:41:55 +0200 Subject: Use external module for cronjobs --- modules/base_installation/manifests/cleanup.pp | 20 ++++++++++ modules/base_installation/manifests/cronie.pp | 54 +++++++++++++++----------- modules/base_installation/manifests/init.pp | 1 + 3 files changed, 52 insertions(+), 23 deletions(-) create mode 100644 modules/base_installation/manifests/cleanup.pp (limited to 'modules/base_installation') diff --git a/modules/base_installation/manifests/cleanup.pp b/modules/base_installation/manifests/cleanup.pp new file mode 100644 index 0000000..96aaa6b --- /dev/null +++ b/modules/base_installation/manifests/cleanup.pp @@ -0,0 +1,20 @@ +class base_installation::cleanup inherits base_installation { + # This class contains temporary classes used to cleanup old stuff + # after refactoring + + cron { "puppet-pull-apply": + ensure => absent; + "puppet-apply": + ensure => absent; + "puppet-apply-reboot": + ensure => absent; + "pacman_keys": + ensure => absent; + "backup": + ensure => absent; + "py-cryptoportfolio-before": + ensure => absent; + "py-cryptoportfolio-after": + ensure => absent; + } +} diff --git a/modules/base_installation/manifests/cronie.pp b/modules/base_installation/manifests/cronie.pp index 2235470..3558d9f 100644 --- a/modules/base_installation/manifests/cronie.pp +++ b/modules/base_installation/manifests/cronie.pp @@ -10,31 +10,39 @@ class base_installation::cronie inherits base_installation { owner => root, group => root, } - cron { 'puppet-pull-apply': - ensure => present, - command => "cd $base_installation::puppet_code_path ; /usr/bin/git pull", - user => root, - minute => '*/30', - require => File['post-hook'], + cron::job { 'puppet-pull-apply': + ensure => present, + command => "cd $base_installation::puppet_code_path ; /usr/bin/git pull", + user => root, + minute => '15,45', + require => File['post-hook'], + description => "Pull git and apply puppet changes", } - cron { 'puppet-apply': - ensure => present, - command => "cd $base_installation::puppet_code_path ; /usr/local/sbin/puppet_apply $base_installation::puppet_code_path/manifests/site.pp", - user => root, - minute => '*/20' + cron::job::multiple { 'puppet-apply': + ensure => present, + jobs => [ + { + command => "cd $base_installation::puppet_code_path ; /usr/local/sbin/puppet_apply $base_installation::puppet_code_path/manifests/site.pp", + user => root, + minute => '*/20', + description => "Re-apply puppet changes regularly", + }, + { + command => "cd $base_installation::puppet_code_path ; /usr/local/sbin/puppet_apply $base_installation::puppet_code_path/manifests/site.pp", + user => root, + special => "reboot", + description => "Re-apply puppet changes at reboot", + } + ] } - cron { 'puppet-apply-reboot': - ensure => present, - command => "cd $base_installation::puppet_code_path ; /usr/local/sbin/puppet_apply $base_installation::puppet_code_path/manifests/site.pp", - user => root, - special => "reboot" - } - cron { 'pacman_keys': - ensure => present, - command => "pacman-key --populate archlinux", - user => root, - minute => "0", - hour => "1", + + cron::daily { 'pacman_keys': + ensure => present, + command => "pacman-key --populate archlinux", + user => root, + minute => "0", + hour => "1", + description => "Populate pacman keys", } } } diff --git a/modules/base_installation/manifests/init.pp b/modules/base_installation/manifests/init.pp index 998f8ff..d8abcaf 100644 --- a/modules/base_installation/manifests/init.pp +++ b/modules/base_installation/manifests/init.pp @@ -30,4 +30,5 @@ class base_installation ( contain ::base_installation::users contain ::base_installation::package_managers contain ::base_installation::puppet + contain ::base_installation::cleanup } -- cgit v1.2.3