Skip to content

Instantly share code, notes, and snippets.

@bbonamin
Created December 24, 2014 13:07
Show Gist options
  • Select an option

  • Save bbonamin/5e7355c796a2144872b3 to your computer and use it in GitHub Desktop.

Select an option

Save bbonamin/5e7355c796a2144872b3 to your computer and use it in GitHub Desktop.
Vagrant + Ansible as provisioned dev box
---
- hosts: all
vars:
- ruby_version: 2.1
- ruby_version_patch: 5
tasks:
- name: Update apt cache
apt: update_cache=yes cache_valid_time=3600
sudo: yes
- name: Upgrade ubuntu
apt: upgrade=yes
sudo: yes
- name: Install dependencies
apt: pkg={{item}} state=latest
sudo: yes
with_items:
- build-essential
- zlib1g-dev
- libssl-dev
- libreadline6-dev
- libyaml-dev
- git
- libpq-dev
- include: ruby.yml
- include: postgresql.yml
---
- name: Add PostgreSQL APT repository
apt_repository: repo='deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main' state=present
sudo: yes
- name: Add PostgreSQL APT key
apt_key: url=https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo: yes
- name: Reload apt cache
apt: update_cache=yes
sudo: yes
- name: Install PostgreSQL 9.4
apt: pkg=postgresql-9.4
sudo: yes
---
- name: Download ruby source
get_url: dest=/tmp/ruby-{{ruby_version}}.{{ruby_version_patch}}.tar.gz url=http://ftp.ruby-lang.org/pub/ruby/{{ruby_version}}/ruby-{{ruby_version}}.{{ruby_version_patch}}.tar.gz
- name: Unarchive ruby source
unarchive: copy=no src=/tmp/ruby-{{ruby_version}}.{{ruby_version_patch}}.tar.gz dest=/tmp
- name: Configure ruby source
command: chdir=/tmp/ruby-{{ruby_version}}.{{ruby_version_patch}} ./configure --prefix=/usr/local
- name: Make ruby
command: chdir=/tmp/ruby-{{ruby_version}}.{{ruby_version_patch}} ./configure --prefix=/usr/local
- name: Install ruby
command: chdir=/tmp/ruby-{{ruby_version}}.{{ruby_version_patch}} make install
sudo: yes
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 3000, host: 3001
config.vm.provision :ansible do |ansible|
ansible.playbook = "playbook.yml"
ansible.verbose = 'v'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment