Puppet Class: cassandra::apache_repo

Defined in:
manifests/apache_repo.pp

Overview

An optional class that will allow a suitable repository to be configured from which packages for Apache Cassandra can be downloaded.

Parameters:

  • descr (string) (defaults to: 'Repo for Apache Cassandra')

    On the Red Hat family, this is passed as the ‘descr` attribute to a `yumrepo` resource. On the Debian family, it is passed as the `comment` attribute to an `apt::source` resource.

  • key_id (string) (defaults to: 'A26E528B271F19B9E5D8E19EA278B781FE4B2BDA')

    On the Debian family, this is passed as the ‘id` attribute to an `apt::key` resource. On the Red Hat family, it is ignored.

  • key_url (string) (defaults to: 'https://www.apache.org/dist/cassandra/KEYS')

    On the Debian family, this is passed as the ‘source` attribute to an `apt::key` resource. On the Red Hat family, it is set to the `gpgkey` attribute on the `yumrepo` resource.

  • pkg_url (string) (defaults to: undef)

    On the Red Hat family, leaving this as default will set the ‘baseurl` on the `yumrepo` resource to ’www.apache.org/dist/cassandra/redhat’ with whatever is set in the ‘release’ attribute appended. On the Debian family, leaving this as the default will set the ‘location` attribute on an `apt::source` to ’www.apache.org/dist/cassandra/debian’.

  • release (string) (defaults to: 'main')

    On the Debian family, this is passed as the ‘release` attribute to an `apt::source` resource. On the Red Hat family, it is the major version number of Cassandra, without dot, and with an appended ’x’ (e.g. ‘311x’)



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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'manifests/apache_repo.pp', line 23

class cassandra::apache_repo (
  $descr   = 'Repo for Apache Cassandra',
  $key_id  = 'A26E528B271F19B9E5D8E19EA278B781FE4B2BDA',
  $key_url = 'https://www.apache.org/dist/cassandra/KEYS',
  $pkg_url = undef,
  $release = 'main',
) {
  case $facts['os']['family'] {
    'RedHat': {
      if $pkg_url != undef {
        $baseurl = $pkg_url
      } else {
        $url = 'http://www.apache.org/dist/cassandra/redhat'
        $baseurl = "${url}/${release}"
      }

      yumrepo { 'cassandra_apache':
        ensure   => present,
        descr    => $descr,
        baseurl  => $baseurl,
        enabled  => 1,
        gpgcheck => 1,
        gpgkey   => $key_url,
      }
    }
    'Debian': {
      include apt
      include apt::update

      apt::key { 'apache.cassandra':
        id     => $key_id,
        source => $key_url,
        before => Apt::Source['cassandra.sources'],
      }

      if $pkg_url != undef {
        $location = $pkg_url
      } else {
        $location = 'http://www.apache.org/dist/cassandra/debian'
      }

      apt::source { 'cassandra.sources':
        location => $location,
        comment  => $descr,
        release  => $release,
        include  => {
          'src' => false,
        },
        notify   => Exec['update-apache-cassandra-repo'],
      }

      # Required to wrap apt_update
      exec { 'update-apache-cassandra-repo':
        refreshonly => true,
        command     => '/bin/true',
        require     => Exec['apt_update'],
      }
    }
    default: {
      warning("OS family ${facts['os']['family']} not supported")
    }
  }
}