-
Notifications
You must be signed in to change notification settings - Fork 682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
systemd is-enabled check does not handle backcompat with sysv-init scripts (e.g. ntp on Ubuntu 16.04) #749
Comments
but 'fail2ban' and 'ssh' seem to work, so..... ??? |
So Ubuntu 16.04 should use systemd by default https://github.com/chef/inspec/blob/master/lib/resources/service.rb#L117-L121:
|
We also have a |
Do you use the systemd name for |
so there's no |
and i just tried this might help: # systemctl is-enabled ntp
ntp.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install is-enabled ntp
enabled |
probably a more accurate title based on the behavior i'm seeing... could be as simple as checking that the last line from stdout is "enabled" rather than checking if the output == "enabled"? |
Just a note that I'm seeing problems with |
Fixes #749 Signed-off-by: Steven Danna <[email protected]>
The output of `systemctl show SERVICENAME` can be misleading in the case of non-native services (i.e. services configured via an init script and integrated with systemd via a shim) or for more sophisticated unit times. For example, the UnitFileState of ntp is "bad": > systemctl show ntp | grep UnitFileState UnitFileState=bad Despite systemd reporting it as enabled: > systemctl is-enabled ntp ntp.service is not a native service, redirecting to systemd-sysv-install Executing /lib/systemd/systemd-sysv-install is-enabled ntp enabled Further, the old parsing code would have missed unit files in the following states that are technically enabled: enabled-runtime, indirect, generated, and transient Using the `is-enabled` commands ensures that we report the same enabled status that systemd reports, without having to update our own parsing in the event that new unit states are added. Further, it handles the sysv compatibility helper. Similarly, the is-active helper command ensures that we always report the same active/not-active status as systemd would natively. For instance, a quick reading of `src/systemctl/systemctl.c` in the systemd source shows that systemctl reports units as active if they are in the state `UNIT_ACTIVE` or `UNIT_RELOADING`. Fixes #749 Signed-off-by: Steven Danna <[email protected]>
The output of `systemctl show SERVICENAME` can be misleading in the case of non-native services (i.e. services configured via an init script and integrated with systemd via a shim) or for more sophisticated unit types. For example, the UnitFileState of ntp is "bad": > systemctl show ntp | grep UnitFileState UnitFileState=bad despite systemd reporting it as enabled: > systemctl is-enabled ntp ntp.service is not a native service, redirecting to systemd-sysv-install Executing /lib/systemd/systemd-sysv-install is-enabled ntp enabled Further, the old parsing code would have missed unit files in the following states that are technically enabled: enabled-runtime, indirect, generated, and transient Using the `is-enabled` commands ensures that we report the same enabled status that systemd reports, without having to update our own parsing in the event that new unit states are added. Additionally, as shown above, it handles the sysv compatibility helper. Similarly, the is-active helper command ensures that we always report the same active/not-active status as systemd would natively. For instance, a quick reading of `src/systemctl/systemctl.c` in the systemd source shows that systemctl reports units as active if they are in the state `UNIT_ACTIVE` or `UNIT_RELOADING`. Fixes #749 Signed-off-by: Steven Danna <[email protected]>
Description
False failure for ntp and nscd services being enabled.
InSpec and Platform Version
Ubuntu 16.04
inspec (0.20.1)
kitchen-inspec (0.12.5)
Replication Case
Possible Solutions
Stacktrace
The text was updated successfully, but these errors were encountered: