Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit 478503f

Browse files
authored
Merge pull request #20 from Telefonica/fix_error_removal_instance
Fix order when setting a github action runner as absent
2 parents 9c2caa6 + c934a46 commit 478503f

File tree

4 files changed

+72
-25
lines changed

4 files changed

+72
-25
lines changed

.fixtures.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ fixtures:
1010
ref: "v1.1.2"
1111
systemd:
1212
repo: "https://github.com/camptocamp/puppet-systemd.git"
13-
ref: "1.1.1"
13+
ref: "2.7.0"
1414

1515

manifests/instance.pp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,20 @@
141141
refreshonly => true
142142
}
143143

144+
$active_service = $ensure ? {
145+
'present' => true,
146+
'absent' => false,
147+
}
148+
149+
$enable_service = $ensure ? {
150+
'present' => true,
151+
'absent' => false,
152+
}
153+
144154
systemd::unit_file { "github-actions-runner.${instance_name}.service":
145155
ensure => $ensure,
156+
enable => $enable_service,
157+
active => $active_service,
146158
content => epp('github_actions_runner/github-actions-runner.service.epp', {
147159
instance_name => $instance_name,
148160
root_dir => $github_actions_runner::root_dir,
@@ -154,23 +166,6 @@
154166
}),
155167
require => [File["${github_actions_runner::root_dir}/${instance_name}/configure_install_runner.sh"],
156168
Exec["${instance_name}-run_configure_install_runner.sh"]],
157-
notify => Service["github-actions-runner.${instance_name}.service"],
158-
}
159-
160-
$ensure_service = $ensure ? {
161-
'present' => running,
162-
'absent' => stopped,
163-
}
164-
165-
$enable_service = $ensure ? {
166-
'present' => true,
167-
'absent' => false,
168-
}
169-
170-
service { "github-actions-runner.${instance_name}.service":
171-
ensure => $ensure_service,
172-
enable => $enable_service,
173-
require => Class['systemd::systemctl::daemon_reload'],
174169
}
175170

176171
}

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
{
1616
"name": "camptocamp/systemd",
17-
"version_requirement": ">= 1.1.1 < 3.0.0"
17+
"version_requirement": ">= 2.7.0 < 3.0.0"
1818
},
1919
{
2020
"name": "puppet-archive",

spec/classes/github_actions_runner_spec.rb

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@
8787
end
8888
end
8989

90-
context 'is expected to create a github_actions_runner service' do
91-
it do
92-
is_expected.to contain_service('github-actions-runner.first_runner.service').with('ensure' => 'running', 'enable' => true)
93-
end
94-
end
95-
9690
context 'is expected to contain archive' do
9791
it do
9892
is_expected.to contain_archive('first_runner-actions-runner-linux-x64-2.272.0.tar.gz').with(
@@ -208,6 +202,64 @@
208202
end
209203
end
210204

205+
context 'is expected to create a github_actions_runner with service active and enabled' do
206+
let(:params) do
207+
super().merge(
208+
'http_proxy' => 'http://proxy.local',
209+
'https_proxy' => 'http://proxy.local',
210+
'no_proxy' => 'example.com',
211+
'instances' => {
212+
'first_runner' => {
213+
'labels' => ['test_label1'],
214+
'repo_name' => 'test_repo',
215+
},
216+
},
217+
)
218+
end
219+
220+
it do
221+
is_expected.to contain_systemd__unit_file('github-actions-runner.first_runner.service').with(
222+
'ensure' => 'present',
223+
'enable' => true,
224+
'active' => true,
225+
)
226+
end
227+
end
228+
229+
context 'is expected to remove github_actions_runner unit_file and other resources' do
230+
let(:params) do
231+
super().merge(
232+
'http_proxy' => 'http://proxy.local',
233+
'https_proxy' => 'http://proxy.local',
234+
'no_proxy' => 'example.com',
235+
'instances' => {
236+
'first_runner' => {
237+
'ensure' => 'absent',
238+
'labels' => ['test_label1'],
239+
'repo_name' => 'test_repo',
240+
},
241+
},
242+
)
243+
end
244+
245+
it do
246+
is_expected.to contain_systemd__unit_file('github-actions-runner.first_runner.service').with(
247+
'ensure' => 'absent',
248+
'enable' => false,
249+
'active' => false,
250+
)
251+
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner').with(
252+
'ensure' => 'absent',
253+
)
254+
is_expected.to contain_archive('first_runner-actions-runner-linux-x64-2.272.0.tar.gz').with(
255+
'ensure' => 'absent',
256+
)
257+
is_expected.to contain_file('/some_dir/actions-runner-2.272.0/first_runner/configure_install_runner.sh').with(
258+
'ensure' => 'absent',
259+
)
260+
end
261+
end
262+
211263
context 'is expected to create a github_actions_runner installation with proxy settings in systemd globally in init.pp' do
212264
let(:params) do
213265
super().merge(

0 commit comments

Comments
 (0)