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

Allow to set a header to the beginning of a configuration file #486

Open
zilchms opened this issue Sep 21, 2022 · 0 comments
Open

Allow to set a header to the beginning of a configuration file #486

zilchms opened this issue Sep 21, 2022 · 0 comments

Comments

@zilchms
Copy link

zilchms commented Sep 21, 2022

Use Case

I am trying to set the contents of a config file in a custom module utilizing the functionality this module provides. In order to be able to see directly what configuration file are written by puppet, I usually put a header such as #managed by puppet on the first line of the configuration file.

Describe the Solution You Would Like

I would like to have a header ini_setting that allows me to set this comment on the beginning of a file.
So that it looks like this or something similar:

# managed by puppet

[section 1]
....

Describe Alternatives You've Considered

I tried so manually do this with:

  ini_setting {"comment":
    path    => '/path/to/configuration.conf',
    section => 'Managed by Puppet',
    section_prefix => '#',
    section_suffix => '',
  }

In addition to using the inifile::create_ini_settings I use for actually writing the rest of the configuration file.
However this does put the comment in the beginning of the file. Rather it always puts the comment on the last line (which is not really helping when considering long configuration files.)
This behaviour seems independent of the positioning of the comment-ini_setting in the code (bevore or after using the function)
Additionally this brakes idempotency in the latest puppetforge version, as fixed by #483 (is there a release planned in the near future to push this change?)

Additional Context

I guess this touches a bit on #72, but as this was never resolved I wanted to reopen the discussion.
I am not sure how I would be able to influence the order of the sections.
I did look into implementing child providers. I guess my solution is somewhere there? But then we maybe can improve the documentation with a working example of such a use case? I would guess I am not the only one who would appreciate the possibility to provide a header :)
Let me know your thoughts on this :)

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

No branches or pull requests

3 participants