Skip to content
Snippets Groups Projects
apt_setup.pp 1.94 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.
#
Adam Lewenberg's avatar
Adam Lewenberg committed
# IMPORTANT! This class assumes that the APT sources list file is already
# present
Adam Lewenberg's avatar
Adam Lewenberg committed
#
#  #########
#  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,
Adam Lewenberg's avatar
Adam Lewenberg committed
  $debian_archive      = 'debian-stanford',
Adam Lewenberg's avatar
Adam Lewenberg committed
  $debian_repository   = undef,
Adam Lewenberg's avatar
Adam Lewenberg committed
  # Only need to do something if $debian_distribution is defined.
Adam Lewenberg's avatar
Adam Lewenberg committed
  if ($debian_distribution != undef) {

    # If the debian_distribution is "special" (e.g., not one of the normal ones like
    # the current codename), then we need to create an apt source list file.
    if ($debian_distribution != $facts['os']['distro']['codename']) {
      su_apt::source { $debian_distribution:
        comment      => 'Special sources.list.d file for OpenLDAP',
        archive      => $debian_archive,
        distribution => $debian_distribution,
        repository   => $debian_repository,
        notify       => Exec['ldap_aptitude_update'];
Adam Lewenberg's avatar
Adam Lewenberg committed
      }
    }

    # Pin some OpenLDAP packages.
    file { '/etc/apt/preferences.d/ldap':
      content => template('su_ldap/etc/apt/preferences.d/ldap.erb'),
Adam Lewenberg's avatar
Adam Lewenberg committed
      notify  => Exec['ldap_aptitude_update'];
Adam Lewenberg's avatar
Adam Lewenberg committed
    }

    # Update aptitude.
Adam Lewenberg's avatar
Adam Lewenberg committed
    exec { 'ldap_aptitude_update':
Adam Lewenberg's avatar
Adam Lewenberg committed
      path        => '/usr/bin:/usr/sbin:/bin',
      command     => 'aptitude update',
      refreshonly => true,
    }
  }
}