Skip to content

Commit 4d244e5

Browse files
authored
Merge pull request #773 from cultuurnet/feature/UPS-5853
Add cron toggle for UiTPAS API to allow multi-server deployment
2 parents c730e80 + f5c829b commit 4d244e5

File tree

4 files changed

+104
-33
lines changed

4 files changed

+104
-33
lines changed

manifests/uitpas/api.pp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Variant[String, Array[String]] $serveraliases = [],
55
String $database_host = '127.0.0.1',
66
Boolean $deployment = true,
7+
Boolean $cron_enabled = true,
78
Optional[String] $initial_heap_size = undef,
89
Optional[String] $maximum_heap_size = '512m',
910
Boolean $jmx = true,
@@ -144,8 +145,9 @@
144145
}
145146

146147
class { 'profiles::uitpas::api::cron':
147-
portbase => $portbase,
148-
require => Class['profiles::uitpas::api::deployment'],
148+
portbase => $portbase,
149+
cron_enabled => $cron_enabled,
150+
require => Class['profiles::uitpas::api::deployment'],
149151
}
150152

151153
Class['profiles::glassfish'] -> Class['profiles::uitpas::api::deployment']

manifests/uitpas/api/cron.pp

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class profiles::uitpas::api::cron (
2-
Integer $portbase = 4800
2+
Integer $portbase = 4800,
3+
Boolean $cron_enabled = true
34
) inherits ::profiles {
45

56
$http_port = String($portbase + 80)
@@ -29,84 +30,132 @@
2930
* => $profiles::logrotate::default_rule_attributes
3031
}
3132

32-
cron {'uitpas enduser clearcheckincodes':
33+
cron { 'uitpas enduser clearcheckincodes':
34+
ensure => $cron_enabled ? {
35+
true => 'present',
36+
default => 'absent',
37+
},
3338
command => "/usr/bin/curl '${base_url}/uitid/rest/uitpas/enduser/clearcheckincodes' >> ${cron_logdir}/clearcheckincodes.log 2>&1",
3439
hour => '3',
3540
minute => '5',
3641
* => $cron_default_attributes
3742
}
3843

3944
cron { 'uitpas milestone batch activity':
40-
command => "/usr/bin/curl '${base_url}/uitid/rest/uitpas/milestone/batch/activity' >> ${cron_logdir}/activity.log 2>&1",
45+
ensure => $cron_enabled ? {
46+
true => 'present',
47+
default => 'absent',
48+
},
49+
command => "/usr/bin/curl '${base_url}/uitid/rest/uitpas/milestone/batch/activity' >> ${cron_logdir}/activity.log 2>&1",
4150
hour => '1',
4251
minute => '2',
4352
* => $cron_default_attributes
4453
}
4554

4655
cron { 'uitpas milestone batch points':
56+
ensure => $cron_enabled ? {
57+
true => 'present',
58+
default => 'absent',
59+
},
4760
command => "/usr/bin/curl '${base_url}/uitid/rest/uitpas/milestone/batch/points' >> ${cron_logdir}/points.log 2>&1",
4861
hour => '2',
4962
minute => '2',
5063
* => $cron_default_attributes
5164
}
5265

5366
cron { 'uitpas milestone batch birthday':
67+
ensure => $cron_enabled ? {
68+
true => 'present',
69+
default => 'absent',
70+
},
5471
command => "/usr/bin/curl '${base_url}/uitid/rest/uitpas/milestone/batch/birthday' >> ${cron_logdir}/birthday.log 2>&1",
5572
hour => '4',
5673
minute => '2',
5774
* => $cron_default_attributes
5875
}
5976

6077
cron { 'uitpas passholder indexpointspromotions':
78+
ensure => $cron_enabled ? {
79+
true => 'present',
80+
default => 'absent',
81+
},
6182
command => "/usr/bin/curl '${base_url}/uitid/rest/uitpas/passholder/indexpointspromotions?unindexedOnly=true' >> ${cron_logdir}/indexpointspromotions.log 2>&1",
6283
hour => '*',
6384
minute => '34',
6485
* => $cron_default_attributes
6586
}
6687

6788
cron { 'uitpas autorenew triggerupload':
89+
ensure => $cron_enabled ? {
90+
true => 'present',
91+
default => 'absent',
92+
},
6893
command => "/usr/bin/curl '${base_url}/uitid/rest/uitpas/autorenew/triggerupload' >> ${cron_logdir}/triggerupload.log 2>&1",
6994
hour => '*',
7095
minute => '*/10',
7196
* => $cron_default_attributes
7297
}
7398

7499
cron { 'uitpas autorenew triggerdownload':
100+
ensure => $cron_enabled ? {
101+
true => 'present',
102+
default => 'absent',
103+
},
75104
command => "/usr/bin/curl '${base_url}/uitid/rest/uitpas/autorenew/triggerdownload' >> ${cron_logdir}/triggerdownload.log 2>&1",
76105
hour => '*',
77106
minute => '*/10',
78107
* => $cron_default_attributes
79108
}
80109

81110
cron { 'uitpas autorenew triggerprocess':
111+
ensure => $cron_enabled ? {
112+
true => 'present',
113+
default => 'absent',
114+
},
82115
command => "/usr/bin/curl '${base_url}/uitid/rest/uitpas/autorenew/triggerprocess' >> ${cron_logdir}/triggerprocess.log 2>&1",
83116
hour => '*',
84117
minute => '*/10',
85118
* => $cron_default_attributes
86119
}
87120

88121
cron { 'uitpas trigger price message':
122+
ensure => $cron_enabled ? {
123+
true => 'present',
124+
default => 'absent',
125+
},
89126
command => "/usr/bin/curl '${base_url}/uitid/rest/bootstrap/uitpas/trigger-event-price-messages?max=100' >> ${cron_logdir}/trigger-event-price-message.log 2>&1",
90127
hour => '*',
91128
minute => '*',
92129
* => $cron_default_attributes
93130
}
94131

95132
cron { 'uitpas balie indexbalies':
133+
ensure => $cron_enabled ? {
134+
true => 'present',
135+
default => 'absent',
136+
},
96137
command => "/usr/bin/curl '${base_url}/uitid/rest/uitpas/balie/indexbalies' >> ${cron_logdir}/indexbalies.log 2>&1",
97138
hour => '5',
98139
minute => '14',
99140
* => $cron_default_attributes
100141
}
101142

102143
cron { 'uitpas clear jpa cache':
144+
ensure => $cron_enabled ? {
145+
true => 'present',
146+
default => 'absent',
147+
},
103148
command => "/usr/bin/curl -q -s '${base_url}/uitid/rest/bootstrap/uitpas/clearJpaCache' > /dev/null",
104149
hour => '*/6',
105150
minute => '30',
106151
* => $cron_default_attributes
107152
}
108153

109154
cron { 'uitpas clear cache':
155+
ensure => $cron_enabled ? {
156+
true => 'present',
157+
default => 'absent',
158+
},
110159
command => "/usr/bin/curl -q -s '${base_url}/uitid/rest/bootstrap/uitpas/clearcaches' > /dev/null",
111160
hour => '6',
112161
minute => '15',

spec/classes/uitpas/api/cron_spec.rb

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
it { is_expected.to compile.with_all_deps }
1212

1313
it { is_expected.to contain_class('profiles::uitpas::api::cron').with(
14-
'portbase' => 4800
14+
'portbase' => 4800,
15+
'cron_enabled' => true,
1516
) }
1617

1718
it { is_expected.to contain_group('glassfish') }
@@ -21,77 +22,94 @@
2122
'command' => "/usr/bin/curl 'http://127.0.0.1:4880/uitid/rest/uitpas/enduser/clearcheckincodes' >> /var/log/uitpas-cron/clearcheckincodes.log 2>&1",
2223
'user' => 'glassfish',
2324
'hour' => '3',
24-
'minute' => '5'
25+
'minute' => '5',
26+
'ensure' => 'present'
27+
2528
) }
2629

