Skip to content

Unable to contain apt::update #1059

Open
@olavmo-sikt

Description

@olavmo-sikt

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions