Last active
November 10, 2015 16:10
-
-
Save damonp/53d115d811a5fbfa3cdf to your computer and use it in GitHub Desktop.
Vagrant with Nancy / Mono on ubuntu/trusty64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
sudo: yes | |
vars: | |
mono3_zipfile: mono-3.0.12-bin.tar.bz2 | |
mono3_url: "http://samples.nancyfx.org/content/{{ mono3_zipfile }}" | |
pre_tasks: | |
- name: apt-get update | |
apt: update_cache=yes | |
- name: apt-get upgrade | |
apt: upgrade=dist | |
- name: Install requirements | |
apt: | |
name: "{{ item }}" | |
state: present | |
with_items: | |
- ruby1.9.3 | |
- wget | |
- build-essential | |
- gettext | |
- zlib1g-dev | |
tasks: | |
- name: Fetch Mono binary | |
get_url: | |
url: "{{ mono3_url }}" | |
dest: "/tmp/{{ mono3_zipfile }}" | |
- name: Unzip Mono to /opt | |
unarchive: | |
src: "/tmp/{{ mono3_zipfile }}" | |
dest: /opt | |
copy: no | |
creates: /opt/mono | |
- name: Touch /etc/profile.d/mono.sh | |
file: | |
path: /etc/profile.d/mono.sh | |
state: touch | |
- name: Set Mono path in /etc/profile.d/mono.sh | |
lineinfile: | |
dest: /etc/profile.d/mono.sh | |
regexp: "PATH=" | |
line: PATH="$PATH:/opt/mono/bin" | |
- name: Set Mono library path in /etc/profile.d/mono.sh | |
lineinfile: | |
dest: /etc/profile.d/mono.sh | |
regexp: "LD_LIBRARY_PATH=" | |
line: LD_LIBRARY_PATH="/opt/mono/lib" | |
- name: Install Gems | |
gem: | |
name: "{{ item }}" | |
state: present | |
with_items: | |
- rake | |
- albacore | |
- name: Set color bash prompt | |
lineinfile: | |
dest: /home/vagrant/.bashrc | |
regexp: "force_color_prompt=yes" | |
line: "force_color_prompt=yes" | |
roles: | |
post_tasks: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
#### | |
# | |
# Builds unbuntu/trusty64 box and installs Nancy/Mono and requirements. | |
# https://github.com/NancyFx/Nancy | |
# | |
#### | |
Vagrant.configure(2) do |config| | |
config.vm.box = "ubuntu/trusty64" | |
# config.vm.network "forwarded_port", guest: 80, host: 8080 | |
# config.vm.network "private_network", ip: "192.168.33.10" | |
# config.vm.network "public_network" | |
# config.vm.synced_folder "../data", "/vagrant_data" | |
# Disable vbguest auto-updating | |
if Vagrant.has_plugin?("vbguest") or Vagrant.has_plugin?("vagrant-vbguest") | |
config.vbguest.auto_update = false | |
end | |
config.vm.provider :virtualbox do |v| | |
v.memory = 1024 | |
v.cpus = 2 | |
end | |
# shell provisioner | |
# use one, this or ansible provisioner (below) | |
# comment out the other | |
config.vm.provision :shell, inline: <<-SHELL_BLK | |
#!/bin/bash | |
MONO3_FILENAME="mono-3.0.12-bin.tar.bz2" | |
MONO3_BINARY="http://samples.nancyfx.org/content/$MONO3_FILENAME" | |
apt-get update | |
apt-get upgrade | |
apt-get install -y ruby1.9.3 wget build-essential gettext zlib1g-dev | |
apt-get autoremove -y | |
gem install rake | |
gem install albacore | |
if [ ! -d /opt/mono ]; then | |
sed -i "s/#\s*force_color_prompt=yes/force_color_prompt=yes/" /home/vagrant/.bashrc | |
cd /vagrant | |
echo cd \/vagrant >> /home/vagrant/.bashrc | |
rm -rf /etc/motd | |
echo Nancy on Mono >> /etc/motd | |
echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> /etc/motd | |
echo >> /etc/motd | |
echo This directory is shared with the host. >> /etc/motd | |
echo On your local machine, clone the source repo in the same >> /etc/motd | |
echo directory as this Vagrantfile. Then inside this VM do: >> /etc/motd | |
echo >> /etc/motd | |
echo \$ cd SRC_DIR >> /etc/motd | |
echo \$ rake mono >> /etc/motd | |
echo >> /etc/motd | |
echo and observe the output. >> /etc/motd | |
echo >> /etc/motd | |
echo export PATH="$PATH:/opt/mono/bin" >> /etc/profile.d/mono.sh | |
echo export LD_LIBRARY_PATH="/opt/mono/lib" >> /etc/profile.d/mono.sh | |
echo "Grabbing: $MONO3_BINARY" | |
wget -q $MONO3_BINARY | |
tar xk -C "/opt" -f $MONO3_FILENAME | |
else | |
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
echo "/opt/mono exists!" | |
echo "Assuming Mono installed. Skipping." | |
fi | |
echo ====================================================== | |
echo "Build Complete" | |
echo "login with: vagrant ssh" | |
SHELL_BLK | |
# uncomment and use provision.yml if ansible is available | |
# config.vm.provision :ansible do |ansible| | |
# ansible.playbook = "provision.yml" | |
# ansible.sudo = true | |
# ansible.verbose = false | |
# end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment