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

(FACT-852) Support for systemd and systemd_version #871

Closed
wants to merge 1 commit into from

Conversation

Spredzy
Copy link

@Spredzy Spredzy commented Mar 12, 2015

This commit adds support for systemd and systemd_version facts.

end

Facter.add(:systemd_version) do
confine :kernel => :linux
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this additionally be confined to :systemd => true?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daenney you're right. Fixed.

This commit adds support for systemd and systemd_version facts.
@puppetcla
Copy link

CLA signed by all contributors.

init_process_name = Facter::Core::Execution.exec('ps -p 1 -o comm=')
if init_process_name.eql? 'systemd'
result = true
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you just want to do:

setcode do
   ...
   init_process_name == 'systemd'
end

In other words, the value of the fact should be the last value of the setcode block. If you're on a systemd system, then the last value is true due to evaluating result = true, e.g.

irb(main):001:0> result = true
=> true

If you're not on systemd, then the value is actually coming from the if check:

irb(main):002:0> if 1 == 2
irb(main):003:1> end
=> nil

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, wouldn't we want this instead?

setcode do
  if Facter::Core::Execution.exec('ps -p 1 -o comm=').eql? 'systemd'
    true
  else
    false
  end
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or just

setcode do
  Facter::Core::Execution.exec('ps -p 1 -o comm=') == 'systemd'
end

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good point!

@melissa
Copy link

melissa commented Mar 12, 2015

Thanks for the contribution!

However, we likely aren't going to do any more releases from the master branch of facter. This looks like work that should be targeted at Facter 3, our native implementation in C++. @MikaelSmith do you have any input on this?

Backstory: https://groups.google.com/forum/#!msg/puppet-dev/tBqHZB9M308/QqdaldMsJlkJ

@MikaelSmith
Copy link

Yes, this will need an additional ticket to cover Facter 3.

@MikaelSmith
Copy link

We plan to make that more obvious soon by moving the Facter 3 codebase to facter#master.

@kylog
Copy link

kylog commented Mar 12, 2015

Agreed. I'd target this at Facter 3. And yes, the codebase move will make this all more obvious. Coming soon!

For backstory: https://groups.google.com/forum/#!msg/puppet-dev/tBqHZB9M308/QqdaldMsJlkJ

@kylog
Copy link

kylog commented Mar 12, 2015

One other thing: I'd add these two facts as a single new structured fact.

@daenney
Copy link

daenney commented Mar 12, 2015

How would you name it then though? One is binary, one is data:

systemd { active => true, version => $version }

It feels awkward.

@kylog
Copy link

kylog commented Mar 12, 2015

Hmm, well, naming is hard, but:

systemd { active => true, version => 212 }

actually makes sense to me. And then in code you could reference:

systemd[active]
systemd[version]

Although ... would it be worth generalizing it to service_managers or some such? That feels like an awkward name, but would allow sth like:

if service_manager[type] == 'systemd' ....

@daenney
Copy link

daenney commented Mar 13, 2015

init_system?

@branan
Copy link

branan commented Mar 18, 2015

Per the existing discussion on this ticket and the concensus in the PR triage discussion meeting, I'm going to close this. New features should be targeted at cfacter as we get ready to release facter 3.

@melissa
Copy link

melissa commented Mar 25, 2015

Just an update to this, we moved the CFacter code into the facter/master branch. So this work should be targeted there.

@melissa melissa added the triaged Jira issue has been created for this label Mar 25, 2015
roidelapluie added a commit to roidelapluie/puppet-systemd that referenced this pull request Feb 19, 2016
cegeka-jenkins pushed a commit to cegeka/puppet-systemd that referenced this pull request Aug 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged Jira issue has been created for this
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants