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 new ini_section type #537

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Add new ini_section type #537

wants to merge 3 commits into from

Conversation

smortex
Copy link
Collaborator

@smortex smortex commented Apr 1, 2024

In order to explicitly manage sections of an ini file regardless of their content, we introduce a new ini_section type. This make it possible to remove a whole section of an ini file, regardless of its content:

ini_section { 'remove puppet.conf agent section':
  ensure  => abent,
  path    => '/etc/puppetlabs/puppet/puppet.conf',
  section => 'agent',
}

Just like the ini_setting type, ini_section can be subclassed:

puppet_config { 'remove agent section':
  ensure  => abent,
  section => 'agent',
}

Fixes #524

PR #532 introduced 4ebe030 which breaks
backwards compatibility and is part of a patch release, as reported here:
#532 (comment)

This reverts commit 4ebe030.

This will allow us to do a new patch release that fix the unexpected
backwards incompatible change, and leave the room to implement this as
part of a next major version of the module.
When the last setting of a section was removed, the whole section was
removed unless it contained white space of comments.  In #532, this was
changed to also remove sections that only contained space (blank lines),
but it caused regressions and was reverted in #535.

For consistency, we completely suppress the auto-removal of "empty"
sections: removing the last setting of a section will not remove this
section anymore, just like what happens for sections with only blank
lines and comments.
In order to explicitly manage sections of an ini file regardless of
their content, we introduce a new ini_section type.  This make it
possible to remove a whole section of an ini file, regardless of its
content:

```puppet
ini_section { 'remove puppet.conf agent section':
  ensure  => abent,
  path    => '/etc/puppetlabs/puppet/puppet.conf',
  section => 'agent',
}
```

Just like the ini_setting type, ini_section can be subclassed:

```puppet
puppet_config { 'remove agent section':
  ensure  => abent,
  section => 'agent',
}
```

Fixes #524
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.

Dangling section headers persist in INI files when sections contain whitespace
2 participants