Puppet Class: mongodb::repo::apt

Defined in:
manifests/repo/apt.pp

Summary

This is a repo class for apt

Overview

Parameters:

  • ensure (Enum['present', 'absent'])

    present or absent

  • repo_location (String[1])

    Location of the upstream repository

  • keyring_location (String[1])

    Location of the upstream keyring

  • release (Optional[String[1]]) (defaults to: undef)

    Specifies a distribution of the Apt repository.

  • repos (Optional[String[1]]) (defaults to: undef)

    Specifies a component of the Apt repository.

  • comment (Optional[String[1]]) (defaults to: undef)

    Supplies a comment for adding to the Apt source file.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'manifests/repo/apt.pp', line 23

class mongodb::repo::apt (
  Enum['present', 'absent'] $ensure,
  String[1] $repo_location,
  String[1] $keyring_location,
  Optional[String[1]] $release = undef,
  Optional[String[1]] $repos = undef,
  Optional[String[1]] $comment = undef,
) {
  # we try to follow/reproduce the instruction
  # from http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/

  assert_private()

  include apt

  $keyring_file = split($keyring_location, '/')[-1]
  apt::source { 'mongodb':
    ensure   => $ensure,
    location => $repo_location,
    release  => $mongodb::repo::release,
    repos    => $mongodb::repo::repos,
    key      => {
      dir    => '/usr/share/keyrings/',
      name   => "mongodb-${keyring_file}",
      source => $keyring_location,
    },
    comment  => $comment,
  }

  if($ensure == 'present') {
    Apt::Source['mongodb'] -> Class['apt::update'] -> Package<| tag == 'mongodb_package' |>
  }
}