2730
it { is_expected.to contain_cron('uitpas milestone batch activity').with(
2831
'command' => "/usr/bin/curl 'http://127.0.0.1:4880/uitid/rest/uitpas/milestone/batch/activity' >> /var/log/uitpas-cron/activity.log 2>&1",
2932
'user' => 'glassfish',
3033
'hour' => '1',
31-
'minute' => '2'
34+
'minute' => '2',
35+
'ensure' => 'present'
36+
3237
) }
3338

3439
it { is_expected.to contain_cron('uitpas milestone batch points').with(
3540
'command' => "/usr/bin/curl 'http://127.0.0.1:4880/uitid/rest/uitpas/milestone/batch/points' >> /var/log/uitpas-cron/points.log 2>&1",
3641
'user' => 'glassfish',
3742
'hour' => '2',
38-
'minute' => '2'
43+
'minute' => '2',
44+
'ensure' => 'present'
45+
3946
) }
4047

4148
it { is_expected.to contain_cron('uitpas milestone batch birthday').with(
4249
'command' => "/usr/bin/curl 'http://127.0.0.1:4880/uitid/rest/uitpas/milestone/batch/birthday' >> /var/log/uitpas-cron/birthday.log 2>&1",
4350
'user' => 'glassfish',
4451
'hour' => '4',
45-
'minute' => '2'
52+
'minute' => '2',
53+
'ensure' => 'present'
54+
4655
) }
4756

4857
it { is_expected.to contain_cron('uitpas passholder indexpointspromotions').with(
4958
'command' => "/usr/bin/curl 'http://127.0.0.1:4880/uitid/rest/uitpas/passholder/indexpointspromotions?unindexedOnly=true' >> /var/log/uitpas-cron/indexpointspromotions.log 2>&1",
5059
'user' => 'glassfish',
5160
'hour' => '*',
52-
'minute' => '34'
61+
'minute' => '34',
62+
'ensure' => 'present'
63+
5364
) }
5465

