Skip to content

Commit

Permalink
safeguard on file creation
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 09afeaf commit e2099b7
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
################################################################################
# Time-stamp: <Tue 2017-09-05 17:14 svarrette>
# Time-stamp: <Tue 2017-09-05 17:24 svarrette>
#
# File:: <tt>repo.pp</tt>
# Author:: UL HPC Team (hpc-sysadmins@uni.lu)
Expand Down Expand Up @@ -63,7 +63,6 @@
String $provider = 'git',
String $basedir = $slurm::params::repo_basedir,
String $path = '',
String $user = '',
$source = undef,
String $branch = 'HEAD',
String $syncscript = ''
Expand All @@ -84,19 +83,29 @@
'' => "${basedir}/${institute}/${reponame}",
default => $path,
}
$real_user = empty($user) ? {
true => defined(Class[::slurm]) ? {
true => $slurm::username,
default => 'root',
},
default => $user,
$user = defined(Class[::slurm]) ? {
true => $slurm::username,
default => 'root',
}
$group = defined(Class[::slurm]) ? {
true => $slurm::group,
default => 'root',
}


if $ensure == 'present' {
exec { "mkdir -p ${real_path} && chown ${user}: ${real_path}":
exec { "mkdir -p ${real_path}":
path => '/sbin:/usr/bin:/usr/sbin:/bin',
unless => "test -d ${real_path}",
before => Vcsrepo[$real_path],
before => File[$real_path],
}
if !defined(File[$real_path]) {
file { $real_path:
ensure => 'directory',
owner => $user,
group => $group,
mode => $slurm::params::configdir_mode,
}
}
}
else {
Expand All @@ -105,18 +114,17 @@
force => true,
}
}

# notice($source)
# notice($real_path)

vcsrepo { $real_path:
ensure => $ensure,
provider => $provider,
source => $source,
user => $real_user,
user => $user,
revision => $branch,
}



}
}

0 comments on commit e2099b7

Please sign in to comment.