Skip to content

Default package_ensure value is not compatible with current stdlib default for ensure_packages() #1522

Closed
@varesa

Description

@varesa

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

include nginx
ensure_packages(['nginx'])

Note: while the above snippet alone doesn't make much sense to use, it's a reduction of a much more complex setup, where one type of call is used by one module and the other used by some other module.

What are you seeing

Error: Evaluation Error: Error while evaluating a Function Call, Duplicate declaration: Package[nginx] is already declared at (file: /home/varesa/test-modules/nginx/manifests/package/redhat.pp, line: 106); cannot redeclare (file: /home/varesa/test.pp, line: 2) (file: /home/varesa/test.pp, line: 2, column: 1) on node test-node

What behaviour did you expect instead

ensure_packages() does not fail.

Output log

Any additional information you'd like to impart

This is something that used to work, but the stdlib defaults changed somewhere between 7.1.0 and 8.5.0 from { 'ensure' => 'present' } to { 'ensure' => 'installed' }. This means that the default of $package_ensure = present does not deduplicate with ensure_packages() and causes a conflicting resource declaration.

While I believe this would also be a breaking change for the nginx-module for the very same reason, maybe in some future major release it'd be a good idea to align with the current stdlib default, causing less friction when used with ensure_packages()?

Of course, as of now, there is the workaround of either overriding the ensure-parameter, either in the nginx class declaration, or the ensure_packages call. Assuming that at least one of these is not inside some third party / vendor module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions