Module Moonshine::Manifest::Rails::Os

  1. lib/moonshine/manifest/rails/os.rb (view online)

Public instance methods

cron_packages ()

Set up cron and enable the service. You can create cron jobs in your manifests like so:

cron :run_me_at_three
  :command => "/usr/sbin/something",
  :user => root,
  :hour => 3

cron 'rake:task',
    :command => "cd #{rails_root} && RAILS_ENV=#{ENV['RAILS_ENV']} rake rake:task",
    :user => configuration[:user],
    :minute => 15
[show source]
    # File lib/moonshine/manifest/rails/os.rb, line 14
14:   def cron_packages
15:     service "cron", :require => package("cron"), :ensure => :running
16:     package "cron", :ensure => :installed
17:   end
motd ()

Create a MOTD to remind those logging in via SSH that things are managed with Moonshine

[show source]
    # File lib/moonshine/manifest/rails/os.rb, line 21
21:   def motd
22:     motd_contents ="""-----------------
23: Moonshine Managed
24: -----------------
25: 
26:   Application:  #{configuration[:application]}
27:   Repository:   #{configuration[:repository]}
28:   Deploy Path:  #{configuration[:deploy_to]}
29: 
30: ----------------
31:   A Reminder
32: ----------------
33: As the configuration of this server is managed with Moonshine, please refrain
34: from installing any gems, packages, or dependencies directly on the server.
35: ----------------
36: """
37:     file '/var/run/motd',
38:       :mode => '644',
39:       :content => `uname -snrvm`+motd_contents
40:     file '/etc/motd.tail',
41:       :mode => '644',
42:       :content => motd_contents
43:   end
ntp ()

Install ntp and enables the ntp service.

[show source]
    # File lib/moonshine/manifest/rails/os.rb, line 51
51:   def ntp
52:     package 'ntp', :ensure => :latest
53:     service 'ntp', :ensure => :running, :require => package('ntp'), :pattern => 'ntpd'
54:   end
postfix ()

Install postfix.

[show source]
    # File lib/moonshine/manifest/rails/os.rb, line 46
46:   def postfix
47:     package 'postfix', :ensure => :latest
48:   end
security_updates ()

Configure automatic security updates. Output regarding errors will be sent to configuration[:user]. To exclude specific packages from these upgrades, create an array of packages on configuration[:unattended_upgrade][:package_blacklist]

[show source]
    # File lib/moonshine/manifest/rails/os.rb, line 73
73:   def security_updates
74:     configure(:unattended_upgrade => {})
75:     unattended_config = "APT::Periodic::Update-Package-Lists \"\#{configuration[:unattended_upgrade][:package_lists]||1}\";\nAPT::Periodic::Unattended-Upgrade \"\#{configuration[:unattended_upgrade][:interval]||1}\";\n"
76: 
77:     package 'unattended-upgrades', :ensure => :latest
78:     file '/etc/apt/apt.conf.d/10periodic',
79:       :ensure => :present,
80:       :mode => '644',
81:       :content => unattended_config
82:     file '/etc/apt/apt.conf.d/50unattended-upgrades',
83:       :ensure => :present,
84:       :mode => '644',
85:       :content => template(File.join(File.dirname(__FILE__), "templates", "unattended_upgrades.erb"))
86:   end
time_zone ()

Set the system timezone to configuration[:time_zone] or ‘UTC’ by default.

[show source]
    # File lib/moonshine/manifest/rails/os.rb, line 58
58:   def time_zone
59:     zone = configuration[:time_zone] || 'UTC'
60:     zone = 'UTC' if zone.nil? || zone.strip == ''
61:     file "/etc/timezone",
62:       :content => zone+"\n",
63:       :ensure => :present
64:     file "/etc/localtime",
65:       :ensure => "/usr/share/zoneinfo/#{zone}",
66:       :notify => service('ntp')
67:   end