puppetlabs / puppetlabs-apt

Puppet module to help manage Apt
https://forge.puppetlabs.com/puppetlabs/apt
Apache License 2.0
215 stars 462 forks source link

Unable to contain apt::update #1059

Open olavmo-sikt opened 1 year ago

olavmo-sikt commented 1 year ago

Use Case

I want a class that configures an APT repository to also ensure that apt-get update has run before any dependencies on that class. This way I can depend on the class that configures the repository without needing to know how this repository is configured. E.g.:

class mymod::repository {
  if $facts['os']['family'] == 'Debian' {
    apt::source { 'somerepo':
      ...
    }
    contain apt::update
  } else {...}
}

class mymod {
  require mymod::repository # Make sure that the repository is configured and available.
  package { 'somepackage':
    ensure => 'present',
  }
}

This is currently not possible by using contain apt::source because that class is private. Instead if fails with:

error during compilation: Evaluation Error: Error while evaluating a Function Call, Class apt::update is private

Describe the Solution You Would Like

Since the apt::update class is a documented part of this module, I think it could be marked as public. That would allow it to be used both through contain and through direct dependencies (require => Class['apt::update']).

Describe Alternatives You've Considered

Two alternatives:

  1. Using an anchor: `Class['apt::update'] -> anchor { 'mymod::repository::last' }'. The downside of this is that anchors are deprecated and no longer documented as part of containment.
  2. Directly depending on `Class['apt::update'] in the package resource. This only works if the repository configured is always an APT repository
github-actions[bot] commented 1 year ago

Hello! 👋

This issue has been open for a while and has had no recent activity. We've labelled it with attention-needed so that we can get a clear view of which issues need our attention.

If you are waiting on a response from us we will try and address your comments on a future Community Day.

Alternatively, if it is no longer relevant to you please close the issue with a comment.