From 246566d65e11f4842dc2d477ccd34ee7b81db208 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sat, 4 Aug 2012 09:55:37 -0500 Subject: [PATCH] Replace manual git work with vcsrepo module. Change-Id: Ia0f3acd50aab07cc83d13cd12c8f7fc67f1c697d Reviewed-on: https://review.openstack.org/10832 Reviewed-by: Clark Boylan Reviewed-by: James E. Blair Approved: Monty Taylor Tested-by: Jenkins --- install_modules.sh | 2 +- modules/etherpad_lite/manifests/init.pp | 72 ++++--------------- .../jenkins_slave/manifests/devstackrepo.pp | 46 ------------ .../jenkins_slave/manifests/slavecirepo.pp | 38 ---------- modules/lodgeit/manifests/init.pp | 20 ++---- modules/meetbot/manifests/init.pp | 32 +++------ modules/meetbot/manifests/site.pp | 9 ++- modules/planet/manifests/site.pp | 11 ++- modules/zuul/manifests/init.pp | 23 ++---- 9 files changed, 43 insertions(+), 210 deletions(-) delete mode 100644 modules/jenkins_slave/manifests/devstackrepo.pp delete mode 100644 modules/jenkins_slave/manifests/slavecirepo.pp diff --git a/install_modules.sh b/install_modules.sh index c265cd2c8e..e29a1cde62 100644 --- a/install_modules.sh +++ b/install_modules.sh @@ -4,7 +4,7 @@ if ! puppet help module >/dev/null 2>&1 ; then apt-get install -y -o Dpkg::Options::="--force-confold" puppet facter fi -MODULES="puppetlabs-mysql puppetlabs-dashboard" +MODULES="puppetlabs-mysql puppetlabs-dashboard puppetlabs-vcsrepo" MODULE_LIST=`puppet module list` for MOD in $MODULES ; do diff --git a/modules/etherpad_lite/manifests/init.pp b/modules/etherpad_lite/manifests/init.pp index a4c6492828..4da8c0967f 100644 --- a/modules/etherpad_lite/manifests/init.pp +++ b/modules/etherpad_lite/manifests/init.pp @@ -1,49 +1,3 @@ -# define to manage a git repo (should replace with vcsrepo module) -define git_repo ( - $repo, - $dest, - $user = 'root', - $branch = 'master', - $clone_only = undef -) { - - if $clone_only == 'true' { - $checkout_condition = "false" - } - else { - $checkout_condition = "test -d ${dest}" - } - -# if we already have the git repo the pull updates - exec { "update_${title}": - command => "git pull --ff-only origin ${branch}", - cwd => $dest, - path => '/bin:/usr/bin', - user => $user, - onlyif => $checkout_condition, - before => Exec["clone_${title}"], - } - -# otherwise get a new clone of it - exec { "clone_${title}": - command => "git clone ${repo} ${dest}", - path => '/bin:/usr/bin', - user => $user, - onlyif => "test ! -d ${dest}", - } -> - - exec { "checkout_${title}_${branch}": - command => "git checkout ${branch}", - path => '/bin:/usr/bin', - cwd => $dest, - user => $user, - subscribe => Exec["clone_${title}"], - refreshonly => true, - onlyif => "test -d ${dest}" - } - -} - # define to build from source using ./configure && make && make install. define buildsource( $dir = $title, @@ -114,11 +68,11 @@ class etherpad_lite ( mode => 0664, } - git_repo { 'nodejs_repo': - repo => 'https://github.com/joyent/node.git', - dest => "${base_install_dir}/nodejs", - branch => 'v0.6.16-release', - clone_only => 'true', + vcsrepo { "${base_install_dir}/nodejs": + ensure => present, + provider => git, + source => 'https://github.com/joyent/node.git', + revision => 'origin/v0.6.16-release', require => Package['git'] } @@ -144,15 +98,15 @@ class etherpad_lite ( Package['libssl-dev'], Package['pkg-config'], Package['build-essential'], - Git_repo['nodejs_repo']] + Vcsrepo["${base_install_dir}/nodejs"]] } - git_repo { 'etherpad_repo': - repo => 'https://github.com/Pita/etherpad-lite.git', - dest => "${base_install_dir}/etherpad-lite", - user => $ep_user, - clone_only => 'true', - require => Package['git'] + vcsrepo { "${base_install_dir}/etherpad-lite": + ensure => present, + provider => git, + source => "https://github.com/Pita/etherpad-lite.git", + owner => $ep_user, + require => Package['git'], } exec { 'install_etherpad_dependencies': @@ -161,7 +115,7 @@ class etherpad_lite ( user => $ep_user, cwd => "${base_install_dir}/etherpad-lite", environment => "HOME=${base_log_dir}/${ep_user}", - require => [Git_repo['etherpad_repo'], + require => [Vcsrepo["${base_install_dir}/etherpad-lite"], Buildsource["${base_install_dir}/nodejs"]], before => File["${base_install_dir}/etherpad-lite/settings.json"], creates => "${base_install_dir}/etherpad-lite/node_modules" diff --git a/modules/jenkins_slave/manifests/devstackrepo.pp b/modules/jenkins_slave/manifests/devstackrepo.pp deleted file mode 100644 index 4b54dcb8c4..0000000000 --- a/modules/jenkins_slave/manifests/devstackrepo.pp +++ /dev/null @@ -1,46 +0,0 @@ -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" - } - } -} diff --git a/modules/jenkins_slave/manifests/slavecirepo.pp b/modules/jenkins_slave/manifests/slavecirepo.pp deleted file mode 100644 index 3dbdad54f4..0000000000 --- a/modules/jenkins_slave/manifests/slavecirepo.pp +++ /dev/null @@ -1,38 +0,0 @@ -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" - } - } -} diff --git a/modules/lodgeit/manifests/init.pp b/modules/lodgeit/manifests/init.pp index ed9eb7660c..f85ddf7858 100644 --- a/modules/lodgeit/manifests/init.pp +++ b/modules/lodgeit/manifests/init.pp @@ -6,7 +6,6 @@ class lodgeit { "python-werkzeug", "python-simplejson", "python-pygments", - "mercurial", "drizzle", "python-mysqldb" ] @@ -34,21 +33,10 @@ class lodgeit { hasrestart => true } -# if we already have the git repo the pull updates - - exec { "update_lodgeit": - command => "git pull --ff-only", - cwd => "/tmp/lodgeit-main", - path => "/bin:/usr/bin", - onlyif => "test -d /tmp/lodgeit-main" - } - -# otherwise get a new clone of it - - exec { "get_lodgeit": - command => "git clone git://github.com/openstack-ci/lodgeit.git /tmp/lodgeit-main", - path => "/bin:/usr/bin", - onlyif => "test ! -d /tmp/lodgeit-main" + vcsrepo { "/tmp/lodgeit-main": + ensure => latest, + provider => git, + source => "https://github.com/openstack-ci/lodgeit.git", } # create initial git DB backup location diff --git a/modules/meetbot/manifests/init.pp b/modules/meetbot/manifests/init.pp index e0440c4086..a28bd1e2c5 100644 --- a/modules/meetbot/manifests/init.pp +++ b/modules/meetbot/manifests/init.pp @@ -1,26 +1,9 @@ -class vcs { -# if we already have the git repo the pull updates - - exec { "update_meetbot_repo": - command => "git pull --ff-only", - cwd => "/opt/meetbot", - path => "/bin:/usr/bin", - onlyif => "test -d /opt/meetbot" - } - -# otherwise get a new clone of it - - exec { "clone_meebot_repo": - command => "git clone https://github.com/openstack-ci/meetbot.git /opt/meetbot", - path => "/bin:/usr/bin", - onlyif => "test ! -d /opt/meetbot" - } -} - class meetbot { - stage { 'first': before => Stage['main'] } - class { 'vcs': - stage => 'first' + + vcsrepo { "/opt/meetbot": + ensure => latest, + provider => git, + source => "https://github.com/openstack-ci/meetbot.git", } user { "meetbot": @@ -41,7 +24,7 @@ class meetbot { service { "nginx": ensure => running, - hasrestart => true + hasrestart => true, } file { "/var/lib/meetbot": @@ -54,7 +37,8 @@ class meetbot { ensure => directory, recurse => true, source => "/opt/meetbot/MeetBot", - require => Package["supybot"] + require => [Package["supybot"], + Vcsrepo["/opt/meetbot"]] } file { "/etc/nginx/sites-enabled/default": diff --git a/modules/meetbot/manifests/site.pp b/modules/meetbot/manifests/site.pp index 12d6928f47..feafdca46f 100644 --- a/modules/meetbot/manifests/site.pp +++ b/modules/meetbot/manifests/site.pp @@ -88,7 +88,8 @@ define meetbot::site($nick, $nickpass, $network, $server, $url=$fqdn, $channels, recurse => true, source => "/opt/meetbot/ircmeeting", owner => 'meetbot', - require => File["/var/lib/meetbot/${name}"] + require => [Vcsrepo["/opt/meetbot"], + File["/var/lib/meetbot/${name}"]] } file { "/var/lib/meetbot/${name}/ircmeeting/meetingLocalConfig.py": @@ -114,7 +115,9 @@ define meetbot::site($nick, $nickpass, $network, $server, $url=$fqdn, $channels, service { "${name}-meetbot": provider => upstart, ensure => running, - require => File["/etc/init/${name}-meetbot.conf"], - subscribe => [File["/usr/share/pyshared/supybot/plugins/MeetBot"], File["/var/lib/meetbot/${name}/ircmeeting"]] + require => [Vcsrepo["/opt/meetbot"], + File["/etc/init/${name}-meetbot.conf"]], + subscribe => [File["/usr/share/pyshared/supybot/plugins/MeetBot"], + File["/var/lib/meetbot/${name}/ircmeeting"]] } } diff --git a/modules/planet/manifests/site.pp b/modules/planet/manifests/site.pp index 5f76c0c785..bd6912fa39 100644 --- a/modules/planet/manifests/site.pp +++ b/modules/planet/manifests/site.pp @@ -14,12 +14,11 @@ define planet::site($git_url) { require => Package[nginx], } -# otherwise get a new clone of it - - exec { "create_${name}_planet": - command => "git clone ${git_url} /var/lib/planet/${name}", - path => "/bin:/usr/bin", - onlyif => "test ! -d /var/lib/planet/${name}" + vcsrepo { "/var/lib/planet/${name}": + ensure => present, + provider => git, + source => $git_url, + require => File['/var/lib/planet'], } cron { "update_planet_${name}": diff --git a/modules/zuul/manifests/init.pp b/modules/zuul/manifests/init.pp index e8a9bbf864..31b891d92f 100644 --- a/modules/zuul/manifests/init.pp +++ b/modules/zuul/manifests/init.pp @@ -13,29 +13,18 @@ class zuul ( ensure => "present", } - # if we already have the repo the pull updates - - exec { "update_zuul": - command => "git pull --ff-only", - cwd => "/opt/zuul", - path => "/bin:/usr/bin", - onlyif => "test -d /opt/zuul", - before => Exec["get_zuul"], - } - - # otherwise get a new clone of it - - exec { "get_zuul": - command => "git clone https://github.com/openstack-ci/zuul /opt/zuul", - path => "/bin:/usr/bin", - onlyif => "test ! -d /opt/zuul" + vcsrepo { "/opt/zuul": + ensure => latest, + provider => git, + source => "https://github.com/openstack-ci/zuul.git", } exec { "install_zuul": command => "python setup.py install", cwd => "/opt/zuul", path => "/bin:/usr/bin", - subscribe => [ Exec["get_zuul"], Exec["update_zuul"] ], + refreshonly => true, + subscribe => Vcsrepo["/opt/zuul"], } file { "/etc/zuul":