5566
it { is_expected.to contain_cron('uitpas autorenew triggerupload').with(
5667
'command' => "/usr/bin/curl 'http://127.0.0.1:4880/uitid/rest/uitpas/autorenew/triggerupload' >> /var/log/uitpas-cron/triggerupload.log 2>&1",
5768
'user' => 'glassfish',
5869
'hour' => '*',
59-
'minute' => '*/10'
70+
'minute' => '*/10',
71+
'ensure' => 'present'
6072
) }
6173

6274
it { is_expected.to contain_cron('uitpas autorenew triggerdownload').with(
6375
'command' => "/usr/bin/curl 'http://127.0.0.1:4880/uitid/rest/uitpas/autorenew/triggerdownload' >> /var/log/uitpas-cron/triggerdownload.log 2>&1",
6476
'user' => 'glassfish',
6577
'hour' => '*',
66-
'minute' => '*/10'
78+
'minute' => '*/10',
79+
'ensure' => 'present'
80+
6781
) }
6882

6983
it { is_expected.to contain_cron('uitpas autorenew triggerprocess').with(
7084
'command' => "/usr/bin/curl 'http://127.0.0.1:4880/uitid/rest/uitpas/autorenew/triggerprocess' >> /var/log/uitpas-cron/triggerprocess.log 2>&1",
7185
'user' => 'glassfish',
7286
'hour' => '*',
73-
'minute' => '*/10'
87+
'minute' => '*/10',
88+
'ensure' => 'present'
7489
) }
7590

7691
it { is_expected.to contain_cron('uitpas balie indexbalies').with(
7792
'command' => "/usr/bin/curl 'http://127.0.0.1:4880/uitid/rest/uitpas/balie/indexbalies' >> /var/log/uitpas-cron/indexbalies.log 2>&1",
7893
'user' => 'glassfish',
7994
'hour' => '5',
80-
'minute' => '14'
95+
'minute' => '14',
96+
'ensure' => 'present'
8197
) }
8298

8399
it { is_expected.to contain_cron('uitpas clear jpa cache').with(
84100
'command' => "/usr/bin/curl -q -s 'http://127.0.0.1:4880/uitid/rest/bootstrap/uitpas/clearJpaCache' > /dev/null",
85101
'user' => 'glassfish',
86102
'hour' => '*/6',
87-
'minute' => '30'
103+
'minute' => '30',
104+
'ensure' => 'present'
88105
) }
89106

90107
it { is_expected.to contain_cron('uitpas clear cache').with(
91108
'command' => "/usr/bin/curl -q -s 'http://127.0.0.1:4880/uitid/rest/bootstrap/uitpas/clearcaches' > /dev/null",
92109
'user' => 'glassfish',
93110
'hour' => '6',
94-
'minute' => '15'
111+
'minute' => '15',
112+
'ensure' => 'present'
95113
) }
96114

97115
it { is_expected.to contain_cron('uitpas enduser clearcheckincodes').that_requires('User[glassfish]') }
@@ -107,9 +125,10 @@
107125
it { is_expected.to contain_cron('uitpas clear cache').that_requires('User[glassfish]') }
108126
end
109127

110-
context "with portbase => 14800" do
128+
context "with portbase => 14800 and cron_enabled=> true" do
111129
let(:params) { {
112-
'portbase' => 14800
130+
'portbase' => 14800,
131+
'cron_enabled' => true
113132
} }
114133

115134
it { is_expected.to contain_cron('uitpas enduser clearcheckincodes').with(

spec/classes/uitpas/api_spec.rb

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,21 @@
2020
it { is_expected.to compile.with_all_deps }
2121

2222
it { is_expected.to contain_class('profiles::uitpas::api').with(
23-
'servername' => 'uitpas.example.com',
24-
'serveraliases' => [],
25-
'database_password' => 'mypassword',
26-
'database_host' => '127.0.0.1',
27-
'deployment' => true,
28-
'initial_heap_size' => nil,
29-
'maximum_heap_size' => '512m',
30-
'jmx' => true,
31-
'newrelic' => false,
32-
'newrelic_license_key' => 'my_license_key',
33-
'portbase' => 4800,
34-
'service_status' => 'running',
35-
'gcloud_etl_sync_enabled' => true,
36-
'settings' => {}
23+
'servername' =>'uitpas.example.com',
24+
'serveraliases' =>[],
25+
'database_password' =>'mypassword',
26+
'database_host' =>'127.0.0.1',
27+
'cron_enabled' =>true,
28+
'deployment' =>true,
29+
'initial_heap_size' =>nil,
30+
'maximum_heap_size' =>nil,
31+
'jmx' =>true,
32+
'newrelic' =>false,
33+
'newrelic_license_key' =>'my_license_key',
34+
'portbase' =>4800,
35+
'service_status' =>'running',
36+
'gcloud_etl_sync_enabled' =>true,
37+
'settings' =>{}
3738
) }
3839

3940
it { is_expected.to contain_group('glassfish') }

0 commit comments

Comments
 (0)