diff --git a/doc/gerrit.rst b/doc/gerrit.rst index ef69a3fddb..7de3ab1c5e 100644 --- a/doc/gerrit.rst +++ b/doc/gerrit.rst @@ -43,7 +43,7 @@ host for use by the OpenStack project. sudo apt-get install puppet git openjdk-6-jre-headless mysql-server git clone git://github.com/openstack/openstack-ci-puppet.git cd openstack-ci-puppet/ - sudo puppet apply --modulepath=modules manifests/site.pp + sudo bash run_puppet.sh Install MySQL ------------- diff --git a/install_modules.sh b/install_modules.sh new file mode 100644 index 0000000000..658eb10a69 --- /dev/null +++ b/install_modules.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +MODULES="puppetlabs-mysql" +MODULE_LIST=`puppet module list` + +for MOD in $MODULES ; do + if ! echo $MODULE_LIST | grep $MOD >/dev/null 2>&1 ; then + # This will get run in cron, so silence non-error output + puppet module install $MOD >/dev/null + fi +done diff --git a/manifests/site.pp b/manifests/site.pp index 694f2af7dd..8ae61a9159 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -35,7 +35,7 @@ node "community.openstack.org" { } node "ci-puppetmaster.openstack.org" { - include openstack_project::puppet_cron + include openstack_project::remove_cron include openstack_project::puppetmaster } diff --git a/modules/openstack_project/manifests/puppet_cron.pp b/modules/openstack_project/manifests/puppet_cron.pp index 9bccf8dfc0..960f7aebe0 100644 --- a/modules/openstack_project/manifests/puppet_cron.pp +++ b/modules/openstack_project/manifests/puppet_cron.pp @@ -4,7 +4,7 @@ class openstack_project::puppet_cron { cron { "updatepuppet": user => root, minute => "*/15", - command => 'apt-get update >/dev/null 2>&1 ; sleep $((RANDOM\%600)) && cd /root/openstack-ci-puppet && /usr/bin/git pull -q && puppet apply -l /var/log/manifest.log --modulepath=/root/openstack-ci-puppet/modules manifests/site.pp', + command => 'apt-get update >/dev/null 2>&1 ; sleep $((RANDOM\%600)) && /bin/bash /root/openstack-ci-puppet/run_puppet.sh /root/openstack-ci-puppet', environment => "PATH=/var/lib/gems/1.8/bin:/usr/bin:/bin:/usr/sbin:/sbin", } logrotate::file { 'updatepuppet': diff --git a/modules/openstack_project/manifests/puppetmaster.pp b/modules/openstack_project/manifests/puppetmaster.pp index 2957d6eb88..444e094fb5 100644 --- a/modules/openstack_project/manifests/puppetmaster.pp +++ b/modules/openstack_project/manifests/puppetmaster.pp @@ -5,7 +5,7 @@ class openstack_project::puppetmaster { cron { "updatepuppetmaster": user => root, minute => "*/15", - command => 'sleep $((RANDOM\%600)) && cd /opt/openstack-ci-puppet/production && /usr/bin/git pull -q', + command => 'sleep $((RANDOM\%600)) && cd /opt/openstack-ci-puppet/production && /usr/bin/git pull -q && /bin/bash install_modules.sh', environment => "PATH=/var/lib/gems/1.8/bin:/usr/bin:/bin:/usr/sbin:/sbin", } } diff --git a/modules/puppetboot/files/puppetboot.conf b/modules/puppetboot/files/puppetboot.conf index 67d34a8e07..93e27c5d6c 100644 --- a/modules/puppetboot/files/puppetboot.conf +++ b/modules/puppetboot/files/puppetboot.conf @@ -6,6 +6,8 @@ start on runlevel[2345] script cd /root/openstack-ci-puppet/modules /usr/bin/git pull --ff-only + echo "Installing modules" >> /var/log/manifest.log + /bin/bash install_modules.sh >> /var/log/manifest.log echo "Running puppet on boot" >> /var/log/manifest.log date >> /var/log/manifest.log /usr/bin/puppet apply --modulepath=/root/openstack-ci-puppet/modules -l /var/log/manifest.log /root/openstack-ci-puppet/manifests/site.pp diff --git a/run_puppet.sh b/run_puppet.sh new file mode 100644 index 0000000000..5274a1347c --- /dev/null +++ b/run_puppet.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +if ! test -z $1 ; then + BASE_DIR=$1 +else + BASE_DIR=`pwd` +fi + +MODULE_DIR=${BASE_DIR}/modules +MODULE_PATH=${MODULE_DIR}:/etc/puppet/modules +MANIFEST_LOG=/var/log/manifest.log + +cd $BASE_DIR +/usr/bin/git pull -q && \ + /bin/bash install_modules.sh && \ + /usr/bin/puppet apply -l $MANIFEST_LOG --modulepath=$MODULE_PATH manifests/site.pp