0d08138ac0
Change-Id: I9d3f34d3eb55d6a9f4ec17d6befa1fadd9a18547
47 lines
1.5 KiB
Puppet
47 lines
1.5 KiB
Puppet
define devstackrepo($ensure = present) {
|
|
$repo_there = "test -d /home/jenkins/devstack"
|
|
case $ensure {
|
|
present: {
|
|
exec { "Clone devstack git repo":
|
|
path => "/usr/sbin:/usr/bin:/sbin:/bin",
|
|
environment => "HOME=/home/jenkins",
|
|
command => "sudo -H -u jenkins -i git clone git://github.com/jeblair/devstack.git /home/jenkins/devstack",
|
|
user => "root",
|
|
group => "root",
|
|
unless => "$repo_there",
|
|
logoutput => on_failure,
|
|
}
|
|
file { '/home/jenkins/devstack/localrc':
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => 444,
|
|
ensure => 'present',
|
|
source => 'puppet:///modules/jenkins_slave/localrc',
|
|
require => Exec["Clone devstack git repo"],
|
|
}
|
|
exec { "Update devstack git repo":
|
|
path => "/usr/sbin:/usr/bin:/sbin:/bin",
|
|
environment => "HOME=/home/jenkins",
|
|
command => "sudo -H -u jenkins -i bash -c 'cd /home/jenkins/devstack && git pull'",
|
|
user => "root",
|
|
group => "root",
|
|
onlyif => "$repo_there",
|
|
logoutput => on_failure,
|
|
}
|
|
}
|
|
absent: {
|
|
exec { "Remove OpenStack git repo":
|
|
path => "/usr/sbin:/usr/bin:/sbin:/bin",
|
|
environment => "HOME=/root",
|
|
command => "rm -rf /home/jenkins/devstack",
|
|
user => "root",
|
|
group => "root",
|
|
onlyif => "$repo_there",
|
|
}
|
|
}
|
|
default: {
|
|
fail "Invalid 'ensure' value '$ensure' for devstackrepo"
|
|
}
|
|
}
|
|
}
|