Skip to content
Snippets Groups Projects
apt_setup.pp 1.8 KiB
Newer Older
Adam Lewenberg's avatar
Adam Lewenberg committed
# Set up apt to get the correct Debian packages.
#
# $distribution: A valid Debian distribution. This can
#   be the usual ones, such as "jessie", "stretch", "buster", "sid".
#   It can also be one of the stanford special ones, e.g.,
#   "stretch-acs-dev", "stretch-acs-prod", etc.
#
# $repository: If the package is found in a non-standard location,
#   you can indicate the repository here. Note that the repositories
#     - http://debian.stanford.edu/debian-local
#     - http://debian.stanford.edu/debian-stanford
#   should already be convered and are considerd standard locations.
#
#  #########
#  Example 1
#
#  class {'su_ldap::openldap_install':
#    distribution => 'stretch'
#  }
#
#  This will install the stock OpenLDAP packages from the stretch distribution.
#
#
#  #########
#  Example 2:
#
#  class {'su_ldap::openldap_install':
#    distribution => 'stretch-acs-dev'
#  }
#
# This will install the OpenLDAP packages from the special stretch-acs-dev
# distribution that resides in the "stanford" repository.


class su_ldap::apt_setup (
Adam Lewenberg's avatar
Adam Lewenberg committed
  $debian_distribution = undef,
  $debian_repository   = undef,
Adam Lewenberg's avatar
Adam Lewenberg committed
) {

  # Only need to do something if $distribution is defined.

  if ($distribution) {
    # If $repository is defined, we need to add a file in
    # /etc/apt/sources.list.d.
    if ($repository) {
      file { '/etc/apt/sources.list.d/ldap.list':
        content => template('su_ldap/etc/apt/sources.list.d/ldap.erb')
      }
    }

    # Pin some OpenLDAP packages.
    file { '/etc/apt/preferences.d/ldap':
      content => template('su_ldap/etc/apt/preferences.d/ldap.erb'),
      notify  => Exec['ldap aptitude update'];
    }

    # Update aptitude.
    exec { 'ldap aptitude update':
      path        => '/usr/bin:/usr/sbin:/bin',
      command     => 'aptitude update',
      refreshonly => true,
    }
  }
}