Skip to content

Commit

Permalink
slurm::repo class
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastien Varrette <Sebastien.Varrette@uni.lu>
  • Loading branch information
Sebastien Varrette authored and Sebastien Varrette committed Sep 5, 2017
1 parent 0fb7326 commit 504974b
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 1 deletion.
5 changes: 4 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
################################################################################
# Time-stamp: <Mon 2017-09-04 21:23 svarrette>
# Time-stamp: <Tue 2017-09-05 16:42 svarrette>
#
# File:: <tt>params.pp</tt>
# Author:: UL HPC Team (hpc-sysadmins@uni.lu)
Expand Down Expand Up @@ -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',
# }
Expand Down
100 changes: 100 additions & 0 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
################################################################################
# Time-stamp: <Tue 2017-09-05 16:47 svarrette>
#
# File:: <tt>repo.pp</tt>
# 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
# └── <clustername>/
# ├── 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,
}



}
13 changes: 13 additions & 0 deletions tests/repo.pp
Original file line number Diff line number Diff line change
@@ -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',
}

}

0 comments on commit 504974b

Please sign in to comment.