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

Add RedHat init script #43

Merged
merged 4 commits into from
Apr 5, 2019
Merged

Conversation

kBite
Copy link
Contributor

@kBite kBite commented Apr 3, 2019

OS like CentOS 6 are missing an init script for ferm. This PR ...

  • adds an init script inspired by Kellermann's script for Debian and
  • adds a test for RedHat-like OS to contain this init script


case $facts['os']['family'] {
'RedHat': {
if scanf($facts['os']['release']['major'], '%i')[0] <= 6 {
Copy link
Member

Choose a reason for hiding this comment

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

interesting to use scanf() and not versioncmp(). The latter is more common, but scanf is cooler. 👍

Copy link
Member

Choose a reason for hiding this comment

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

Could we go with versioncmp though? :)

A single if instead of a case and an if would probably be simpler too.

case $facts['os']['family'] {
'RedHat': {
if scanf($facts['os']['release']['major'], '%i')[0] <= 6 {
file{'/etc/init.d/ferm':
Copy link
Member

Choose a reason for hiding this comment

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

could you create a new parameter like $manage_initfile or something like that? The file isn't in the official rpm, so people might already have a custom script inplace that we overwrite. So we should only deploy the file, if a user explicitly requests it. Otherwise the next release needs to be a major one instead a minor one.

@bastelfreak bastelfreak added enhancement New feature or request needs-work not ready to merge just yet labels Apr 4, 2019
@bastelfreak
Copy link
Member

Hi @kBite, thanks for the PR. Can you probably fix the rubocop warnings by doing this:

bundle install --path .vendor/ --without development system_tests #installs required gems
bundle exec rake rubocop:auto_correct # runs the ruby linter + tries to fix things

@@ -22,6 +22,9 @@
it { is_expected.to contain_file('/etc/ferm.d/chains') }
it { is_expected.not_to contain_service('ferm') }
it { is_expected.not_to contain_file('/etc/ferm.conf') }
if facts[:os]['family'] == 'RedHat' and facts[:os]['release']['major'].to_i <= 6
Copy link
Member

Choose a reason for hiding this comment

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

@kBite Please use && instead of and to fix the RuboCop issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dhoppe Done. Please see my updated commits.

Copy link
Member

Choose a reason for hiding this comment

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

Looks good. Thank you very much for your contribution.

@kBite
Copy link
Contributor Author

kBite commented Apr 5, 2019

Force pushed updated commits:

  • uses versioncmp in a single if statement
  • adds $manage_initfile (default false) so existing deployments won't be affected
  • replaces and with &&
  • updates test accordingly

@kBite kBite changed the title Add RedHat init script [WIP] Add RedHat init script Apr 5, 2019
@kBite kBite changed the title [WIP] Add RedHat init script Add RedHat init script Apr 5, 2019
@dhoppe dhoppe removed needs-work not ready to merge just yet tests-fail labels Apr 5, 2019
@dhoppe dhoppe merged commit c90a142 into voxpupuli:master Apr 5, 2019
@kBite kBite deleted the add-redhat-init-script branch April 28, 2021 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants