Skip to content

Commit 4129413

Browse files
committed
WIP
1 parent 401ad9b commit 4129413

File tree

10 files changed

+65
-140
lines changed

10 files changed

+65
-140
lines changed

.fixtures.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
fixtures:
55
forge_modules:
66
stdlib: "puppetlabs/stdlib"
7+
quadlets: "puppet/quadlets"
78
systemd: "puppet/systemd"

REFERENCE.md

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,29 @@
66

77
### Classes
88

9-
* [`smee`](#smee): Manages the smee.io webhook proxy service client
9+
* [`smee`](#smee)
1010

1111
## Classes
1212

1313
### <a name="smee"></a>`smee`
1414

15-
Manages the smee.io webhook proxy service client
15+
The smee class.
1616

1717
#### Parameters
1818

1919
The following parameters are available in the `smee` class:
2020

2121
* [`url`](#-smee--url)
22-
* [`packages`](#-smee--packages)
23-
* [`binary`](#-smee--binary)
24-
* [`exec_start`](#-smee--exec_start)
2522
* [`path`](#-smee--path)
2623
* [`port`](#-smee--port)
27-
* [`version`](#-smee--version)
24+
* [`image`](#-smee--image)
2825

2926
##### <a name="-smee--url"></a>`url`
3027

3128
Data type: `Stdlib::HTTPSUrl`
3229

3330
URL to the smee topic to watch for webhook events.
3431

35-
##### <a name="-smee--packages"></a>`packages`
36-
37-
Data type: `Array[String]`
38-
39-
URL to the smee topic to watch for webhook events.
40-
41-
##### <a name="-smee--binary"></a>`binary`
42-
43-
Data type: `Stdlib::Absolutepath`
44-
45-
Path to smee client binary.
46-
47-
##### <a name="-smee--exec_start"></a>`exec_start`
48-
49-
Data type: `Stdlib::Absolutepath`
50-
51-
Systemd `ExecStart` string.
52-
5332
##### <a name="-smee--path"></a>`path`
5433

5534
Data type: `String`
@@ -66,11 +45,9 @@ Local HTTP server port.
6645

6746
Default value: `3000`
6847

69-
##### <a name="-smee--version"></a>`version`
48+
##### <a name="-smee--image"></a>`image`
7049

71-
Data type: `String`
50+
Data type: `String[1]`
7251

73-
Version of the smee-client package to install.
7452

75-
Default value: `'2.0.0'`
7653

data/common.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
--- {}
1+
---
2+
smee::image: ghcr.io/lsst-it/smee-client:4.3.1

data/osfamily/RedHat/major/7.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

data/osfamily/RedHat/major/8.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

data/osfamily/RedHat/major/9.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/smee.pp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class { 'smee':
2+
url => 'https://foo.example.org',
3+
path => '/payload',
4+
port => 1234,
5+
}

manifests/init.pp

Lines changed: 27 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,47 @@
11
# @summary
22
# Manages the smee.io webhook proxy service client
33
#
4+
# @param image
5+
# The OCI image to use for the service.
6+
47
# @param url
58
# URL to the smee topic to watch for webhook events.
69
#
7-
# @param packages
8-
# URL to the smee topic to watch for webhook events.
9-
#
10-
# @param binary
11-
# Path to smee client binary.
12-
#
13-
# @param exec_start
14-
# Systemd `ExecStart` string.
15-
#
1610
# @param path
1711
# URL path to post proxied requests to.
1812
#
1913
# @param port
2014
# Local HTTP server port.
2115
#
22-
# @param version
23-
# Version of the smee-client package to install.
24-
#
2516
class smee (
17+
String[1] $image,
2618
Stdlib::HTTPSUrl $url,
27-
Array[String] $packages,
28-
Stdlib::Absolutepath $binary,
29-
Stdlib::Absolutepath $exec_start,
3019
String $path = '/',
3120
Integer $port = 3000,
32-
String $version = '2.0.0',
3321
) {
34-
stdlib::ensure_packages($packages)
35-
36-
group { 'smee':
37-
ensure => present,
38-
system => true,
39-
}
40-
-> user { 'smee':
41-
ensure => present,
42-
gid => 'smee',
43-
home => '/',
44-
managehome => false,
45-
shell => '/sbin/nologin',
46-
system => true,
47-
}
48-
49-
exec { 'install-smee':
50-
creates => $binary,
51-
command => "npm install --global smee-client@${version}",
52-
subscribe => Package[$packages],
53-
path => [
54-
'/opt/rh/rh-nodejs10/root/usr/bin', # needed for EL7
55-
'/usr/sbin',
56-
'/usr/bin',
57-
],
58-
}
59-
60-
$service_unit = @("EOT")
61-
[Unit]
62-
Description=smee.io webhook daemon
63-
64-
[Service]
65-
Type=simple
66-
User=smee
67-
Group=smee
68-
ExecStart=${exec_start} \
69-
--url ${url} \
70-
-P ${path} \
71-
-p ${port}
72-
Restart=on-failure
73-
RestartSec=10
74-
PrivateTmp=yes
75-
PrivateDevices=yes
76-
ProtectSystem=yes
77-
ProtectHome=yes
78-
79-
[Install]
80-
WantedBy=default.target
81-
| EOT
22+
$nobody = 65534
8223

83-
systemd::unit_file { 'smee.service':
84-
ensure => 'present',
85-
active => true,
86-
content => $service_unit,
87-
enable => true,
88-
subscribe => Exec['install-smee'],
89-
require => User['smee'],
24+
quadlets::quadlet { 'smee.container':
25+
ensure => present,
26+
active => true,
27+
unit_entry => {
28+
'Description' => 'smee.io webhook proxy client',
29+
'Requires' => 'network-online.target',
30+
'After' => 'network-online.target',
31+
},
32+
container_entry => {
33+
'Image' => $image,
34+
'Exec' => "--url '${url}' --path '${path}' --port '${port}'",
35+
'Network' => 'host',
36+
'User' => $nobody,
37+
'Group' => $nobody,
38+
'Tmpfs' => ['/run'],
39+
},
40+
service_entry => {
41+
'Restart' => 'always',
42+
},
43+
install_entry => {
44+
'WantedBy' => 'default.target',
45+
},
9046
}
9147
}

metadata.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
"summary": "Manages the smee.io webhook proxy service client",
66
"license": "Apache-2.0",
77
"source": "https://github.com/lsst-it/puppet-smee",
8+
"tags": [
9+
"proxy",
10+
"smee",
11+
"webhook"
12+
],
813
"dependencies": [
914
{
1015
"name": "puppetlabs/stdlib",
1116
"version_requirement": ">= 9.0.0 < 10.0.0"
1217
},
1318
{
14-
"name": "puppet/systemd",
15-
"version_requirement": ">= 3.0.0 < 9.0.0"
19+
"name": "puppet/quadlets",
20+
"version_requirement": ">= 2.0.0 < 3.0.0"
1621
}
1722
],
1823
"operatingsystem_support": [

spec/acceptance/smee_spec.rb

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,26 @@
33
require 'spec_helper_acceptance'
44

55
describe 'smee class' do
6-
context 'with url' do
7-
let(:manifest) do
8-
<<-PP
9-
class { smee:
10-
url => 'https://foo.example.org',
11-
path => '/payload',
12-
port => 1234,
13-
}
14-
PP
15-
end
6+
shell('dnf install -y podman-docker') # used by serverspec
167

17-
it_behaves_like 'an idempotent resource'
8+
include_examples 'the example', 'smee.pp'
189

19-
describe service('smee') do
20-
it { is_expected.to be_enabled }
21-
it { is_expected.to be_running }
22-
end
10+
it_behaves_like 'an idempotent resource'
2311

24-
describe process('node') do
25-
its(:user) { is_expected.to eq 'smee' }
26-
its(:group) { is_expected.to eq 'smee' }
27-
its(:args) { is_expected.to match %r{--url https://foo.example.org} }
28-
its(:args) { is_expected.to match %r{-P /payload} }
29-
its(:args) { is_expected.to match %r{-p 1234} }
30-
end
12+
describe service('smee') do
13+
it { is_expected.to be_enabled }
14+
it { is_expected.to be_running }
15+
end
16+
17+
describe docker_container('systemd-smee') do
18+
its(['Config.Image']) { is_expected.to eq 'ghcr.io/lsst-it/smee-client:4.3.1' }
19+
its(['Config.User']) { is_expected.to eq '65534:65534' }
20+
its(['HostConfig.NetworkMode']) { is_expected.to eq 'host' }
21+
its(['Args']) { is_expected.to include('--url') }
22+
its(['Args']) { is_expected.to include('https://foo.example.org') }
23+
its(['Args']) { is_expected.to include('--path') }
24+
its(['Args']) { is_expected.to include('/payload') }
25+
its(['Args']) { is_expected.to include('--port') }
26+
its(['Args']) { is_expected.to include('1234') }
3127
end
3228
end

0 commit comments

Comments
 (0)