Changes needed for vagrant in the ODL Priv Cloud
[releng/builder.git] / vagrant / baseline / 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 rackspace provider dummy box
9   config.vm.box = "dummy"
10
11   # rackspace systems even with cloud-init
12   # don't seem to have the cloud init user ${osname}
13   # getting the ssh key for some reason, root does
14   # so use that
15   config.ssh.username = 'root'
16
17   # DEPRECATED
18   # ==========
19   #
20   # NOTE: The Rackspace provider section is deprecated as we are moving into a
21   # private OpenStack cloud. It may be revived after we've migrated and have a
22   # chance to do work to reconfigure the Rackspace public cloud to work for
23   # burst access
24   #
25   # make sure to set the following in your
26   # ~/.vagrant.d/boxes/dummy/0/rackspace/Vagrantfile
27   # rs.username
28   # rs.api_key
29   # rs.rackspace_region
30   #
31   # If you are not using a SSH token / smartcard also set this
32   # rs.key_name
33   # config.ssh.private_key_path  -- set this outside the rackspace block
34   #         in your base box
35   config.vm.provider :rackspace do |rs|
36     # create these base builds always on the smallest system possible
37     rs.flavor = 'general1-1'
38
39     # allow for switching to ORD cloud but default to DFW
40     if (ENV['RSREGION'] == 'ord')
41       rs.rackspace_region = :ord
42     else
43       rs.rackspace_region = :dfw
44     end
45
46     # Default to the Fedora 20 image unless overridden by a RSIMAGE
47     # environment variable
48     if ENV['IMAGE']
49       rs.image = ENV['IMAGE']
50     else
51       rs.image = 'Fedora 20 (Heisenbug) (PVHVM)'
52     end
53   end
54   # /DEPRECATED
55
56   # Configuration used by ODL Private cloud
57   # Should be mostly usable by any OpenStack cloud that can
58   # utilize upstream cloud images
59   config.vm.provider :openstack do |os, override|
60     if ENV['BOX']
61       override.vm.box = ENV['BOX']
62     else
63       override.vm.box = 'dummy'
64     end
65     config.ssh.username = 'centos'
66     os.flavor = 'm1.small'
67
68     # require an IMAGE to be passed in
69     # IMAGE must be a human name and not an image ID!
70     if ENV['IMAGE']
71       os.image = ENV['IMAGE']
72     else
73       os.image = 'BAD IMAGE'
74       override.ssh.username = 'baduser'
75     end
76
77     case ENV['IMAGE']
78       when /.*ubuntu.*/i
79         override.ssh.username = 'ubuntu'
80
81       when /.*fedora.*/i
82         override.ssh.username = 'fedora'
83
84         # take care of the tty requirement by fedora for sudo
85         os.user_data = "#!/bin/bash
86 /bin/sed -i 's/ requiretty/ !requiretty/' /etc/sudoers;"
87
88       when /.*centos.*/i
89         override.ssh.username = 'centos'
90
91         # take care of the tty requirement by centos for sudo
92         os.user_data = "#!/bin/bash
93 /bin/sed -i 's/ requiretty/ !requiretty/' /etc/sudoers;"
94     end
95
96   end
97
98   # Do a full system update and enable enforcing if needed
99   config.vm.provision 'shell', path: '../lib/baseline.sh'
100
101   # Execute a system clean-up in prep for imaging so that this base
102   # image can be used for other Rackspace Vagrant configurations
103   config.vm.provision 'shell', path: '../lib/system_reseal.sh'
104 end