Update basic-builder definition for private cloud
[releng/builder.git] / vagrant / basic-builder / Vagrantfile
1 # -*- mode: ruby -*-
2 # vi: set ft=ruby sw=2 ts=2 sts=2 et :
3
4 # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5 VAGRANTFILE_API_VERSION = "2"
6
7 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8   # root off of the openstack provider dummy box
9   config.vm.box = "dummy"
10   config.ssh.username = 'root'
11
12   # make sure to set the following in your
13   # ~/.vagrant.d/boxes/dummy/0/openstack/Vagrantfile
14   #
15   # os.openstack_auth_url
16   # os.endpoint_type
17   # os.flavor
18   # os.tenant_name
19   # os.username
20   # os.password
21   # os.networks
22   #
23   # If you are not using an SSH token / smartcard also set this
24   # os.key_name
25   # config.ssh.private_key_path -- set this outside the openstack block
26   #         in your base box
27   config.vm.provider :openstack do |os, override|
28     if ENV['BOX']
29       override.vm.box = ENV['BOX']
30     else
31       override.vm.box = 'dummy'
32     end
33     config.ssh.username = 'centos'
34     os.flavor = 'm1.small'
35
36     # require an IMAGE to be passed in
37     # IMAGE must be a human name and not an image ID!
38     if ENV['IMAGE']
39       os.image = ENV['IMAGE']
40     else
41       os.image = 'BAD IMAGE'
42       override.ssh.username = 'baduser'
43     end
44
45     case ENV['IMAGE']
46       when /.*ubuntu.*/i
47         override.ssh.username = 'ubuntu'
48
49       when /.*fedora.*/i
50         override.ssh.username = 'fedora'
51
52         # take care of the tty requirement by fedora for sudo
53         os.user_data = "#!/bin/bash
54 /bin/sed -i 's/ requiretty/ !requiretty/' /etc/sudoers;"
55
56       when /.*centos.*/i
57         override.ssh.username = 'centos'
58
59         # take care of the tty requirement by centos for sudo
60         os.user_data = "#!/bin/bash
61 /bin/sed -i 's/ requiretty/ !requiretty/' /etc/sudoers;"
62     end
63   end
64
65   # Explicitlly set default shared folder and load lib folder
66   config.vm.synced_folder ".", "/vagrant"
67   config.vm.synced_folder "../lib/", "/vagrant/lib"
68
69   # Do a full system update and enable enforcing if needed
70   config.vm.provision 'shell', path: '../lib/baseline.sh'
71
72   # run our bootstrapping
73   config.vm.provision 'shell', path: 'bootstrap.sh'
74
75   #################
76   # FINAL CLEANUP #
77   #################
78
79   # set RESEAL to... anything if you want to snap an image of this box
80   # not setting the environment variable will cause the system to come
81   # up fully and not be in a resealable state
82   if ENV['RESEAL']
83     config.vm.provision 'shell', path: '../lib/system_reseal.sh'
84   end
85 end