Skip to content

Commit 3af1822

Browse files
committed
Restart services when enabling cockpit
Signed-off-by: Eric D. Helms <[email protected]>
1 parent 74a4878 commit 3af1822

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

manifests/plugin/remote_execution/cockpit.pp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@
4242
service { 'foreman-cockpit':
4343
ensure => running,
4444
enable => true,
45-
require => Foreman::Plugin['remote_execution-cockpit'],
45+
require => [
46+
Foreman::Plugin['remote_execution-cockpit'],
47+
Foreman::Config::Apache::Fragment['cockpit'],
48+
],
4649
subscribe => File["${config_directory}/cockpit.conf", "${config_directory}/foreman-cockpit-session.yml"],
4750
}
4851
}
@@ -82,6 +85,7 @@
8285
foreman_config_entry { 'remote_execution_cockpit_url':
8386
value => "${cockpit_path}/=%{host}",
8487
require => Class['foreman::database'],
88+
notify => Class['foreman::service'],
8589
}
8690
}
8791
}

spec/acceptance/foreman_rex_cockpit_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,24 @@
1717
describe port(19090) do
1818
it { is_expected.to be_listening.on('127.0.0.1').with('tcp') }
1919
end
20+
21+
describe service('foreman-cockpit') do
22+
it { is_expected.to be_running }
23+
it { is_expected.to be_enabled }
24+
end
25+
26+
describe service('httpd') do
27+
it { is_expected.to be_running }
28+
it { is_expected.to be_enabled }
29+
end
30+
31+
describe file('/etc/httpd/conf.d/05-foreman-ssl.d/cockpit.conf') do
32+
it { is_expected.to be_file }
33+
its(:content) { should match(%r{<Location /webcon>}) }
34+
its(:content) { should match(%r{ProxyPass http://127\.0\.0\.1:19090/webcon}) }
35+
end
36+
37+
describe command('curl -k -s -o /dev/null -w "%{http_code}" https://localhost/webcon/') do
38+
its(:stdout) { should match(/^(200|302|401)$/) }
39+
end
2040
end

spec/classes/plugin/remote_execution_cockpit_spec.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@ class {'foreman':
2323
is_expected.to contain_foreman__plugin('tasks')
2424
end
2525

26-
it { is_expected.to contain_service('foreman-cockpit').with_ensure('running').with_enable('true') }
26+
it do
27+
is_expected.to contain_service('foreman-cockpit')
28+
.with_ensure('running')
29+
.with_enable('true')
30+
.that_requires(['Foreman::Plugin[remote_execution-cockpit]', 'Foreman::Config::Apache::Fragment[cockpit]'])
31+
end
2732

2833
it do
2934
is_expected.to contain_foreman_config_entry('remote_execution_cockpit_url')
3035
.that_requires(['Class[foreman::database]', 'Foreman::Plugin[remote_execution-cockpit]'])
36+
.that_notifies('Class[foreman::service]')
3137
end
3238

3339
it 'creates configs' do

spec/defines/foreman_config_apache_fragment_spec.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ class { 'foreman::config::apache':
3333
{ content: '# config' }
3434
end
3535

36-
it { should contain_file("#{confd_dir}/05-foreman.d/test.conf").with_content('# config') }
36+
it do
37+
should contain_file("#{confd_dir}/05-foreman.d/test.conf")
38+
.with_content('# config')
39+
.that_notifies('Class[apache::service]')
40+
end
3741
it { should contain_file("#{confd_dir}/05-foreman-ssl.d/test.conf").with_ensure(:absent) }
3842
end
3943

@@ -62,7 +66,11 @@ class { 'foreman::config::apache':
6266
end
6367

6468
it { should contain_file("#{confd_dir}/05-foreman.d/test.conf").with_ensure(:absent) }
65-
it { should contain_file("#{confd_dir}/05-foreman-ssl.d/test.conf").with_content('# config') }
69+
it do
70+
should contain_file("#{confd_dir}/05-foreman-ssl.d/test.conf")
71+
.with_content('# config')
72+
.that_notifies('Class[apache::service]')
73+
end
6674
end
6775
end
6876
end

0 commit comments

Comments
 (0)