Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor playbook to allow boostrapping with ansible. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.vagrant
.vagrant
*.retry
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ This demonstrates the installation of MongoDB using Ansible
Quick start:
* clone this repository
* run '''vagrant up'''
* ssh into the newly created server
* run '''ansible-playbook -i src/stage src/playbook.yml''' (also found in bootstrap.sh)
* ssh into the newly created server (`vagrant ssh`)

Using mongo:

```
mongo
use somedb
db.somecollection.insert({"name": "Daniel Watrous"})
db.somecollection.insert({"message": "Hello World"})
db.somecollection.find()
```

Some things to consider.
* This assumes Ubuntu 14.04
* Due to limitations in Python 2.7.6 and Ubuntu 14.04, I'm not validating certificates
* The backup script is incomplete and should be tied into your object store solution
* This is a single point of failure. You will need to add additional nodes and create a discovery mechanism to accommodate clustered deployment
* This is a single point of failure. You will need to add additional nodes and create a discovery mechanism to accommodate clustered deployment
34 changes: 21 additions & 13 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# use insecure key for development environment (see http://software.danielwatrous.com/using-vagrant-to-build-a-lemp-stack/)
config.ssh.insert_key = false
config.vm.define :mongodb do |mongodb|
mongodb.vm.hostname = "ansible-mongodb"

# use insecure key for development environment (see http://software.danielwatrous.com/using-vagrant-to-build-a-lemp-stack/)
mongodb.ssh.insert_key = false

mongodb.vm.box = "ubuntu/trusty64"
mongodb.vm.hostname = "ansible-mongodb"
mongodb.vm.synced_folder ".", "/home/vagrant/src", mount_options: ["dmode=775,fmode=664"]
#mongodb.vm.network "private_network", ip: "192.168.76.10" # uncomment this and choose an IP to allow other systems to access MongoDB
mongodb.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
mongodb.vm.provider :virtualbox do |vb|
vb.cpus = 1
vb.memory = 512
end

config.vm.box = "ubuntu/trusty64"
config.vm.hostname = "ansible-mongodb"
config.vm.synced_folder ".", "/home/vagrant/src", mount_options: ["dmode=775,fmode=664"]
config.vm.provision :shell, path: "bootstrap.sh"
#config.vm.network "private_network", ip: "192.168.76.10" # uncomment this and choose an IP to allow other systems to access MongoDB
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
config.vm.provider :virtualbox do |vb|
vb.cpus = 1
vb.memory = 512
mongodb.vm.provision "ansible", run: "always" do |ansible|
ansible.playbook = "playbook.yml"
ansible.sudo = false
end
end
end
15 changes: 0 additions & 15 deletions bootstrap.sh

This file was deleted.

22 changes: 20 additions & 2 deletions playbook.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
---
- name: bootstrap host with ansible deps.
remote_user: root
hosts:
- mongodb
gather_facts: no
pre_tasks:
- name: 'install python2'
raw: sudo apt-get -y install python-simplejson

- name: deploy MongoDB and configure the database
hosts:
hosts:
- mongodb
user: vagrant
sudo: yes
pre_tasks:
- name: Install core packages
become: yes
package: name={{item}} state=installed
ignore_errors: True
with_items:
- git
- python-dev
- python-pip
roles:
- mongodb
- mongodb
5 changes: 4 additions & 1 deletion roles/mongodb/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
---
dependencies: []
galaxy_info:
author: Daniel Watrous
description: This demonstrates the installation of MongoDB using Ansible.
dependencies: []