Index: trunk/extensions/OpenStackManager/upstarts/runonce-fixpuppet.conf |
— | — | @@ -0,0 +1,48 @@ |
| 2 | +description "a test upstart job" |
| 3 | +start on stopped rc RUNLEVEL=[2345] |
| 4 | +console output |
| 5 | +task |
| 6 | +script |
| 7 | + |
| 8 | +# Configure puppet for first run |
| 9 | +while true |
| 10 | +do |
| 11 | + if [ -f '/etc/default/puppet' ] |
| 12 | + then |
| 13 | + echo 'Enabling waitforcert on puppet daemon' |
| 14 | + sed -i 's/DAEMON_OPTS.*/DAEMON_OPTS="--waitforcert=180"/' /etc/default/puppet |
| 15 | + break |
| 16 | + fi |
| 17 | + sleep 1 |
| 18 | +done |
| 19 | +while true |
| 20 | +do |
| 21 | + if [ -f '/etc/puppet/puppet.conf' ] |
| 22 | + then |
| 23 | + echo 'Disabling pluginsync, and ensuring we have a consistently named PID file for puppet' |
| 24 | + sed -i 's/pluginsync.*/pluginsync=false/' /etc/puppet/puppet.conf |
| 25 | + sed -i '/pluginsync/apidfile=/var/run/puppet/puppetd.pid' /etc/puppet/puppet.conf |
| 26 | + break |
| 27 | + fi |
| 28 | +sleep 1 |
| 29 | +done |
| 30 | + |
| 31 | +# Add logging and restart rsyslogd |
| 32 | +echo 'Enabling console logging for puppet while it does the initial run' |
| 33 | +echo 'daemon.* |/dev/console' > /etc/rsyslog.d/60-puppet.conf |
| 34 | +restart rsyslog |
| 35 | + |
| 36 | +# Start the first puppet run |
| 37 | +while true |
| 38 | +do |
| 39 | + # Wait for puppetd to start running |
| 40 | + if [ -f '/var/run/puppet/puppetd.pid' ] |
| 41 | + then |
| 42 | + echo "Force starting puppet run" |
| 43 | + puppetd -tv -w 180 |
| 44 | + echo "Finished puppet run" |
| 45 | + fi |
| 46 | +sleep 1 |
| 47 | +done |
| 48 | + |
| 49 | +end script |