Skip to content
Snippets Groups Projects
tal_cli.pp 2.5 KiB
Newer Older
  • Learn to ignore specific revisions
  • # @summary
    
    #   Command-line interface to TAL.
    
    #   Clones and compiles repo to provide TAL access.
    
    #
    #
    # @param credentials
    
    #   Credentials for TAL access.
    
    Mika Perälä's avatar
    Mika Perälä committed
    class aes::tal_cli (
    
    Filip Strömbäck's avatar
    Filip Strömbäck committed
      Optional[String] $credentials = undef
    ) {
      file { '/home/examadm/tal-cli' :
        ensure => directory,
        owner  => examadm,
        group  => examadm,
        mode   => '0700',
    
      }
    
      file { '/home/examadm/bin/tal-cli' :
        ensure => file,
        owner  => examadm,
        group  => examadm,
    
        mode   => '0755',
    
    Filip Strömbäck's avatar
    Filip Strömbäck committed
        source => "puppet:///modules/${module_name}/tal/tal-cli",
      }
    
    
      file { '/home/examadm/bin/tal-export' :
        ensure => file,
        owner  => examadm,
        group  => examadm,
        mode   => '0755',
        source => "puppet:///modules/${module_name}/tal/tal-export",
      }
    
    
    Filip Strömbäck's avatar
    Filip Strömbäck committed
      file { '/home/examadm/tal-cli/.tal' :
        ensure  => file,
        owner   => examadm,
        group   => examadm,
    
        mode    => '0600',
    
    Filip Strömbäck's avatar
    Filip Strömbäck committed
        content => $credentials,
      }
    
      file { '/home/examadm/tal-cli/on_update.sh' :
        ensure => file,
        owner  => examadm,
        group  => examadm,
        mode   => '0700',
        source => "puppet:///modules/${module_name}/tal/on_update.sh",
      }
    
    
      vcsrepo { '/home/examadm/tal-cli/source':
        submodules  => false,
    
        ensure      => latest,
        provider    => git,
        source      => 'https://oauth2:glpat-bfpVssm_zFmt1YRW7cLz@gitlab.liu.se/upp-aes/tal-cli.git',
        revision    => master,
        owner       => examadm,
        group       => examadm,
        notify      => Exec['compile-tal-repo'],
    
      }
    
      exec { 'compile-tal-repo':
    
    Filip Strömbäck's avatar
    Filip Strömbäck committed
        user        => examadm,
        group       => examadm,
        cwd         => '/home/examadm/tal-cli',
    
        path        => '/bin:/usr/bin',
        environment => ['HOME=/home/examadm/tal-cli'],
        creates     => '/home/examadm/tal-cli/source/tal',
        command     => '/home/examadm/tal-cli/on_update.sh',
        require     => File['/home/examadm/tal-cli/on_update.sh'],
    
    Filip Strömbäck's avatar
    Filip Strömbäck committed
      }
    
      file { '/etc/cron.daily/tal-remind' :
        ensure  => file,
        owner   => 'root',
        group   => 'root',
        mode    => '0700',
    
        # lint:ignore:strict_indent heredoc failing...
    
        content => @(END),
        #!/bin/bash
        if [ "$(hostname)" = "aes-devel.edu.liu.se" ]
        then
            TO="klas.arvidsson@liu.se"
        else
            TO="inrapportering@ida.liu.se"
        fi
        if [ -e /home/examadm/ENABLE_TAL_REMINDERS ]
        then
    
            sudo -u examadm /home/examadm/tal-cli/source/scripts/tal-remind.py --to ${TO} --send
            sudo -u examadm /home/examadm/tal-cli/source/scripts/tal-remind.py --to ${TO} --computer-exam --send
    
        # lint:endignore:strict_indent
    
    Filip Strömbäck's avatar
    Filip Strömbäck committed
    }