Skip to content

Instantly share code, notes, and snippets.

@eric
Created June 11, 2010 18:07
Show Gist options
  • Save eric/434833 to your computer and use it in GitHub Desktop.
Save eric/434833 to your computer and use it in GitHub Desktop.
class ApplicationManifest < Moonshine::Manifest
def ntp
package 'ntp', :ensure => :latest
case Facter.lsbdistid
when 'Ubuntu'
service 'ntp', :alias => 'ntp', :ensure => :running,
:require => package('ntp'), :pattern => 'ntpd'
when 'Fedora', 'RedHat'
service 'ntpd', :alias => 'ntp', :ensure => :running,
:require => package('ntp'), :pattern => 'ntpd'
else
raise "Unsupported distribution: #{_}"
end
end
recipe :ntp
end
class ApplicationManifest < Moonshine::Manifest
def ntp
service_name = for_distro('Ubuntu' => 'ntp', 'Fedora' => 'ntpd')
package 'ntp', :ensure => :latest
service service_name, :alias => 'ntp', :ensure => :running,
:require => package('ntp'), :pattern => 'ntpd'
end
recipe :ntp
def for_distro(mapping)
distribution = Facter.lsbdistid
if value = mapping[distribution.to_s]
value
else
raise "Unsupported distribution: #{distribution}"
end
end
end
class ApplicationManifest < Moonshine::Manifest
def ntp
service_name = Facter.case(:lsbdistid, 'Ubuntu' => 'ntp', 'Fedora' => 'ntpd')
package 'ntp', :ensure => :latest
service service_name, :alias => 'ntp', :ensure => :running,
:require => package('ntp'), :pattern => 'ntpd'
end
recipe :ntp
end
class ApplicationManifest < Moonshine::Manifest
def ntp
package 'ntp', :ensure => :latest
service 'ntp',
:name => Facter.case(:lsbdistid, 'Ubuntu' => 'ntp', 'Fedora' => 'ntpd'),
:ensure => :running, :require => package('ntp'), :pattern => 'ntpd'
end
recipe :ntp
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment