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

Fix: select systemd for ubuntu correctly #252

Merged
merged 1 commit into from
Jul 29, 2016
Merged

Conversation

jk2l
Copy link
Contributor

@jk2l jk2l commented Jul 22, 2016

Patch for #240

@jk2l jk2l mentioned this pull request Jul 22, 2016
2 tasks
@bastelfreak
Copy link
Member

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.

@jk2l
Copy link
Contributor Author

jk2l commented Jul 22, 2016

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

@jk2l jk2l changed the title Fix: select systemd for ubuntu correctly (DO NOT MERGE) Fix: select systemd for ubuntu correctly Jul 22, 2016
@jk2l
Copy link
Contributor Author

jk2l commented Jul 22, 2016

The refactoring fail:

  • First refactoring patch is correct but failed for having quoted boolean word. Maybe we should add puppet-lint skip quoted boolean check?
  • Second refactoring failed when run on my server. The facter $::systemd give me 'false' as string which evaluated as true

Feedback require

@jk2l
Copy link
Contributor Author

jk2l commented Jul 22, 2016

@bastelfreak who is in charge for the development guideline within this repo?

@bastelfreak
Copy link
Member

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 :(

@bastelfreak
Copy link
Member

@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:

  • Compare the result from $::systemd as strings
  • cast the string into a bool with any2bool

My personal preference is any2bool. Then we should be save even when facter will return the correct datatype.


context 'On Ubuntu' do
context 'trusty' do
let :facts do
Copy link
Contributor

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?

Copy link
Member

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 :(

Copy link
Contributor Author

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)

Copy link
Member

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.

@jk2l
Copy link
Contributor Author

jk2l commented Jul 24, 2016

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

@jk2l
Copy link
Contributor Author

jk2l commented Jul 24, 2016

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.

@jk2l jk2l changed the title (DO NOT MERGE) Fix: select systemd for ubuntu correctly (Pending Code Review) Fix: select systemd for ubuntu correctly Jul 25, 2016
@jk2l
Copy link
Contributor Author

jk2l commented Jul 25, 2016

Finally figured out how to test between different systems and robocop. This should be the last patch

}
} else {

if $::osfamily in ['Debian', 'RedHat'] {
Copy link
Member

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

@jk2l jk2l changed the title (Pending Code Review) Fix: select systemd for ubuntu correctly (DO NOT MERGE) Fix: select systemd for ubuntu correctly Jul 26, 2016
@jk2l
Copy link
Contributor Author

jk2l commented Jul 26, 2016

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

@jk2l
Copy link
Contributor Author

jk2l commented Jul 26, 2016

@bastelfreak Feedback require

@bastelfreak
Copy link
Member

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
@jk2l jk2l changed the title (DO NOT MERGE) Fix: select systemd for ubuntu correctly (Pending Code Review) Fix: select systemd for ubuntu correctly Jul 29, 2016
@bastelfreak bastelfreak changed the title (Pending Code Review) Fix: select systemd for ubuntu correctly Fix: select systemd for ubuntu correctly Jul 29, 2016
@bastelfreak bastelfreak merged commit 9e0f784 into voxpupuli:master Jul 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants