-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvagrantfile
42 lines (34 loc) · 1.21 KB
/
vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
# Creating Ansible user for unified provisioning in different environments
# You can ssh to created host without password using 'ansible' user
$key = File.read("#{Dir.home}/.ssh/id_rsa.pub")
$shell = <<SCRIPT
if [[ $(id -u ansible 2>/dev/null) -eq 0 ]]; then
useradd -m ansible -s /bin/bash
mkdir -p /home/ansible/.ssh
echo "#{$key}" >> /home/ansible/.ssh/authorized_keys
chown -R ansible /home/ansible
echo 'ansible ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
fi
SCRIPT
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
base_box = "ubuntu/trusty64"
config.ssh.insert_key = false
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
config.vm.define :blog_awesome do |master|
master.vm.box = base_box
master.vm.network :private_network, ip: "192.168.100.10"
master.vm.hostname = "master"
master.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "4096"]
end
end
config.vm.provision "shell", inline: $shell
# Default provision for dev environment
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook_dev.yml"
ansible.verbose = "vvv"
end
end