Skip to content

Commit 6fa182d

Browse files
sengo4hdFizzadar
authored andcommitted
operations/openrc: support runlevel for enabling services
1 parent 26c14a6 commit 6fa182d

File tree

5 files changed

+48
-4
lines changed

5 files changed

+48
-4
lines changed

pyinfra/operations/openrc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ def service(
5050

5151
if enabled is True:
5252
if not is_enabled:
53-
yield "rc-update add {0}".format(service)
53+
yield "rc-update add {0} {1}".format(service, runlevel)
5454
openrc_enabled[service] = True
5555
else:
5656
host.noop("service {0} is enabled".format(service))
5757

5858
if enabled is False:
5959
if is_enabled:
60-
yield "rc-update del {0}".format(service)
60+
yield "rc-update del {0} {1}".format(service, runlevel)
6161
openrc_enabled[service] = False
6262
else:
6363
host.noop("service {0} is disabled".format(service))

tests/operations/openrc.service/disable.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
}
1717
},
1818
"commands": [
19-
"rc-update del nginx"
19+
"rc-update del nginx default"
2020
]
2121
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"args": ["nftables"],
3+
"kwargs": {
4+
"runlevel": "boot",
5+
"enabled": false
6+
},
7+
"facts": {
8+
"openrc.OpenrcStatus": {
9+
"runlevel=boot": {
10+
"nftables": true
11+
}
12+
},
13+
"openrc.OpenrcEnabled": {
14+
"runlevel=boot": {
15+
"nftables": true
16+
}
17+
}
18+
},
19+
"commands": [
20+
"rc-update del nftables boot"
21+
]
22+
}

tests/operations/openrc.service/enable.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
}
1717
},
1818
"commands": [
19-
"rc-update add nginx"
19+
"rc-update add nginx default"
2020
]
2121
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"args": ["nftables"],
3+
"kwargs": {
4+
"runlevel": "boot",
5+
"enabled": true
6+
},
7+
"facts": {
8+
"openrc.OpenrcStatus": {
9+
"runlevel=boot": {
10+
"nftables": true
11+
}
12+
},
13+
"openrc.OpenrcEnabled": {
14+
"runlevel=boot": {
15+
"nftables": false
16+
}
17+
}
18+
},
19+
"commands": [
20+
"rc-update add nftables boot"
21+
]
22+
}

0 commit comments

Comments
 (0)