-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
Fix: select systemd for ubuntu correctly #252
Conversation
Maybe we can simplify the logic a bit. We use camptocamp/systemd as a dependency, the module provides a fact. We probably should use this instead of parsing operatingsystem versions. |
I have done the code changes, and adjusted the tests. But i don't have a system with systemd to test it. so the facter part is solidly base on assumption of the input and output from facter. Need someone help evaluate that section |
The refactoring fail:
Feedback require |
@bastelfreak who is in charge for the development guideline within this repo? |
The voxpupuli team is. We define our guidelines in https://github.com/voxpupuli/modulesync_config and they apply to all modules in our namespace. I don't think that we should disable the quoted-boolean checks, bools shouldn't be quoted. I will test the code tomorrow on a systemd box. Facter on puppet3 is a bit painful because it doesn't know any datatypes except for strings :( |
@jk2l I tested the fact on a CentOS7 and an older Debian box. It correctly returns true/false, but as strings. We have two options here I think:
My personal preference is |
|
||
context 'On Ubuntu' do | ||
context 'trusty' do | ||
let :facts do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason we don't use rspec-facts here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would allow us to shorten the overhead. but then we need am itchy case block to mock the systemd fact depending on the OS :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only start involve with puppet and open source (only learned rspec last month), so i am still not familiar with the ruby and rspec (PHP background btw).
i can implement the changes, but it will be great if you can show me any reference or guideline that i can follow. as most of the stuff i pick up by reading the github source code directly (it is a bit hard to find the documentation on this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rspec-facts is a cool tool which parses the metadata.json and generates a hash of facts for each OS version in the metadata.json. I already implemented that for a few spec tests: https://github.com/voxpupuli/puppet-zabbix/blob/master/spec/classes/sender_spec.rb#L7-L13
you can always join the #voxpupuli IRC channel on freenode if you've question. direct chat will make it easier for both of us - we're always happy to help.
I never use IRC before. I just joined it but i am not sure did I do it right. it seem like a total empty channel |
anyway @bastelfreak i wonder would it be overkill or better if I move the init script section into seperate class and write a unit tests for that instead. which can get rid of duplicate codes in both agent and server section and also the init script coding is not really depends on other system facts. |
Finally figured out how to test between different systems and robocop. This should be the last patch |
} | ||
} else { | ||
|
||
if $::osfamily in ['Debian', 'RedHat'] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove that if? There are multiple other distributions that also ship systemd. the next if with any2bool() should be enough
I just realise the any2bool is only available on stdlib master branch. The puppet forge release does not have it yet. Using any2bool also need to move our dependency of stdlib from >= 4.4.0 to newer version that does not exist yet |
@bastelfreak Feedback require |
this may be the reason why the documentation for that is a bit low. I think this is the best function for our usecase. I will see if we can get a release of stdlib. |
* Changed to use $::systemd fact from systemd module * Merged and moved duplicate code from servers & agents into startup define
Patch for #240