mirror of
https://github.com/mpolden/echoip.git
synced 2024-11-10 15:37:24 +01:00
Add Ansible provisioning of Vagrant env
This commit is contained in:
parent
137052410b
commit
a67a47a93f
31
Vagrantfile
vendored
31
Vagrantfile
vendored
@ -1,33 +1,18 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
$script = <<SCRIPT
|
||||
# Ensure noninteractive apt-get
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Set time zone
|
||||
echo "Europe/Oslo" > /etc/timezone
|
||||
dpkg-reconfigure tzdata
|
||||
|
||||
# Install packages
|
||||
apt-get -y --quiet update
|
||||
apt-get -y --quiet install git make
|
||||
|
||||
# Install golang
|
||||
test -d /usr/local/go || \
|
||||
curl https://go.googlecode.com/files/go1.1.2.linux-amd64.tar.gz | \
|
||||
tar -xzC /usr/local
|
||||
test -s /etc/profile.d/golang.sh || \
|
||||
echo 'export PATH=/usr/local/go/bin:$PATH' > /etc/profile.d/golang.sh
|
||||
SCRIPT
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "raring64-current"
|
||||
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/raring/current/raring-server-cloudimg-amd64-vagrant-disk1.box"
|
||||
config.vm.box = "precise64-current"
|
||||
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box"
|
||||
config.vm.network :forwarded_port, guest: 8080, host: 5000
|
||||
config.vm.network :private_network, ip: "172.16.5.10"
|
||||
config.vm.synced_folder ".", "/vagrant", nfs: true
|
||||
config.ssh.forward_agent = true
|
||||
config.vm.provider :virtualbox do |vb|
|
||||
vb.customize ["modifyvm", :id, "--memory", "1024"]
|
||||
end
|
||||
config.vm.provision :shell, :inline => $script
|
||||
config.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "provisioning/playbook.yml"
|
||||
ansible.inventory_path = "provisioning/development"
|
||||
end
|
||||
end
|
||||
|
2
provisioning/development
Normal file
2
provisioning/development
Normal file
@ -0,0 +1,2 @@
|
||||
[development]
|
||||
172.16.5.10
|
7
provisioning/playbook.yml
Normal file
7
provisioning/playbook.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
- hosts: development
|
||||
sudo: yes
|
||||
roles:
|
||||
- ntp
|
||||
- golang
|
||||
- vagrant
|
1
provisioning/roles/golang/files/golang.sh
Normal file
1
provisioning/roles/golang/files/golang.sh
Normal file
@ -0,0 +1 @@
|
||||
test -d /usr/local/go/bin && export PATH=/usr/local/go/bin:$PATH
|
11
provisioning/roles/golang/tasks/main.yml
Normal file
11
provisioning/roles/golang/tasks/main.yml
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
- name: install golang
|
||||
shell: curl https://go.googlecode.com/files/go1.2.linux-amd64.tar.gz | tar -zxC /usr/local
|
||||
creates=/usr/local/go
|
||||
|
||||
- name: configure path
|
||||
copy: src=golang.sh
|
||||
dest=/etc/profile.d/golang.sh
|
||||
owner=root
|
||||
group=root
|
||||
mode=0644
|
1
provisioning/roles/ntp/files/timezone
Normal file
1
provisioning/roles/ntp/files/timezone
Normal file
@ -0,0 +1 @@
|
||||
Europe/Oslo
|
3
provisioning/roles/ntp/handlers/main.yml
Normal file
3
provisioning/roles/ntp/handlers/main.yml
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
- name: update timezone
|
||||
command: dpkg-reconfigure --frontend=noninteractive tzdata
|
15
provisioning/roles/ntp/tasks/main.yml
Normal file
15
provisioning/roles/ntp/tasks/main.yml
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: set timezone
|
||||
copy: src=timezone
|
||||
dest=/etc/timezone
|
||||
owner=root
|
||||
group=root
|
||||
mode=0644
|
||||
notify:
|
||||
- update timezone
|
||||
|
||||
- name: install ntp
|
||||
apt: pkg=ntp state=latest
|
||||
|
||||
- name: make sure ntp is running
|
||||
service: name=ntp state=running enabled=yes
|
2
provisioning/roles/vagrant/files/dot.bash_profile
Normal file
2
provisioning/roles/vagrant/files/dot.bash_profile
Normal file
@ -0,0 +1,2 @@
|
||||
export GOPATH=/vagrant
|
||||
cd /vagrant
|
24
provisioning/roles/vagrant/tasks/main.yml
Normal file
24
provisioning/roles/vagrant/tasks/main.yml
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
- name: install packages
|
||||
apt: pkg={{ item }} state=latest update_cache=yes cache_valid_time=3600
|
||||
with_items:
|
||||
- gdb
|
||||
- git
|
||||
- make
|
||||
- mercurial
|
||||
environment:
|
||||
LANG: en_US.UTF-8
|
||||
|
||||
- name: hide login message
|
||||
copy: dest=/home/vagrant/.hushlogin
|
||||
content=
|
||||
owner=vagrant
|
||||
group=vagrant
|
||||
mode=0644
|
||||
|
||||
- name: install bash_profile
|
||||
copy: src=dot.bash_profile
|
||||
dest=/home/vagrant/.bash_profile
|
||||
owner=vagrant
|
||||
group=vagrant
|
||||
mode=0644
|
Loading…
Reference in New Issue
Block a user