Skip to content

apt::mark with setting auto is not idempotent #1226

@FrankVanDamme

Description

@FrankVanDamme

Describe the Bug

apt::mark with setting "auto" will execute every run

apt::mark { 'lib1':
setting => auto,
}

The behaviour is quite similar to #1166.

Expected Behavior

To mark a package as automatic if it is installed and not marked as automatic.

Environment

  • puppetlabs-apt v10.0.0;
  • Debian 11 or 12

Additional Context

The main issue I believe is that the module tries to mark packages as auto that are not installed. What happens in that case:

  • the package will not show up in the output of "apt-mark showauto", since non-installed packages can't be marked
  • the onlyif setting wil always return true: "dpkg -l " will show that the package is uninstalled, but that doesn't mean it returns non-zero exit status. It only does so if the package doesn't exist in the sources.
    https://github.com/puppetlabs/puppetlabs-apt/blob/v10.0.1/manifests/mark.pp#L29

Suggest changing the check to something like:

$onlyif_cmd = ["/usr/bin/dpkg -l $title | grep '^ii '" ]

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