Puppet With Launchd
Version 3 (Gerard Hickey, 02/02/2011 12:49 pm)
| 1 | 1 | # Using Puppet with launchd |
|
|---|---|---|---|
| 2 | 1 | ||
| 3 | 1 | Apple Computer has made it clear that the future of application and |
|
| 4 | 1 | server launching is their new launchd. Whether or not you have an |
|
| 5 | 1 | affinity for launchd, it appears to be here to stay, replacing SysV |
|
| 6 | 1 | Init as well as the newer StartupItems. The configuration of each |
|
| 7 | 1 | server is done with (surprise) XML property lists. |
|
| 8 | 1 | ||
| 9 | 1 | If you would like to run puppetd with launchd, you'll need to put |
|
| 10 | 1 | the folowing content into |
|
| 11 | 1 | /Library/LaunchDaemons/com.reductivelabs.puppet.plist: |
|
| 12 | 1 | ||
| 13 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 14 | 1 | <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
|
| 15 | 1 | <plist version="1.0"> |
|
| 16 | 1 | <dict> |
|
| 17 | 1 | <key>EnvironmentVariables</key> |
|
| 18 | 1 | <dict> |
|
| 19 | 1 | <key>PATH</key> |
|
| 20 | 1 | <string>/sbin:/usr/sbin:/bin:/usr/bin</string> |
|
| 21 | 1 | <key>RUBYLIB</key> |
|
| 22 | 1 | <string>/usr/lib/ruby/site_ruby/1.8/</string> |
|
| 23 | 1 | </dict> |
|
| 24 | 1 | <key>Label</key> |
|
| 25 | 1 | <string>com.reductivelabs.puppet</string> |
|
| 26 | 1 | <key>OnDemand</key> |
|
| 27 | 1 | <false/> |
|
| 28 | 1 | <key>ProgramArguments</key> |
|
| 29 | 1 | <array> |
|
| 30 | 3 | Gerard Hickey | <string>/usr/sbin/puppetd</string> |
| 31 | 1 | <string>--verbose</string> |
|
| 32 | 1 | <string>--no-daemonize</string> |
|
| 33 | 1 | <string>--logdest</string> |
|
| 34 | 1 | <string>console</string> |
|
| 35 | 1 | </array> |
|
| 36 | 1 | <key>RunAtLoad</key> |
|
| 37 | 1 | <true/> |
|
| 38 | 1 | <key>ServiceDescription</key> |
|
| 39 | 1 | <string>Puppet Daemon</string> |
|
| 40 | 1 | <key>ServiceIPC</key> |
|
| 41 | 1 | <false/> |
|
| 42 | 1 | <key>StandardErrorPath</key> |
|
| 43 | 1 | <string>/var/puppet/log/puppet.err</string> |
|
| 44 | 1 | <key>StandardOutPath</key> |
|
| 45 | 1 | <string>/var/puppet/log/puppet.out</string> |
|
| 46 | 1 | </dict> |
|
| 47 | 1 | </plist> |
|
| 48 | 1 | ||
| 49 | 1 | If you would like to run puppetmasterd with launchd, you'll need to |
|
| 50 | 1 | put the folowing content into \`\` |
|
| 51 | 1 | /Library/LaunchDaemons/com.reductivelabs.puppetmaster.plist\`\`: |
|
| 52 | 1 | ||
| 53 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 54 | 1 | <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
|
| 55 | 1 | <plist version="1.0"> |
|
| 56 | 1 | <dict> |
|
| 57 | 1 | <key>EnvironmentVariables</key> |
|
| 58 | 1 | <dict> |
|
| 59 | 1 | <key>PATH</key> |
|
| 60 | 1 | <string>/sbin:/usr/sbin:/bin:/usr/bin</string> |
|
| 61 | 1 | <key>RUBYLIB</key> |
|
| 62 | 1 | <string>/usr/lib/ruby/site_ruby/1.8/</string> |
|
| 63 | 1 | </dict> |
|
| 64 | 1 | <key>Label</key> |
|
| 65 | 1 | <string>com.reductivelabs.puppetmaster</string> |
|
| 66 | 1 | <key>OnDemand</key> |
|
| 67 | 1 | <false/> |
|
| 68 | 1 | <key>ProgramArguments</key> |
|
| 69 | 1 | <array> |
|
| 70 | 3 | Gerard Hickey | <string>/usr/sbin/puppetmasterd</string> |
| 71 | 1 | <string>--verbose</string> |
|
| 72 | 1 | <string>--no-daemonize</string> |
|
| 73 | 1 | </array> |
|
| 74 | 1 | <key>RunAtLoad</key> |
|
| 75 | 1 | <true/> |
|
| 76 | 1 | <key>ServiceDescription</key> |
|
| 77 | 1 | <string>Puppetmaster Daemon</string> |
|
| 78 | 1 | <key>ServiceIPC</key> |
|
| 79 | 1 | <false/> |
|
| 80 | 1 | <key>StandardErrorPath</key> |
|
| 81 | 1 | <string>/var/puppet/log/puppetmaster.err</string> |
|
| 82 | 1 | <key>StandardOutPath</key> |
|
| 83 | 1 | <string>/var/puppet/log/puppetmaster.out</string> |
|
| 84 | 1 | </dict> |
|
| 85 | 1 | </plist> |
|
| 86 | 1 | ||
| 87 | 1 | Now use the launchctl program to make launchd aware of the new |
|
| 88 | 1 | services (the -w makes launchd permanently aware of the new |
|
| 89 | 1 | daemon): |
|
| 90 | 1 | ||
| 91 | 1 | % launchctl load -w /Library/LaunchDaemons/com.reductivelabs.puppet.plist |
|
| 92 | 1 | % launchctl load -w /Library/LaunchDaemons/com.reductivelabs.puppetmaster.plist |
|
| 93 | 1 | ||
| 94 | 1 | As with all |
|
| 95 | 1 | [launchd plist files](http://developer.apple.com/technotes/tn2005/tn2083.html#SECSECURITY), |
|
| 96 | 1 | owner and group of the file wants to be root:wheel, and permissions |
|
| 97 | 1 | want to be 644 (owner has read/write, group and other read-only) |
|
| 98 | 1 | The services should now launch at boot-time. |