Skip to content

Instantly share code, notes, and snippets.

@niallo
Created March 8, 2012 22:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niallo/2003789 to your computer and use it in GitHub Desktop.
Save niallo/2003789 to your computer and use it in GitHub Desktop.
Puppet module to run 10gen's MongoDB package on Ubuntu 10.04 LTS / Lucid
class mongodb {
$add-key = "/usr/bin/apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10"
$mongodb-repo = "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen"
Exec { require => Package["python-software-properties"] }
exec { "add-10gen-key":
command => $add-key,
onlyif => "/usr/bin/apt-key list | /usr/bin/awk '$0 ~ /10gen/ { exit 1 }' /etc/apt/sources.list"
}
exec { "10gen-repo" :
command => "/usr/bin/add-apt-repository '${mongodb-repo}'",
require => Exec["add-10gen-key"],
onlyif => "/usr/bin/awk '$0 ~ /10gen/ { exit 1 }' /etc/apt/sources.list"
}
$required-execs = [ "10gen-repo" ]
exec { "mongodb-apt-ready" :
command => "/usr/bin/apt-get update",
require => Exec[$required-execs],
onlyif => "/usr/bin/test ! -x /usr/bin/mongo"
}
package { [ "mongodb-10gen" ] :
ensure => "installed",
require => Exec["mongodb-apt-ready"]
}
service { "mongodb":
ensure => "running",
enable => "true",
require => Package["mongodb-10gen"]
}
file { "/etc/mongodb.conf":
notify => Service["mongodb"],
mode => 600,
owner => "root",
group => "root",
require => Package["mongodb-10gen"],
content => template("mongodb/mongodb.conf.erb")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment