From 504974bed6a8aebe5caec7c7d49067eb90d0cea0 Mon Sep 17 00:00:00 2001 From: Sebastien Varrette Date: Tue, 5 Sep 2017 16:47:30 +0200 Subject: [PATCH] slurm::repo class Signed-off-by: Sebastien Varrette --- manifests/params.pp | 5 ++- manifests/repo.pp | 100 ++++++++++++++++++++++++++++++++++++++++++++ tests/repo.pp | 13 ++++++ 3 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 manifests/repo.pp create mode 100644 tests/repo.pp diff --git a/manifests/params.pp b/manifests/params.pp index 239aff8..11e64e1 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,5 +1,5 @@ ################################################################################ -# Time-stamp: +# Time-stamp: # # File:: params.pp # Author:: UL HPC Team (hpc-sysadmins@uni.lu) @@ -73,6 +73,9 @@ # Slurm configuration $shared_configdir = '' + # Where the [git] control repository will be cloned + $repo_basedir = '/usr/local/src/git' + # $configdir_owner = $::operatingsystem ? { # default => 'root', # } diff --git a/manifests/repo.pp b/manifests/repo.pp new file mode 100644 index 0000000..88d0e21 --- /dev/null +++ b/manifests/repo.pp @@ -0,0 +1,100 @@ +################################################################################ +# Time-stamp: +# +# File:: repo.pp +# Author:: UL HPC Team (hpc-sysadmins@uni.lu) +# Copyright:: Copyright (c) 2017 UL HPC Team +# License:: Apache-2.0 +# +# ------------------------------------------------------------------------------ +# = Class: slurm::repo +# +# This class takes care of the control repository for the slurm configuration, which +# version your slurm configuration files. +# For many reasons, we decided NOT to directly version the /etc/slurm directory, +# but rather to have a control repository cloned in another directory and +# following a specific layout depicted below: +# +# * for the cluster '${clustername}', a root directory named'${clustername}' +# hosts all common slurm configuration files +# * a script '${syncscript}' (typically 'bin/commit_slurm_configs.sh') is +# responsible for synchronizing the configuration and commit it into this +# +# . +# ├── bin/ +# | └── commit_slurm_configs.sh +# └── / +# ├── cgroup.conf +# ├── gres.conf +# ├── plugstack.conf +# ├── plugstack.conf.d +# │   └── x11.conf +# ├── slurm.conf +# └── topology.conf +# +# +# Also, this server is expected to have push writes on the branch 'server/${::hostname}' +# +# @param ensure [String] Default: 'present' +# Ensure the presence (or absence) of the repository +# @param provider [String] Default: 'git' +# Specifies the backend to use for this vcsrepo resource. +# Valid options: 'bzr', 'git', 'hg', and 'svn'. +# @param basedir [String] Default: '/usr/local/src/git' +# Base directory where to clone the repository +# @param path [String] Default: '' +# Specifies a location for the managed repository. +# It this stays empty, the repository will be cloned under $basedir/$namespace/$reponame +# @param source [String or Hash] +# Specifies a source repository to serve as the upstream for your managed repository. +# Typically a Git repository URL or a hash of remotename => URL mappings +# @param branch [String] Default: 'HEAD' +# The branch/revision to pull +# +# @example Clone the SLURM control repository into '/usr/local/src/git/ULHPC/slurm' +# +# class { 'slurm::repo': + # ensure => 'present', + # source => 'ssh://git@gitlab.uni.lu:8022/ULHPC/slurm.git', + # } +# +class slurm::repo( + String $ensure = $slurm::params::ensure, + String $provider = 'git', + String $basedir = $slurm::params::repo_basedir, + String $path = '', + String $user = $slurm::params::username, + $source = undef, + String $branch = 'HEAD', + String $syncscript = '' +) +inherits slurm::params +{ + validate_legacy('String', 'validate_re', $ensure, ['^present', '^absent', '^latest']) + validate_legacy('String', 'validate_re', $provider, ['^git', '^bzr', '^hg', '^svn']) + + if ($source == undef or empty($source)) { + fail("Module ${module_name} requires a valid source to clone the SLURM control repository") + } + + $reponame = basename($source, ".${provider}") + $institute = basename(dirname($source)) + + $real_path = $path ? { + '' => "${basedir}/${institute}/${reponame}", + default => $path, + } + # notice($source) + # notice($real_path) + + vcsrepo { $real_path: + ensure => $ensure, + provider => $provider, + source => $source, + user => $user, + revision => $branch, + } + + + +} diff --git a/tests/repo.pp b/tests/repo.pp new file mode 100644 index 0000000..9fa6716 --- /dev/null +++ b/tests/repo.pp @@ -0,0 +1,13 @@ +# +# You can execute this manifest as follows in your vagrant box +# +# sudo puppet apply -t /vagrant/tests/repo.pp +# +node default { + + class { '::slurm::repo': + ensure => 'present', + source => 'ssh://git@github.com/ULHPC/slurm-control.git', + } + +}