ecab1f6e23
Change-Id: Ib8211facc9d7cc248b97f3be85179157b2e31112
39 lines
1.3 KiB
Puppet
39 lines
1.3 KiB
Puppet
define slavecirepo($ensure = present) {
|
|
$repo_there = "test -d /home/jenkins/openstack-ci"
|
|
case $ensure {
|
|
present: {
|
|
exec { "Clone openstack-ci git repo":
|
|
path => "/usr/sbin:/usr/bin:/sbin:/bin",
|
|
environment => "HOME=/home/jenkins",
|
|
command => "sudo -H -u jenkins -i git clone git://github.com/openstack/openstack-ci.git /home/jenkins/openstack-ci",
|
|
user => "root",
|
|
group => "root",
|
|
unless => "$repo_there",
|
|
logoutput => on_failure,
|
|
}
|
|
exec { "Update openstack-ci git repo":
|
|
path => "/usr/sbin:/usr/bin:/sbin:/bin",
|
|
environment => "HOME=/home/jenkins",
|
|
command => "sudo -H -u jenkins -i bash -c 'cd /home/jenkins/openstack-ci && 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/openstack-ci",
|
|
user => "root",
|
|
group => "root",
|
|
onlyif => "$repo_there",
|
|
}
|
|
}
|
|
default: {
|
|
fail "Invalid 'ensure' value '$ensure' for slavecirepo"
|
|
}
|
|
}
|
|
}
|