This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
Shadow Puppet overview and examples
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.
Examples
Installing a package (via apt-get) or a gem
package 'some_native_package', :ensure => :installed gem 'some-gem'
Defining a Rake task to be run from cron
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 docs for all available options.
Create a mail alias to forward all mail for the root and rails users.
%w( root rails ).each do |user| mailalias user, :recipient => 'you@domain.com' end
Configure a file with specific contents
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'
Rotate log files. Logs for Rails, MySQL, and Apache are rotated by default
logrotate '/var/log/some_service.log', :options => ['weekly','rotate 7','missingok', 'compress'), :postrotate => '/etc/init.d/some_service restart'
Build and install from source
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'
Only configure certain components on the ‘testing’ stage.
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






