-
Notifications
You must be signed in to change notification settings - Fork 13
/
systemd.go
85 lines (79 loc) · 2.43 KB
/
systemd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright 2018 Red Hat
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package ignition
import (
"strings"
"github.com/flatcar/mantle/kola/cluster"
"github.com/flatcar/mantle/kola/register"
"github.com/flatcar/mantle/platform/conf"
)
func init() {
register.Register(®ister.Test{
Name: "coreos.ignition.systemd.enable-service",
Run: enableSystemdService,
// This test is normally not related to the cloud environment
Platforms: []string{"qemu", "qemu-unpriv"},
ClusterSize: 1,
// enable nfs-server, touch /etc/exports as it doesn't exist by default on Container Linux,
// and touch /var/lib/nfs/etab (https://bugzilla.redhat.com/show_bug.cgi?id=1394395) for RHCOS
UserData: conf.Ignition(`{
"ignition": {"version": "2.2.0"},
"systemd": {
"units": [{
"name":"nfs-server.service",
"enabled":true
}]
},
"storage": {
"files": [{
"filesystem":"root",
"path":"/etc/exports"
},
{
"filesystem":"root",
"path":"/var/lib/nfs/etab"
}]
}
}`),
UserDataV3: conf.Ignition(`{
"ignition": {"version": "3.0.0"},
"systemd": {
"units": [{
"name":"nfs-server.service",
"enabled":true
}]
},
"storage": {
"files": [{
"path":"/etc/exports"
},
{
"path":"/var/lib/nfs/etab"
}]
}
}`),
// FCOS just ships the client (see
// https://github.com/coreos/fedora-coreos-tracker/issues/121).
// Should probably just pick a different unit to test with, though
// testing the NFS workflow is useful for RHCOS/CL.
ExcludeDistros: []string{"fcos"},
})
}
func enableSystemdService(c cluster.TestCluster) {
m := c.Machines()[0]
out := c.MustSSH(m, "systemctl status nfs-server.service")
if strings.Contains(string(out), "inactive") {
c.Fatalf("service was not enabled or systemd-presets did not run")
}
}