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

Ensure config file ends with a new line #707

Merged
merged 1 commit into from
Oct 24, 2019

Conversation

baurmatt
Copy link
Contributor

@baurmatt baurmatt commented Oct 4, 2019

The puppet.conf file doesn't end with a newline which makes it hard to cat. This ensure that the file will end with a newline.

@ekohl
Copy link
Member

ekohl commented Oct 23, 2019

Last time I tried this, it didn't do what I wanted. From the reference:

ensure_newline
Specifies whether to add a line break at the end of each fragment that doesn't already end in one.

We also add newlines in places and this resulted in a hard to read file. Is this still the case?

@baurmatt
Copy link
Contributor Author

Ha, right! :) puppet::config::entry adds a newline at the beginning of the fragment and the ensure_newline parameter function only checks (and adds) newlines at the end. I've fixed it and the diff now looks good:

Notice: /Stage[main]/Puppet::Config/Concat[/etc/puppetlabs/puppet/puppet.conf]/File[/etc/puppetlabs/puppet/puppet.conf]/content:
--- /etc/puppetlabs/puppet/puppet.conf	2019-04-23 09:19:27.831205678 +0200
+++ /tmp/puppet-file20191024-11597-17womp5	2019-10-24 09:48:23.947771487 +0200
@@ -1,5 +1,4 @@

-
 [main]
     certname = test1234
     codedir = /etc/puppetlabs/code
@@ -27,4 +26,4 @@
     runinterval = 1800
     splay = false
     splaylimit = 1800
-    usecacheonfailure = true
\ No newline at end of file
+    usecacheonfailure = true

Notice: /Stage[main]/Puppet::Config/Concat[/etc/puppetlabs/puppet/puppet.conf]/File[/etc/puppetlabs/puppet/puppet.conf]/content: current_value '{md5}80c36d9d03e380e9db04d16088aa31c8', should be '{md5}5ee4e42185caa115c3ddd0ba2d022dba' (noop)

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Confirmed this fixes it and is much cleaner

@ekohl ekohl merged commit e87d8f2 into theforeman:master Oct 24, 2019
@alexjfisher
Copy link
Contributor

I remember @bastelfreak trying to make a similar change and us deciding that it wasn't this easy.

puppet::config::entry {'example_setting 1':
    key     => 'example_setting',
    value   => '1',
    section => 'example_section',
  }
puppet::config::entry {'example_setting 2':
    key     => 'example_setting',
    value   => '2',
    section => 'example_section',
}

would have previously generated...

[example_section]
    example_setting = 1,2

now it generates

[example_section]
    example_setting = 1
,2

@@ -39,7 +39,7 @@
if (!defined(Concat::Fragment["puppet.conf_${section}_${key}"])){
concat::fragment{"puppet.conf_${section}_${key}":
Copy link
Contributor

Choose a reason for hiding this comment

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

This fragment will always get a newline now. This breaks adding multiple values to the same key via different instances of puppet::config::entry (the resources added in the else below).

@alexjfisher
Copy link
Contributor

@baurmatt
Copy link
Contributor Author

Adding multiple values to the same key with different puppet::config::entry's doesn't sound like an indented feature to be honest.

@alexjfisher
Copy link
Contributor

alexjfisher commented Oct 28, 2019

It looks very deliberate to me. The fragment in the else would never trigger otherwise (and the comments say this is how it works). On the other hand, I wouldn't be that surprised if the feature had no users?? Ripping it out might be an option and I think would be preferable to leaving it in but broken.

@baurmatt
Copy link
Contributor Author

Right! :( Removing it does indeed sound like a better option than just leaving it in.

@ekohl What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants