Skip to content

Instantly share code, notes, and snippets.

@nfisher
Last active December 13, 2015 22:08
Show Gist options
  • Save nfisher/4982076 to your computer and use it in GitHub Desktop.
Save nfisher/4982076 to your computer and use it in GitHub Desktop.
Mongo DBA Week 4 - Replica Sets
node default {
class { 'mongo::server': version => '2.2.3' }
}
class aptupdate {
exec { 'apt_update':
command => 'apt-get update -qq',
path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
refreshonly => true,
}
}
class mongo::apt {
include aptupdate
# Note: this isn't the best way to add the key.
exec { 'add_10gen_key':
command => 'sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10',
path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
refreshonly => true,
notify => Class['aptupdate'],
}
file { '10gen_apt_list':
path => '/etc/apt/sources.list.d/10gen.list',
content => 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen',
owner => 'root',
group => 'root',
mode => '644',
notify => Exec['add_10gen_key'],
}
}
class mongo::server($version) {
include mongo::apt
package { 'mongodb-10gen':
ensure => $version,
require => Class['mongo::apt'],
}
service { 'mongodb':
ensure => false,
enable => false,
require => Package['mongodb-10gen'],
}
}
#!/bin/sh -eu
sudo mongod -f /etc/mongodb.conf --oplogSize 50 --smallfiles --fork --replSet rs01
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.provision :puppet do |puppet|
# equivalent to;
# puppet apply manifests/base.pp
puppet.manifests_path = "manifests"
puppet.manifest_file = "base.pp"
end
config.vm.define :mongo01 do |mongo|
mongo.vm.network :hostonly, "192.168.33.101"
mongo.vm.host_name = 'mongo01.local'
end
config.vm.define :mongo02 do |mongo|
mongo.vm.network :hostonly, "192.168.33.102"
mongo.vm.host_name = 'mongo02.local'
end
config.vm.define :mongo03 do |mongo|
mongo.vm.network :hostonly, "192.168.33.103"
mongo.vm.host_name = 'mongo03.local'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment