-
Notifications
You must be signed in to change notification settings - Fork 155
/
Vagrantfile.repo
63 lines (55 loc) · 1.98 KB
/
Vagrantfile.repo
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
boxes = [
{
:name => "centos",
:eth1 => "192.168.200.80",
:mem => "1024",
:cpu => "1"
}
]
Vagrant.configure(2) do |config|
config.vm.box = "centos/7"
config.ssh.insert_key = false
config.vm.provision "shell" do |s|
ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip
s.env = {AWS_ACCESS_KEY:ENV['AWS_ACCESS_KEY'], AWS_SECRET_KEY:ENV['AWS_SECRET_KEY']}
s.inline = <<-SHELL
mkdir -p /root/.ssh
echo #{ssh_pub_key} >> /home/vagrant/.ssh/authorized_keys
echo #{ssh_pub_key} >> /root/.ssh/authorized_keys
# setup Nginx
yum install epel-release -y
yum install nginx -y
rm -f /usr/share/nginx/html/*
sed -i '/server {/a \ autoindex on\;' /etc/nginx/nginx.conf
sudo systemctl start nginx
systemctl enable nginx
# setup AWS cli
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
yum install unzip -y
unzip awscli-bundle.zip
./awscli-bundle/install -i /usr/aws -b /usr/bin/aws
mkdir /root/.aws
echo "[default]" >> /root/.aws/credentials
echo "aws_access_key_id = ${AWS_ACCESS_KEY}" >> /root/.aws/credentials
echo "aws_secret_access_key = ${AWS_SECRET_KEY}" >> /root/.aws/credentials
cat /root/.aws/credentials
aws s3 sync s3://kismatic-repo-test /usr/share/nginx/html
SHELL
end
# Turn off shared folders
config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
boxes.each do |opts|
config.vm.define opts[:name] do |config|
config.vm.hostname = opts[:name]
config.vm.provider "vmware_fusion" do |v|
v.vmx["memsize"] = opts[:mem]
v.vmx["numvcpus"] = opts[:cpu]
end
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--memory", opts[:mem]]
v.customize ["modifyvm", :id, "--cpus", opts[:cpu]]
end
config.vm.network :private_network, ip: opts[:eth1]
end
end
end