Skip to content
Snippets Groups Projects
sync_scripts.pp 4.6 KiB
Newer Older
# Manage the sync scripts and their configurations.

Adam Lewenberg's avatar
Adam Lewenberg committed
# The reason that each one is selected seperately is that not all
# environments get the same sync scripts. While these are intended to be
# installed on the tools server, this class is still flexible enough to be
# used to install the scripts on an LDAP master.

# $ensure: set to 'absent' to remove ALL sync scripts. This parameter
# overrides all the other "enable_*" parameters; that is, if $ensure is
# set to 'absent', no matter what the $enable_* parameters are set to no
# sync scripts will be installed, and any that are present will be
# removed.

class su_ldap::sync_scripts (
Linda J Laubenheimer's avatar
Linda J Laubenheimer committed
  $env                                = undef,
Adam Lewenberg's avatar
Adam Lewenberg committed
  Enum['present', 'absent'] $ensure   = 'present',
  String                    $basedir  = '/etc/ldapadmin',
Adam Lewenberg's avatar
Adam Lewenberg committed
  #
  $ldap_master_fqdn                   = undef,
  #
  # select the sync scripts one-by-one in the hiera file
  $enable_ldap_wg_maint               = false,
  $enable_ldap_group_maint            = false,
  $enable_ldap_sync_sugal_attributes  = false,
  $enable_ldap_sync_suprivilegegroup  = false,
  $enable_ldap_alias_maint            = false,
  $enable_posix_account_sync          = false,
  $enable_ldap_reports                = false,
  Enum['present', 'absent'] $ensure_ldap_posix_group  = 'present',
Adam Lewenberg's avatar
Adam Lewenberg committed
  # We want a boolean version of $ensure.
  if ($ensure == 'present') {
    $ensure_b = true
  } else {
    $ensure_b = false
Adam Lewenberg's avatar
Adam Lewenberg committed
  # Set up the common components needed by all sync scripts.
  class { 'su_ldap::sync_scripts::common':
    ensure  => $ensure,
    env     => $env,
    basedir => $basedir,
Adam Lewenberg's avatar
Adam Lewenberg committed
  }
  # We need this below.
  $ticket_file_path = "/var/run/ldap-sync-$env.tkt"

Adam Lewenberg's avatar
Adam Lewenberg committed
  # We need to define some basic stuff first, then pass it to some of
  # the classes below.
Adam Lewenberg's avatar
Adam Lewenberg committed
      $lsdb_host    = 'lsdb.stanford.edu'
      $generate_gid = '0'
Adam Lewenberg's avatar
Adam Lewenberg committed
      $lsdb_host    = 'lsdb-$env.stanford.edu'
      $generate_gid = '1'
Adam Lewenberg's avatar
Adam Lewenberg committed

  # NOTE: The special function su_ldap::ensure_from_boolean used below
  # simply converts a boolean to an ensure string: true goes to
  # 'present', false goes to 'absent'. The code for this function is in
  # this module in lib/puppet/functions/su_ldap/ensure_from_boolean.rb.

  ## SYNC SERVICE: ldap-wg-maint
  class { 'su_ldap::sync_scripts::ldap_wg_maint':
Adam Lewenberg's avatar
Adam Lewenberg committed
    ensure  => su_ldap::ensure_from_boolean($enable_ldap_wg_maint and $ensure_b),
    env     => $env,
    basedir => $basedir,
Adam Lewenberg's avatar
Adam Lewenberg committed
    ldap_master_fqdn => $ldap_master_fqdn,
    ticket_file_path => $ticket_file_path,
Adam Lewenberg's avatar
Adam Lewenberg committed

  ## SYNC SERVICE: ldap-group-maint
  class { 'su_ldap::sync_scripts::ldap_group_maint':
Adam Lewenberg's avatar
Adam Lewenberg committed
    ensure  => su_ldap::ensure_from_boolean($enable_ldap_group_maint and $ensure_b),
    env     => $env,
    basedir => $basedir,
Adam Lewenberg's avatar
Adam Lewenberg committed
    ldap_master_fqdn => $ldap_master_fqdn,
    generate_gid     => $generate_gid,
Adam Lewenberg's avatar
Adam Lewenberg committed
  ## SYNC SRVICE: ldap-sync-sugal-attributes
  class { 'su_ldap::sync_scripts::ldap_sync_sugal_attributes':
    ensure  => su_ldap::ensure_from_boolean($enable_ldap_sync_sugal_attributes and $ensure_b),
    env     => $env,
    basedir => $basedir,
    ldap_master_fqdn => $ldap_master_fqdn,
  }
Adam Lewenberg's avatar
Adam Lewenberg committed

  ## SYNC SERVICE: ldap-sync-suprivilegegroup.service
  class { 'su_ldap::sync_scripts::ldap_sync_suprivilegegroup':
Adam Lewenberg's avatar
Adam Lewenberg committed
    ensure  => su_ldap::ensure_from_boolean($enable_ldap_sync_suprivilegegroup and $ensure_b),
    env     => $env,
    basedir => $basedir,
Adam Lewenberg's avatar
Adam Lewenberg committed
    ldap_master_fqdn => $ldap_master_fqdn,
Adam Lewenberg's avatar
Adam Lewenberg committed
  ## SYNC SERVICE: ldap-alias-maint
  class { 'su_ldap::sync_scripts::ldap_alias_maint':
Adam Lewenberg's avatar
Adam Lewenberg committed
    ensure  => su_ldap::ensure_from_boolean($enable_ldap_alias_maint and $ensure_b),
    env     => $env,
Adam Lewenberg's avatar
Adam Lewenberg committed
    ldap_master_fqdn => $ldap_master_fqdn,
Adam Lewenberg's avatar
Adam Lewenberg committed
  # posix accounts syncing
  $ensure_posix_account_sync = su_ldap::ensure_from_boolean($enable_posix_account_sync and $ensure_b)

  su_ldap::sync_scripts::posix_account_sync { 'aeroastroarl':
Adam Lewenberg's avatar
Adam Lewenberg committed
    ensure  => $ensure_posix_account_sync,
    env     => $env,
    basedir => $basedir,
Adam Lewenberg's avatar
Adam Lewenberg committed
  }
  su_ldap::sync_scripts::posix_account_sync { 'anesthesia':
Adam Lewenberg's avatar
Adam Lewenberg committed
    ensure  => $ensure_posix_account_sync,
    env     => $env,
    basedir => $basedir,
Adam Lewenberg's avatar
Adam Lewenberg committed
  }
  su_ldap::sync_scripts::posix_account_sync { 'statistics':
Adam Lewenberg's avatar
Adam Lewenberg committed
    ensure  => $ensure_posix_account_sync,
    env     => $env,
    basedir => $basedir,
Adam Lewenberg's avatar
Adam Lewenberg committed
  class { 'su_ldap::sync_scripts::ldap_reports':
    ensure    => su_ldap::ensure_from_boolean($enable_ldap_reports and $ensure_b),
    addresses => $addresses,
Adam Lewenberg's avatar
Adam Lewenberg committed
  ## Add another remctl driven sync
  # LDAP posixgroup (ldap-posix-group)
  class { 'su_ldap::ldapadmin::posixgroup':
    env     => $env,
    ensure  => $ensure_ldap_posix_group,
    basedir => $basedir,