Puppet Class: cassandra::datastax_repo

Defined in:
manifests/datastax_repo.pp

Overview

An optional class that will allow a suitable repository to be configured from which packages for DataStax Community can be downloaded. Changing the defaults will allow any Debian Apt or Red Hat Yum repository to be configured.

Parameters:

  • descr (string) (defaults to: 'DataStax 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: '7E41C00F85BFC1706C4FFFB3350200F2B999A372')

    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: 'http://debian.datastax.com/debian/repo_key')

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

  • pkg_url (string) (defaults to: undef)

    If left as the default, this will set the ‘baseurl` to ’rpm.datastax.com/community’ on a ‘yumrepo` resource on the Red Hat family. On the Debian family, leaving this as the default will set the `location` attribute on an `apt::source` to ’debian.datastax.com/community’.

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

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



22
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
# File 'manifests/datastax_repo.pp', line 22

class cassandra::datastax_repo (
  $descr   = 'DataStax Repo for Apache Cassandra',
  $key_id  = '7E41C00F85BFC1706C4FFFB3350200F2B999A372',
  $key_url = 'http://debian.datastax.com/debian/repo_key',
  $pkg_url = undef,
  $release = 'stable',
) {
  case $facts['os']['family'] {
    'RedHat': {
      if $pkg_url != undef {
        $baseurl = $pkg_url
      } else {
        $baseurl = 'http://rpm.datastax.com/community'
      }

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

      apt::key { 'datastaxkey':
        id     => $key_id,
        source => $key_url,
        before => Apt::Source['datastax'],
      }

      if $pkg_url != undef {
        $location = $pkg_url
      } else {
        $location = 'http://debian.datastax.com/community'
      }

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

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