aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-03-26 00:41:55 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-03-26 01:19:39 +0200
commit2859008efe8f0a75344c7ba1c9c6e4d589f92da3 (patch)
treebb48fa503b6b1e01f9216d9e1729e1ba26adacf5
parent7f1244c8c2a418ed9e978f098c73f8697e2cd306 (diff)
downloadPuppet-2859008efe8f0a75344c7ba1c9c6e4d589f92da3.tar.gz
Puppet-2859008efe8f0a75344c7ba1c9c6e4d589f92da3.tar.zst
Puppet-2859008efe8f0a75344c7ba1c9c6e4d589f92da3.zip
Use external module for cronjobs
-rw-r--r--.gitmodules3
-rw-r--r--modules/base_installation/manifests/cleanup.pp20
-rw-r--r--modules/base_installation/manifests/cronie.pp54
-rw-r--r--modules/base_installation/manifests/init.pp1
m---------modules/cron0
-rw-r--r--modules/role/manifests/backup.pp2
-rw-r--r--modules/role/manifests/cryptoportfolio/bot.pp40
7 files changed, 75 insertions, 45 deletions
diff --git a/.gitmodules b/.gitmodules
index 7a56af5..6752dee 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -55,3 +55,6 @@
55[submodule "modules/ssl"] 55[submodule "modules/ssl"]
56 path = modules/ssl 56 path = modules/ssl
57 url = git://git.immae.eu/github/fnerdwq/puppet-ssl 57 url = git://git.immae.eu/github/fnerdwq/puppet-ssl
58[submodule "modules/cron"]
59 path = modules/cron
60 url = git://git.immae.eu/github/voxpupuli/puppet-cron
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 @@
1class base_installation::cleanup inherits base_installation {
2 # This class contains temporary classes used to cleanup old stuff
3 # after refactoring
4
5 cron { "puppet-pull-apply":
6 ensure => absent;
7 "puppet-apply":
8 ensure => absent;
9 "puppet-apply-reboot":
10 ensure => absent;
11 "pacman_keys":
12 ensure => absent;
13 "backup":
14 ensure => absent;
15 "py-cryptoportfolio-before":
16 ensure => absent;
17 "py-cryptoportfolio-after":
18 ensure => absent;
19 }
20}
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 {
10 owner => root, 10 owner => root,
11 group => root, 11 group => root,
12 } 12 }
13 cron { 'puppet-pull-apply': 13 cron::job { 'puppet-pull-apply':
14 ensure => present, 14 ensure => present,
15 command => "cd $base_installation::puppet_code_path ; /usr/bin/git pull", 15 command => "cd $base_installation::puppet_code_path ; /usr/bin/git pull",
16 user => root, 16 user => root,
17 minute => '*/30', 17 minute => '15,45',
18 require => File['post-hook'], 18 require => File['post-hook'],
19 description => "Pull git and apply puppet changes",
19 } 20 }
20 cron { 'puppet-apply': 21 cron::job::multiple { 'puppet-apply':
21 ensure => present, 22 ensure => present,
22 command => "cd $base_installation::puppet_code_path ; /usr/local/sbin/puppet_apply $base_installation::puppet_code_path/manifests/site.pp", 23 jobs => [
23 user => root, 24 {
24 minute => '*/20' 25 command => "cd $base_installation::puppet_code_path ; /usr/local/sbin/puppet_apply $base_installation::puppet_code_path/manifests/site.pp",
26 user => root,
27 minute => '*/20',
28 description => "Re-apply puppet changes regularly",
29 },
30 {
31 command => "cd $base_installation::puppet_code_path ; /usr/local/sbin/puppet_apply $base_installation::puppet_code_path/manifests/site.pp",
32 user => root,
33 special => "reboot",
34 description => "Re-apply puppet changes at reboot",
35 }
36 ]
25 } 37 }
26 cron { 'puppet-apply-reboot': 38
27 ensure => present, 39 cron::daily { 'pacman_keys':
28 command => "cd $base_installation::puppet_code_path ; /usr/local/sbin/puppet_apply $base_installation::puppet_code_path/manifests/site.pp", 40 ensure => present,
29 user => root, 41 command => "pacman-key --populate archlinux",
30 special => "reboot" 42 user => root,
31 } 43 minute => "0",
32 cron { 'pacman_keys': 44 hour => "1",
33 ensure => present, 45 description => "Populate pacman keys",
34 command => "pacman-key --populate archlinux",
35 user => root,
36 minute => "0",
37 hour => "1",
38 } 46 }
39 } 47 }
40} 48}
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 (
30 contain ::base_installation::users 30 contain ::base_installation::users
31 contain ::base_installation::package_managers 31 contain ::base_installation::package_managers
32 contain ::base_installation::puppet 32 contain ::base_installation::puppet
33 contain ::base_installation::cleanup
33} 34}
diff --git a/modules/cron b/modules/cron
new file mode 160000
Subproject d90d9be088ad5008018ada87c30ceb314a46ed7
diff --git a/modules/role/manifests/backup.pp b/modules/role/manifests/backup.pp
index 7a0c275..510a8ef 100644
--- a/modules/role/manifests/backup.pp
+++ b/modules/role/manifests/backup.pp
@@ -41,7 +41,7 @@ class role::backup (
41 mode => "0755", 41 mode => "0755",
42 } 42 }
43 43
44 cron { "backup": 44 cron::job { "backup":
45 ensure => present, 45 ensure => present,
46 command => $backup_script, 46 command => $backup_script,
47 user => $user, 47 user => $user,
diff --git a/modules/role/manifests/cryptoportfolio/bot.pp b/modules/role/manifests/cryptoportfolio/bot.pp
index d8b377f..7b62ae0 100644
--- a/modules/role/manifests/cryptoportfolio/bot.pp
+++ b/modules/role/manifests/cryptoportfolio/bot.pp
@@ -37,8 +37,7 @@ class role::cryptoportfolio::bot inherits role::cryptoportfolio {
37 refreshonly => true, 37 refreshonly => true,
38 before => [ 38 before => [
39 File[$cf_bot_app_conf], 39 File[$cf_bot_app_conf],
40 Cron["py-cryptoportfolio-before"], 40 Cron::Job::Multiple["py-cryptoportfolio"],
41 Cron["py-cryptoportfolio-after"],
42 ] 41 ]
43 } 42 }
44 43
@@ -54,31 +53,30 @@ class role::cryptoportfolio::bot inherits role::cryptoportfolio {
54 ], 53 ],
55 } 54 }
56 55
57 cron { "py-cryptoportfolio-before": 56 cron::job::multiple { "py-cryptoportfolio":
58 ensure => present, 57 ensure => present,
59 command => "cd $cf_bot_app ; python main.py --quiet --config $cf_bot_app_conf --before",
60 user => $user,
61 weekday => 7, # Sunday
62 hour => 22,
63 minute => 30,
64 environment => ["HOME=${home}","PATH=/usr/bin/","CRON_TZ=UTC"], 58 environment => ["HOME=${home}","PATH=/usr/bin/","CRON_TZ=UTC"],
65 require => [ 59 require => [
66 File[$cf_bot_app_conf], 60 File[$cf_bot_app_conf],
67 Archive["${home}/trader_${bot_version}.tar.gz"] 61 Archive["${home}/trader_${bot_version}.tar.gz"]
68 ], 62 ],
69 } 63 jobs => [
70 64 {
71 cron { "py-cryptoportfolio-after": 65 command => "cd $cf_bot_app ; python main.py --quiet --config $cf_bot_app_conf --before",
72 ensure => present, 66 user => $user,
73 command => "cd $cf_bot_app ; python main.py --quiet --config $cf_bot_app_conf --after", 67 weekday => 7, # Sunday
74 user => $user, 68 hour => 22,
75 weekday => 1, # Monday 69 minute => 30,
76 hour => 0, 70 description => "Run before the cryptoportfolio update",
77 minute => 0, 71 },
78 environment => ["HOME=${home}","PATH=/usr/bin/","CRON_TZ=UTC"], 72 {
79 require => [ 73 command => "cd $cf_bot_app ; python main.py --quiet --config $cf_bot_app_conf --after",
80 File[$cf_bot_app_conf], 74 user => $user,
81 Archive["${home}/trader_${bot_version}.tar.gz"] 75 weekday => 1, # Monday
76 hour => 0,
77 minute => 0,
78 description => "Run after the cryptoportfolio update",
79 }
82 ], 80 ],
83 } 81 }
84 82