Skip to content

Commit 26c14a6

Browse files
sengo4hdFizzadar
authored andcommitted
operations/openrc: log a noop message for enabled or disabled service
1 parent 61d83d2 commit 26c14a6

File tree

3 files changed

+53
-7
lines changed

3 files changed

+53
-7
lines changed

pyinfra/operations/openrc.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,16 @@ def service(
4848
openrc_enabled = host.get_fact(OpenrcEnabled, runlevel=runlevel)
4949
is_enabled = openrc_enabled.get(service, False)
5050

51-
if enabled and not is_enabled:
52-
yield "rc-update add {0}".format(service)
53-
openrc_enabled[service] = True
54-
55-
if not enabled and is_enabled:
56-
yield "rc-update del {0}".format(service)
57-
openrc_enabled[service] = False
51+
if enabled is True:
52+
if not is_enabled:
53+
yield "rc-update add {0}".format(service)
54+
openrc_enabled[service] = True
55+
else:
56+
host.noop("service {0} is enabled".format(service))
57+
58+
if enabled is False:
59+
if is_enabled:
60+
yield "rc-update del {0}".format(service)
61+
openrc_enabled[service] = False
62+
else:
63+
host.noop("service {0} is disabled".format(service))
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"args": ["nginx"],
3+
"kwargs": {
4+
"enabled": false
5+
},
6+
"facts": {
7+
"openrc.OpenrcStatus": {
8+
"runlevel=default": {
9+
"nginx": true
10+
}
11+
},
12+
"openrc.OpenrcEnabled": {
13+
"runlevel=default": {
14+
"nginx": false
15+
}
16+
}
17+
},
18+
"commands": [],
19+
"noop_description": "service nginx is disabled"
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"args": ["nginx"],
3+
"kwargs": {
4+
"enabled": true
5+
},
6+
"facts": {
7+
"openrc.OpenrcStatus": {
8+
"runlevel=default": {
9+
"nginx": true
10+
}
11+
},
12+
"openrc.OpenrcEnabled": {
13+
"runlevel=default": {
14+
"nginx": true
15+
}
16+
}
17+
},
18+
"commands": [],
19+
"noop_description": "service nginx is enabled"
20+
}

0 commit comments

Comments
 (0)