Reorganized current play books and added a new one, bottle-mongodb.

This commit is contained in:
Michael Griffin 2013-04-12 01:08:24 -07:00
parent 017b145342
commit 925c1291be
7 changed files with 135 additions and 77 deletions

View file

@ -5,6 +5,7 @@ Configure servers in a snap with these concise Ansible playbooks!
Current Playbooks:
* **ZeroMQ** - open source high-performance asynchronous messaging library
* **Bottle-MongoDB** - open source lightweight webserver/application and document-oriented database combination
Future Playbooks:
@ -14,6 +15,7 @@ Future Playbooks:
* **NginX** - open source web server
* **Python** - open source highlevel interprited programming language
* **Ruby** - open source highlevel interprited programming language
* **PHP** - open source highlevel interprited programming language
* **RVM** - open source Ruby version and environment manager
Before running these Ansible playbooks, or any Ansible commands for that matter, it is essential that you have your publick SSH keys copied to your server's `~/.ssh/authorized_keys` file. The following command will copy your public key from your management computer, to the server:

99
Vagrantfile vendored
View file

@ -1,86 +1,89 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = 'precise64'
config.vm.network :bridged, :bridge => 'en1: Wi-Fi (AirPort)'
config.vm.define :server
config.vm.define :client
# This enables provisioning through Ansible. The only current issue is that when this is enabled, it seems that Vagrant only boots up one VM and provisions it, not two, and certainly not two concurrently...
# config.vm.provision :ansible do |ansible|
# ansible.playbook = 'zeromq.yml'
# ansible.hosts = 'chat_clients'
# end
config.vm.box = "precise64"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
# config.vm.box_url = 'http://domain.com/path/to/above.box'
# config.vm.box_url = "http://domain.com/path/to/above.box"
# Boot with a GUI so you can see the screen. (Default is headless)
# config.vm.boot_mode = :gui
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network :forwarded_port, guest: 80, host: 8080
# Assign this VM to a host-only network IP, allowing you to access it
# via the IP. Host-only networks can talk to the host machine as well as
# any other machines on the same network, but cannot be accessed (through this
# network interface) by any external networks.
# config.vm.network :hostonly, '192.168.33.10'
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network :private_network, ip: "192.168.33.10"
# Assign this VM to a bridged network, allowing you to connect directly to a
# network using the host's network device. This makes the VM appear as another
# physical device on your network.
# config.vm.network :bridged
# Forward a port from the guest to the host, which allows for outside
# computers to access the VM, whereas host only networking does not.
# config.vm.forward_port 80, 8080
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network :public_network
# Share an additional folder to the guest VM. The first argument is
# an identifier, the second is the path on the guest to mount the
# folder, and the third is the path on the host to the actual folder.
# config.vm.share_folder 'v-data', '/vagrant_data', '../data'
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider :virtualbox do |vb|
# # Don't boot with headless mode
# vb.gui = true
#
# # Use VBoxManage to customize the VM. For example to change memory:
# vb.customize ["modifyvm", :id, "--memory", "1024"]
# end
#
# View the documentation for the provider you're using for more
# information on available options.
# Enable provisioning with Puppet stand alone. Puppet manifests
# are contained in a directory path relative to this Vagrantfile.
# You will need to create the manifests directory and a manifest in
# the file precise64.pp in the manifests_path directory.
# the file base.pp in the manifests_path directory.
#
# An example Puppet manifest to provision the message of the day:
#
# # group { 'puppet':
# # ensure => 'present',
# # group { "puppet":
# # ensure => "present",
# # }
# #
# # File { owner => 0, group => 0, mode => 0644 }
# #
# # file { '/etc/motd':
# # content => 'Welcome to your Vagrant-built virtual machine!
# # Managed by Puppet.\n'
# # content => "Welcome to your Vagrant-built virtual machine!
# # Managed by Puppet.\n"
# # }
#
# config.vm.provision :puppet do |puppet|
# puppet.manifests_path = 'manifests'
# puppet.manifest_file = 'precise64.pp'
# puppet.manifests_path = "manifests"
# puppet.manifest_file = "base.pp"
# end
# Enable provisioning with chef solo, specifying a cookbooks path, roles
# path, and data_bags path (all relative to this Vagrantfile), and adding
# path, and data_bags path (all relative to this Vagrantfile), and adding
# some recipes and/or roles.
#
# config.vm.provision :chef_solo do |chef|
# chef.cookbooks_path = '../my-recipes/cookbooks'
# chef.roles_path = '../my-recipes/roles'
# chef.data_bags_path = '../my-recipes/data_bags'
# chef.add_recipe 'mysql'
# chef.add_role 'web'
# chef.cookbooks_path = "../my-recipes/cookbooks"
# chef.roles_path = "../my-recipes/roles"
# chef.data_bags_path = "../my-recipes/data_bags"
# chef.add_recipe "mysql"
# chef.add_role "web"
#
# # You may also specify custom JSON attributes:
# chef.json = { :mysql_password => 'foo' }
# chef.json = { :mysql_password => "foo" }
# end
# Enable provisioning with chef server, specifying the chef server URL,
@ -94,15 +97,15 @@ Vagrant::Config.run do |config|
# validation key to validation.pem.
#
# config.vm.provision :chef_client do |chef|
# chef.chef_server_url = 'https://api.opscode.com/organizations/ORGNAME'
# chef.validation_key_path = 'ORGNAME-validator.pem'
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
# chef.validation_key_path = "ORGNAME-validator.pem"
# end
#
# If you're using the Opscode platform, your validator client is
# ORGNAME-validator, replacing ORGNAME with your organization name.
#
# IF you have your own Chef Server, the default validation client name is
# If you have your own Chef Server, the default validation client name is
# chef-validator, unless you changed the configuration.
#
# chef.validation_client_name = 'ORGNAME-validator'
# chef.validation_client_name = "ORGNAME-validator"
end

