Skip to content
Snippets Groups Projects
ldap_sync_sugal_attributes.pp 2.4 KiB
Newer Older
# Configure this server to sync the suGAL person attributes using the
# the ldap-sync-sugal-attributes script.
#
# See also https://ikiwiki.stanford.edu/service/ldap/sync-scripts/

class s_ldap::base::syncs::ldap_sync_sugal_attributes  (
  $ensure       = undef,
){

 # Do we want the service to be running or stopped?
  if ($ensure == 'present') {
    $service_status = 'running'
  } elsif ($ensure == 'absent') {
    $service_status = 'stopped'
  } else {
    fail("ensure must be one 'present' or 'absent'")
  }

  # Load the package containing the ldap-sync-sugal-attributes script.
  package { 'libstanford-directory-sync-sugal-perl':
    ensure  => installed,
    require => Package['slapd'],
  }

  # Install the configuration file for the listener
  file { '/etc/ldapadmin/ldap-sync-sugal-attributes-daemon.conf':
    content => template('s_ldap/etc/ldapadmin/ldap-sync-sugal-attributes-daemon.conf.erb'),
    require => File['/etc/ldapadmin'],
  }

  # Install the configuration file for the NON-listener
  file { '/etc/ldapadmin/ldap-sync-sugal-attributes.conf':
    content => template('s_ldap/etc/ldapadmin/ldap-sync-sugal-attributes.conf.erb'),
    require => File['/etc/ldapadmin'],
  }

  # Install the visibility attributes mapping file.
  file { '/etc/ldapadmin/sugal-visibility.yaml':
    source  => 'puppet:///modules/s_ldap/etc/ldapadmin/sugal-visibility.yaml',
    require => File['/etc/ldapadmin'],
  }

  # Need a cron job to run the sync job against ALL the entries once per
  # day.
  file { '/etc/cron.d/ldap-sync-sugal-attributes':
    ensure  => $ensure,
    mode    => '0644',
    source => 'puppet:///modules/s_ldap/etc/cron.d/ldap-sync-sugal-attributes',
    require => File['/etc/ldapadmin/ldap-sync-sugal-attributes.conf'],
  }

  ## Service (listener)
  include s_ldap::base::systemd

  # We want to reload the systemd daemon on any change to the unit
  # file. We use the systemd shared library's systemd-daemon-reload to
  # do this.
  file { '/lib/systemd/system/ldap-sync-sugal-attributes.service':
    ensure => present,
    source => 'puppet:///modules/s_ldap/lib/systemd/system/ldap-sync-sugal-attributes.service',
    mode   => '0644',
    notify => Exec['systemd-daemon-reload']
  }

  service { 'ldap-sync-sugal-attributes':
    ensure  => $service_status,
    require => [
      File['/lib/systemd/system/ldap-sync-sugal-attributes.service'],
      Package['libstanford-directory-sync-sugal-perl'],
    ],
  }

}