This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
forked from candlepin/subscription-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
96 lines (83 loc) · 2.95 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
VAGRANTFILE_DIR = File.dirname(__FILE__)
Vagrant.configure("2") do |config|
vm_boxes = {
"centos7" => "centos/7",
"centos6" => "centos/6",
"debian9" => "debian/stretch64",
"fedora25" => "fedora/25-cloud-base",
"opensuse42.2" => "opensuse/openSUSE-42.2-x86_64",
}
extra_boxes_loaded = false
# allows us to share base boxes with Katello/forklift
base_boxes = Dir.glob "#{VAGRANTFILE_DIR}/vagrant/plugins/*/base_boxes.yaml"
base_boxes.each do |file|
boxes = YAML.load_file(file)
boxes.each do |name, config|
if config.has_key? 'libvirt' and not name.include? 'sat'
vm_boxes[name] = config['libvirt']
extra_boxes_loaded = true
end
end
end
primary_vm = "centos7"
config.vm.provider "libvirt" # prefer libvirt
# forward X11 by default
config.ssh.forward_x11 = true
# setup shared folder
config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: [
"build",
"src/rhsm/_certificate.so",
"subscription-manager.egg-info",
"cockpit/node_modules",
]
# Set up the hostmanager plugin to automatically configure host & guest hostnames
if Vagrant.has_plugin?("vagrant-hostmanager")
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.manage_guest = true
config.hostmanager.include_offline = true
end
vm_boxes.each do |name, box|
is_primary = name == primary_vm
config.vm.define name, autostart: is_primary, primary: is_primary do |host|
host.vm.host_name = "#{name}.subman.example.com"
host.vm.box = box
host.vm.provider :libvirt do |domain|
domain.graphics_type = "spice"
domain.video_type = "qxl"
domain.memory = 1024
end
host.vm.provider :virtualbox do |domain, override|
override.vm.network "forwarded_port", guest: 9090, host: 9090 # allow VirtualBox to serve cockpit over 9090
end
end
end
['SUBMAN_RHSM_USERNAME', 'SUBMAN_RHSM_PASSWORD'].each do |var|
if extra_boxes_loaded and not ENV.include? var
puts "#{var} not defined. Expect failures. Please set up environment accordingly, and run `vagrant provision`. to correct"
end
end
config.vm.provision "ansible", run: "always" do |ansible|
ansible.playbook = "vagrant/vagrant.yml"
ansible.extra_vars = {
"subman_checkout_dir" => "/vagrant",
"subman_setup_hacking_environment" => "true",
"subman_add_vagrant_candlepin_to_hosts" => "true",
}
# This will pass any environment variables beginning with "SUBMAN_" or
# "subman_" (less the prefix) along with their values to ansible for
# use in our playbooks.
#
# Check the playbooks to see how these variables are used.
env_prefix = "subman_"
ENV.each do |key, value|
if key.downcase.start_with?(env_prefix)
new_var_key = key.downcase()
ansible.extra_vars[new_var_key] = value
end
end
end
end