11
bottle-mongodb/README.md Normal file
View file

@ -0,0 +1,11 @@
Ansible Playbook - Bottle-MongoDB
=================================
This Ansible playbook provisions a server to act as both a WSGI compliant Bottle webserver and a MongoDB database. Eventually it will have the capabilities of setting up separate servers, one (or multiple) webservers, and one (or multiple) databases. This playbook will also (in the future) be able to be set up bottle using Gevent, a massively multi-threaded synchronous WSGI compliant networking library.
These are the files (bottle, and MogoDB and their dependencies) which are retrieved and installed:
* **python-pip**
* **python-dev**
* **build-essential**
* **MongoDB**

View file

@ -0,0 +1,42 @@
---
- hosts: 192.168.33.10
user: vagrant
sudo: yes
vars:
mongodb_path: /mongodb/
mongod_log: /mongodb/mongod.log
mongod_data: /mongodb/data/
tasks:
- name: Install pip and its dependencies python-dev and build-essential
apt: pkg=python-pip,python-dev,build-essential state=installed
- name: Install bottle
pip: name=bottle
# - name: Adding 10gen's public GPG Key to apt's existing key list
# apt_key: url=http://docs.mongodb.org/10gen-gpg-key.asc state=present
# - name: Adding the python-software-properties package to fulfill the apt-add-repository dependency for the apt_repository Ansible module
# apt: pkg=python-software-properties update_cache=yes state=installed
# - name: Adding the 10gen repository to apt
# apt_repository: repo='deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' state=present
# - name: Installing MongoDB with apt
# apt: pkg=mongodb-10gen update_cache=yes
# - name: Start the MongoDB database
# service: name=mongod state=started
- name: Create the MongoDB directory at root
file: path=$mongodb_path state=directory
- name: Download MongoDB from 10gen
get_url: url=http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.1.tgz dest=/
- name: Untar MongoDB tarball
command: tar xvf mongodb-linux-x86_64-2.4.1.tgz -C /mongodb --strip-components 1 chdir=/ # The -C flag and --strip-components commands are used to change directories before untaring, and remove one directory level from all of the filenames stored in the archive
# Creating the symlinks for MongoDB
- name: Create symlink for mongod in /usr/bin/
file: src=${mongodb_path}bin/mongod dest=/usr/bin/mongod state=link
- name: Create symlink for mongo in /usr/bin/
file: src=${mongodb_path}bin/mongo dest=/usr/bin/mongo state=link
- name: Create symlink for monogdump in /usr/bin/
file: src=${mongodb_path}bin/mongodump dest=/usr/bin/mongodump state=link
- name: Create symlink for mongos in /usr/bin/
file: src=${mongodb_path}bin/mongos dest=/usr/bin/mongos state=link
- name: Create the MongoDB data directory
file: path=$mongod_data state=directory
- name: Start the MongoDB database
command: mongod --logpath $mongod_log --dbpath $mongod_data --logappend --fork

