-
Notifications
You must be signed in to change notification settings - Fork 69
Shadow Puppet overview and examples
auxesis edited this page Aug 19, 2010
·
5 revisions
Moonshine is based on Shadow Puppet, which in turn is based on Puppet. All of the Puppet types and options are valid, although the usage is slightly different and more Ruby-like in Moonshine/Shadow Puppet.
This page contains examples for various tasks you might want to do in your manifest. All of these should go into a recipe method that is called in your manifest, like so:
def cron_tasks # define cron jobs, example below. end recipe :cron_tasks
You can also dump all of your configuration into the application_packages
method which is present in your application_manifest
by default.
package 'some_native_package', :ensure => :installed gem 'some-gem'
cron 'Run some task at midnight', :command => "/usr/bin/rake -f #{configuration[:deploy_to]}/current/Rakefile custom:task RAILS_ENV=#{ENV['RAILS_ENV']}", :user => configuration[:user], :minute => 0, :hour => 0
Any of the time options can be specified as, e.g. '*/5'
to run the task every five minutes. See the Puppet documentation for all available options.
%w( root rails ).each do |user| mailalias user, :recipient => '[email protected]' end
farm_config = <<-CONFIG MOOCOWS = 3 HORSIES = 10 CONFIG file '/etc/farm', :ensure => :directory file '/etc/farm/farm.conf', :content => farm_config, :mode => '644', :owner => configuration[:user], :require => '/etc/farm'
logrotate '/var/log/some_service.log', :options => ['weekly','rotate 7','missingok', 'compress'), :postrotate => '/etc/init.d/some_service restart'
exec 'build foo', :command => ['wget http://domain.com/foo.tgz', 'tar xzf foo.tgz', 'cd foo', './configure', 'make', 'make install'].join(' && ') :cwd => '/tmp', :creates => '/usr/bin/foo'
Note: This assumes you are using capistrano-ext multistage functionality when deploying.
# only configure a server a certain way on production: if deploy_stage == 'production' configure( :mysql => {:bind_address => '123.123.123.123'}) end def application_packages # only run parts of a recipe on testing: on_stage 'testing' do file '/etc/motd', :ensure => :file, :content => "Welcome to the TEST server!" end end