Skip to content

Commit

Permalink
(profile::core::puppet_master) use lsst/smee instead of inline code
Browse files Browse the repository at this point in the history
The lsst/smee mod has support for both EL7 and EL8.
  • Loading branch information
jhoblitt committed Jul 28, 2022
1 parent 6cf4956 commit 21eb962
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 47 deletions.
52 changes: 6 additions & 46 deletions site/profile/manifests/core/puppet_master.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@

Class['r10k::webhook::config'] -> Class['r10k::webhook']

class { 'smee':
url => $smee_url,
path => '/payload',
port => 8088,
}

# el7 systemd is too old to support periodic graceful restarts of a service unit.
# Using cron seems slightly more obvious than creating a timer unit than triggers a one shot
# service to restart the original service unit.
Expand All @@ -89,52 +95,6 @@
minute => 42,
}

$node_pkgs = [
'rh-nodejs10',
'rh-nodejs10-npm',
]

package { $node_pkgs:
require => Class['scl'],
}

exec { 'install-smee':
creates => '/opt/rh/rh-nodejs10/root/usr/bin/smee',
command => 'npm install --global smee-client',
subscribe => Package['rh-nodejs10-npm'],
path => [
'/opt/rh/rh-nodejs10/root/usr/bin',
'/usr/sbin',
'/usr/bin',
],
}

$service_unit = @("EOT")
[Unit]
Description=smee.io webhook daemon

[Service]
Type=simple
ExecStart=/usr/bin/scl enable rh-nodejs10 -- \
/opt/rh/rh-nodejs10/root/usr/bin/smee \
--url ${smee_url} \
-P /payload \
-p 8088
Restart=on-failure
RestartSec=10

[Install]
WantedBy=default.target
| EOT

systemd::unit_file { 'smee.service':
ensure => 'present',
active => true,
content => $service_unit,
enable => true,
subscribe => Exec['install-smee'],
}

cron { 'smee':
command => '/usr/bin/systemctl restart smee > /dev/null 2>&1',
user => 'root',
Expand Down
8 changes: 8 additions & 0 deletions spec/classes/core/puppet_master_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
describe 'profile::core::puppet_master' do
it { is_expected.to compile.with_all_deps }

it do
is_expected.to contain_class('smee').with(
url: 'https://foo.example.org',
path: '/payload',
port: 8088,
)
end

it do
is_expected.to contain_cron('webhook').with_command('/usr/bin/systemctl restart webhook > /dev/null 2>&1')
end
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/hieradata/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ profile::core::monitoring::database: "foo"
profile::core::monitoring::password: "foo"
profile::core::monitoring::url: "foo"
profile::core::monitoring::username: "foo"
profile::core::puppet_master::smee_url: "https://smee.io/abc"
profile::core::puppet_master::smee_url: "https://foo.example.org"
profile::icinga::agent::ca_salt: "foo"
profile::icinga::agent::credentials_hash: "foo"
profile::icinga::master::api_name: "foo"
Expand Down
9 changes: 9 additions & 0 deletions spec/hosts/roles/foreman_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@
end

it { is_expected.to contain_foreman_config_entry('template_sync_branch').with_value(site) }

it do
is_expected.to contain_class('smee').with(
url: smee_url,
path: '/payload',
port: 8088,
)
end
end

role = 'foreman'
Expand All @@ -157,6 +165,7 @@
site: site,
}
end
let(:smee_url) { 'https://smee.io/lpxrggGObEn5YTA' }

describe 'foreman.dev.lsst.org', :site, :common do
let(:site) { 'dev' }
Expand Down

0 comments on commit 21eb962

Please sign in to comment.