View file

@ -1,27 +0,0 @@
---
- hosts: virtual_machines
user: vagrant
sudo: yes # Is it possible to only run certain actions as sudo ansible?
tasks:
- name: Install zeroMQ dependancies
action: apt pkg=libtool,autoconf,automake,uuid-dev state=installed
- name: Get a C++ compiler package # Is this the best way to go about doing this?
action: apt pkg=build-essential state=installed
- name: Create directory for zeroMQ build
action: file path=/zeromq/ state=directory mode=0744
- name: Get zeroMQ tarball
action: get_url url=http://download.zeromq.org/zeromq-3.2.2.tar.gz dest=/zeromq/ mode=0744
- name: Untar and uncompress (g-zip compression) the zeroMQ tarball
action: command tar -xvf zeromq-3.2.2.tar.gz chdir=/zeromq/
- name: Run zeroMQ configuration
action: command ./configure chdir=/zeromq/zeromq-3.2.2/ # Do I have to change the directory for every command performed in this directory? How may I get the current working directory?
- name: Make zeroMQ
action: command make chdir=/zeromq/zeromq-3.2.2/
- name: Run a system-wide install of zeroMQ
action: command make install chdir=/zeromq/zeromq-3.2.2/
- name: Create nessecary links
action: command ldconfig chdir=/zeromq/zeromq-3.2.2/
- name: Install PIP and python-dev
action: apt pkg=python-pip,python-dev state=installed
- name: Install the Python binding (driver) for zeroMQ
action: pip name=pyzmq

View file

@ -1,9 +1,9 @@
Ansible Playbook - ZeroMQ
=========================
An Ansible playbook which installs **ZeroMQ** and all of its dependancies, along with its **Python** binding: **pyzmq**.
An Ansible playbook which installs **ZeroMQ** and all of its dependencies, along with its **Python** binding: **pyzmq**.
These are the files (ZeroMQ and its dependancies) which are retrieved and installed:
These are the files (ZeroMQ and its dependencies) which are retrieved and installed:
* **ZeroMQ**
* **autoconf**

27
zeromq/zeromq.yaml Normal file
View file

@ -0,0 +1,27 @@
---
- hosts: virtual_machines
user: vagrant
sudo: yes # Is it possible to only run certain actions as sudo ansible?
tasks:
- name: Install zeroMQ dependancies
apt: pkg=libtool,autoconf,automake,uuid-dev state=installed
- name: Get a C++ compiler package # Is this the best way to go about doing this?
apt: pkg=build-essential state=installed
- name: Create directory for zeroMQ build
file: path=/zeromq/ state=directory mode=0744
- name: Get zeroMQ tarball
get_url: url=http://download.zeromq.org/zeromq-3.2.2.tar.gz dest=/zeromq/ mode=0744
- name: Untar and uncompress (g-zip compression) the zeroMQ tarball
command: tar -xvf zeromq-3.2.2.tar.gz chdir=/zeromq/
- name: Run zeroMQ configuration
command: ./configure chdir=/zeromq/zeromq-3.2.2/ # Do I have to change the directory for every command performed in this directory? How may I get the current working directory?
- name: Make zeroMQ
command: make chdir=/zeromq/zeromq-3.2.2/
- name: Run a system-wide install of zeroMQ
command: make install chdir=/zeromq/zeromq-3.2.2/
- name: Create nessecary links
command: ldconfig chdir=/zeromq/zeromq-3.2.2/
- name: Install PIP and python-dev
apt: pkg=python-pip,python-dev state=installed
- name: Install the Python binding (driver) for zeroMQ
pip: name=pyzmq