Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pytest -m end_to_end_docker

## Documentation

Documentation changes should be made in the [pyinfra git repository](https://github.com/pyinfra-dev/pyinfa) - the repository `docs.pyinfra.com` should
Documentation changes should be made in the [pyinfra git repository](https://github.com/pyinfra-dev/pyinfra) - the repository `docs.pyinfra.com` should
not be changed, it contains build artifacts.

### Generate Documentation
Expand Down
20 changes: 13 additions & 7 deletions pyinfra/operations/openrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,16 @@ def service(
openrc_enabled = host.get_fact(OpenrcEnabled, runlevel=runlevel)
is_enabled = openrc_enabled.get(service, False)

if enabled and not is_enabled:
yield "rc-update add {0}".format(service)
openrc_enabled[service] = True

if not enabled and is_enabled:
yield "rc-update del {0}".format(service)
openrc_enabled[service] = False
if enabled is True:
if not is_enabled:
yield "rc-update add {0} {1}".format(service, runlevel)
openrc_enabled[service] = True
else:
host.noop("service {0} is enabled".format(service))

if enabled is False:
if is_enabled:
yield "rc-update del {0} {1}".format(service, runlevel)
openrc_enabled[service] = False
else:
host.noop("service {0} is disabled".format(service))
2 changes: 1 addition & 1 deletion tests/operations/openrc.service/disable.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
}
},
"commands": [
"rc-update del nginx"
"rc-update del nginx default"
]
}
20 changes: 20 additions & 0 deletions tests/operations/openrc.service/disable_noop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"args": ["nginx"],
"kwargs": {
"enabled": false
},
"facts": {
"openrc.OpenrcStatus": {
"runlevel=default": {
"nginx": true
}
},
"openrc.OpenrcEnabled": {
"runlevel=default": {
"nginx": false
}
}
},
"commands": [],
"noop_description": "service nginx is disabled"
}
22 changes: 22 additions & 0 deletions tests/operations/openrc.service/disable_runlevel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"args": ["nftables"],
"kwargs": {
"runlevel": "boot",
"enabled": false
},
"facts": {
"openrc.OpenrcStatus": {
"runlevel=boot": {
"nftables": true
}
},
"openrc.OpenrcEnabled": {
"runlevel=boot": {
"nftables": true
}
}
},
"commands": [
"rc-update del nftables boot"
]
}
2 changes: 1 addition & 1 deletion tests/operations/openrc.service/enable.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
}
},
"commands": [
"rc-update add nginx"
"rc-update add nginx default"
]
}
20 changes: 20 additions & 0 deletions tests/operations/openrc.service/enable_noop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"args": ["nginx"],
"kwargs": {
"enabled": true
},
"facts": {
"openrc.OpenrcStatus": {
"runlevel=default": {
"nginx": true
}
},
"openrc.OpenrcEnabled": {
"runlevel=default": {
"nginx": true
}
}
},
"commands": [],
"noop_description": "service nginx is enabled"
}
22 changes: 22 additions & 0 deletions tests/operations/openrc.service/enable_runlevel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"args": ["nftables"],
"kwargs": {
"runlevel": "boot",
"enabled": true
},
"facts": {
"openrc.OpenrcStatus": {
"runlevel=boot": {
"nftables": true
}
},
"openrc.OpenrcEnabled": {
"runlevel=boot": {
"nftables": false
}
}
},
"commands": [
"rc-update add nftables boot"
]
}