Created
August 26, 2015 07:22
-
-
Save rgl/8a8a665067f2f5126b99 to your computer and use it in GitHub Desktop.
Vagrantfile to install a ready to use Ubuntu VM
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 : | |
$vagrant_provision_script = Vagrant.configure(2) do |config| | |
config.vm.box = "ubuntu-15.04-amd64" | |
config.vm.hostname = "influxdb" | |
config.vm.network "private_network", ip: "10.10.10.2" | |
config.vm.provider "virtualbox" do |vb| | |
vb.gui = true | |
vb.memory = 2048 | |
vb.cpus = 2 | |
end | |
config.vm.provision "shell", inline: <<'ROOT_PROVISION_SCRIPT' | |
#!/bin/bash | |
# abort this script on errors. | |
set -eux | |
# prevent apt-get et al from opening stdin. | |
# NB even with this, you'll still get some warnings that you can ignore: | |
# dpkg-preconfigure: unable to re-open stdin: No such file or directory | |
export DEBIAN_FRONTEND=noninteractive | |
# install vim because I like it. | |
apt-get -y install vim | |
# install gvm/go dependencies. | |
apt-get -y install curl bison git | |
# install httpie | |
apt-get -y install httpie | |
ROOT_PROVISION_SCRIPT | |
config.vm.provision "shell", privileged: false, inline: <<'VAGRANT_PROVISION_SCRIPT' | |
#!/bin/bash | |
# abort this script on errors. | |
set -eux | |
# setup the shell. | |
cat<<"EOF" > ~/.bashrc | |
if [[ $- != *i* ]] ; then | |
# bail if the shell is non-interactive. | |
return | |
fi | |
export EDITOR=vim | |
export PAGER=less | |
alias l='ls -lF --color' | |
alias ll='l -a' | |
alias h='history 25' | |
alias j='jobs -l' | |
EOF | |
cat<<"EOF" > ~/.inputrc | |
"\e[A": history-search-backward | |
"\e[B": history-search-forward | |
"\eOD": backward-word | |
"\eOC": forward-word | |
set show-all-if-ambiguous on | |
set completion-ignore-case on | |
EOF | |
# setup vim. | |
cat<<"EOF" > ~/.vimrc | |
syntax on | |
set background=dark | |
set esckeys | |
set ruler | |
set laststatus=2 | |
set nobackup | |
autocmd BufNewFile,BufRead Vagrantfile set ft=ruby | |
autocmd BufNewFile,BufRead *.config set ft=xml | |
" Usefull setting for working with Ruby files. | |
autocmd FileType ruby set tabstop=2 shiftwidth=2 smarttab expandtab softtabstop=2 autoindent | |
autocmd FileType ruby set smartindent cinwords=if,elsif,else,for,while,try,rescue,ensure,def,class,module | |
" Usefull setting for working with Python files. | |
autocmd FileType python set tabstop=4 shiftwidth=4 smarttab expandtab softtabstop=4 autoindent | |
" Automatically indent a line that starts with the following words (after we press ENTER). | |
autocmd FileType python set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class | |
" Usefull setting for working with Go files. | |
autocmd FileType go set tabstop=4 shiftwidth=4 smarttab expandtab softtabstop=4 autoindent | |
" Automatically indent a line that starts with the following words (after we press ENTER). | |
autocmd FileType go set smartindent cinwords=if,else,switch,for,func | |
EOF | |
# install go through gvm. | |
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) | |
source ~/.gvm/scripts/gvm | |
gvm install go1.5 --binary | |
$SHELL -i -c 'gvm use go1.5 --default && go version && go env' | |
VAGRANT_PROVISION_SCRIPT | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment