diff --git a/manifests/site.pp b/manifests/site.pp index 250419b846..fa5b4afe2e 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -1,6 +1,7 @@ import "openstack_admins_users" #TODO: refactor import "openstack_ci_admins_users" #TODO: refactor import "doc_server" # TODO: refactor out of module +import "cowbuilder" # # Abstract classes: @@ -387,3 +388,8 @@ node /^driver(\d+)\.1918\.openstack\.org$/ { } } + +node /^debuild(-\d+)?\.slave\.openstack\.org$/ { + include openstack_jenkins_slave + include cowbuilder +} diff --git a/modules/cowbuilder/files/E01-enable-repos b/modules/cowbuilder/files/E01-enable-repos new file mode 100644 index 0000000000..b4ba9a034e --- /dev/null +++ b/modules/cowbuilder/files/E01-enable-repos @@ -0,0 +1,37 @@ +#!/bin/sh + +set -e + +apt-get -y install --force-yes lsb-release +release=`lsb_release --codename -s` + +if test `lsb_release --id --short` = "Ubuntu" +then + + apt-get -y install --force-yes python-software-properties + + cat > "/etc/apt/sources.list.d/extras.list" << EOF +deb http://security.ubuntu.com/ubuntu $release-security main universe +deb-src http://security.ubuntu.com/ubuntu $release-security main universe +deb http://us.archive.ubuntu.com/ubuntu/ $release-updates main universe +deb-src http://us.archive.ubuntu.com/ubuntu/ $release-updates main universe +EOF + + #TODO: This should be packages.openstack.org once we have it. + add-apt-repository ppa:nova-core/trunk + + if test "${release}" != "oneiric" -a "${release}" != "natty" + then + add-apt-repository ppa:nova-core/build-depends + fi +else + # Have I mentioned our lack of debian is a bit assy? Let's hope Maverick + # works for now + cat > "/etc/apt/sources.list.d/nova.list" << EOF +deb http://ppa.launchpad.net/nova-core/trunk/ubuntu maverick main +deb http://ppa.launchpad.net/nova-core/build-depends/ubuntu maverick main +EOF + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 2A2356C9 +fi + +apt-get update diff --git a/modules/cowbuilder/manifests/cow.pp b/modules/cowbuilder/manifests/cow.pp new file mode 100644 index 0000000000..a4b7f067a3 --- /dev/null +++ b/modules/cowbuilder/manifests/cow.pp @@ -0,0 +1,39 @@ +define cowbuilder::cow($distro = ubuntu) { + + $has_cow = "/usr/bin/test -d /var/cache/pbuilder/base-$name.cow" + case $distro { + ubuntu: { + exec { "Add base cow for $name": + environment => ["DIST=$name","APTCACHEHARDLINK=no","HOME=/root"], + command => "git-pbuilder create --distribution $name --components 'main universe' --hookdir /var/cache/pbuilder/hook.d/ --mirror='http://us.archive.ubuntu.com/ubuntu/'", + path => "/usr/sbin:/usr/bin:/sbin:/bin", + user => root, + group => root, + timeout => 0, + logoutput => on_failure, + unless => "$has_cow", + } + } + debian: { + exec { "Add base cow for $name": + environment => ["DIST=$name","APTCACHEHARDLINK=no","HOME=/root"], + command => "git-pbuilder create --distribution $name --mirror ftp://ftp.us.debian.org/debian/ --debootstrapopts '--keyring=/usr/share/keyrings/debian-archive-keyring.gpg' --hookdir /var/cache/pbuilder/hook.d/", + path => "/usr/sbin:/usr/bin:/sbin:/bin", + user => root, + group => root, + timeout => 0, + logoutput => on_failure, + unless => "$has_cow", + } + } + } + exec { "Update base cow for $name": + environment => ["DIST=$name","APTCACHEHARDLINK=no","HOME=/root"], + command => "git-pbuilder update --hookdir /var/cache/pbuilder/hook.d/", + path => "/usr/sbin:/usr/bin:/sbin:/bin", + user => root, + group => root, + logoutput => on_failure, + onlyif => "$has_cow", + } +} diff --git a/modules/cowbuilder/manifests/debgpg.pp b/modules/cowbuilder/manifests/debgpg.pp new file mode 100644 index 0000000000..540e9a1115 --- /dev/null +++ b/modules/cowbuilder/manifests/debgpg.pp @@ -0,0 +1,11 @@ +define cowbuilder::debgpg { + + exec { "Add gpg public key $name": + command => "gpg --keyserver keys.gnupg.net --recv-key $name", + path => "/usr/sbin:/usr/bin:/sbin:/bin", + user => root, + group => root, + logoutput => on_failure, + unless => "/usr/bin/gpg --list-keys $name >/dev/null 2>&1", + } +} diff --git a/modules/cowbuilder/manifests/init.pp b/modules/cowbuilder/manifests/init.pp new file mode 100644 index 0000000000..ef0e46f5bc --- /dev/null +++ b/modules/cowbuilder/manifests/init.pp @@ -0,0 +1,52 @@ +class cowbuilder { + + $slave_packages = ["git-buildpackage", + "pbuilder", + "cowbuilder", + "debian-archive-keyring"] + + $ubuntu_releases = [ "lucid", + "maverick", + "natty", + "oneiric" ] + + $debian_releases = [ "wheezy", + "squeeze" ] + + package { $slave_packages: + ensure => "latest" + } + + file { 'cowhookdir': + name => '/var/cache/pbuilder/hook.d', + ensure => 'directory', + mode => 755, + require => Package['pbuilder'], + } + + file { 'cowhook': + name => '/var/cache/pbuilder/hook.d/E01-enable-repos', + owner => 'root', + group => 'root', + mode => 755, + ensure => 'present', + source => "puppet:///modules/cowbuilder/E01-enable-repos", + replace => 'true', + require => File[cowhookdir] + } + + cowbuilder::debgpg { 'AED4B06F473041FA': } + + cowbuilder::cow { $ubuntu_releases: + distro => 'ubuntu', + require => [Package[debian-archive-keyring], File[cowhook]], + } + cowbuilder::cow { $debian_releases: + distro => 'debian', + require => [ Package[debian-archive-keyring], + File[cowhook], + Cowbuilder::Debgpg[AED4B06F473041FA], + ], + } + +}