Skip to content
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

Expose systemd service properties via .info #715

Merged
merged 1 commit into from
May 6, 2016

Conversation

alexpop
Copy link
Contributor

@alexpop alexpop commented May 6, 2016

Systemd has lots of properties that this PR is exposing now. Usage example:

describe service('sshd').info[:properties]['Restart'] do
  it { should cmp 'on-failure'  }
end

@alexpop alexpop added the Type: Enhancement Improves an existing feature label May 6, 2016
@chris-rock
Copy link
Contributor

This looks good @alexpop
Be aware, that the test, may crash if service('sshd').info[:properties]['Restart'] is not available. Therefore info is nil

@chris-rock chris-rock merged commit 8f6dbe4 into master May 6, 2016
@chris-rock chris-rock deleted the ap/systemd-properties branch May 6, 2016 11:45
@alexpop
Copy link
Contributor Author

alexpop commented May 6, 2016

For systemd, the service resource will still be instantiated, even for missing services:

inspec> service('BOGUSSSSSSSSS').info[:properties]['Restart']
=> "no"
inspec> service('BOGUSSSSSSSSS').info
=> {:name=>"BOGUSSSSSSSSS.service",
 :description=>"BOGUSSSSSSSSS.service",
 :installed=>false,
 :running=>false,
 :enabled=>false,
 :type=>"systemd",
 :properties=>
  {"Type"=>"",
   "Restart"=>"no",
   "PIDFile"=>"",
   "NotifyAccess"=>"none",

@arlimus
Copy link
Contributor

arlimus commented May 6, 2016

@alexpop To Chris' point, if these were to run on e.g. an old Debian system, where we are not based on Systemd, or if any of the calls don't get through, we will have info == nil.

@alexpop
Copy link
Contributor Author

alexpop commented May 6, 2016

Correct, but we only generate tests like that from SCAP systemdunitproperty_test resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Improves an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants