From 40471655d39612d1451affe7ad0ab6aef01accb4 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Tue, 24 Jul 2012 10:03:23 -0500 Subject: [PATCH] Add support for install puppet modules. Change-Id: I0fb81d64daea389a564405c76773108eaeec6684 --- doc/gerrit.rst | 2 +- install_modules.sh | 11 +++++++++++ manifests/site.pp | 2 +- .../openstack_project/manifests/puppet_cron.pp | 2 +- .../openstack_project/manifests/puppetmaster.pp | 2 +- modules/puppetboot/files/puppetboot.conf | 2 ++ run_puppet.sh | 16 ++++++++++++++++ 7 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 install_modules.sh create mode 100644 run_puppet.sh diff --git a/doc/gerrit.rst b/doc/gerrit.rst index ef69a3f..7de3ab1 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 0000000..658eb10 --- /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 694f2af..8ae61a9 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 9bccf8d..960f7ae 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 2957d6e..444e094 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 67d34a8..93e27c5 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 0000000..5274a13 --- /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