This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathVagrantfile.example
141 lines (115 loc) · 6.4 KB
/
Vagrantfile.example
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
# Synced folders are declared here,
# host => guest
VAGRANT_SYNCED_FOLDERS = {
# This code
'.' => '/vagrant',
# For access to sibling repos (e.g. pulp_rpm, pulp_docker, ...)
'..' => '/home/vagrant/devel',
# You can speed up package installs in subsequent "vagrant up" operations by making the dnf
# cache a synced folder. This is essentially what the vagrant-cachier plugin would do for us
# if it supported dnf, and unfortunately that project is in need of maintainers so this might
# be the best we can do for now. Note that you'll have to manually create the '.dnf-cache'
# directory in the same directory as this Vagrantfile for this to work.
#'.dnf-cache' => '/var/cache/dnf'
}
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# It is possible to use URLs to nightly images produced by the Fedora project here. You can find
# the nightly composes here: https://kojipkgs.fedoraproject.org/compose/
# Sometimes, a nightly compose is incomplete and does not contain a Vagrant image, so you may need
# to browse that repository a bit to find the latest successful Vagrant image. For example, at the
# time of this writing, I could set this setting like this for the latest F24 image:
# config.vm.box = "https://kojipkgs.fedoraproject.org/compose/rawhide/latest-Fedora-Rawhide/compose/CloudImages/x86_64/images/<imagename>.vagrant-libvirt.box"
config.vm.box = "centos/7"
# Comment out if you don't want Vagrant to add and remove entries from /etc/hosts for each VM.
# requires the vagrant-hostmanager plugin to be installed
if Vagrant.has_plugin?("vagrant-hostmanager")
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
end
config.vm.provision "shell", inline: "sudo yum install -y epel-release"
# Comment this line if you would like to disable the automatic update during provisioning
config.vm.provision "shell", inline: "sudo yum upgrade -y"
# bootstrap and run with ansible
config.vm.provision "shell", path: "scripts/bootstrap-ansible.sh"
config.vm.provision "ansible" do |ansible|
# Uncomment this if you want debug tools like gdb, tcpdump, et al. installed
# (you don't, unless you know you do)
# ansible.extra_vars = { pulp_dev_debug: true }
ansible.playbook = "ansible/vagrant-playbook.yml"
end
# Create the "dev" box
config.vm.define "pulp2_dev" do |pulp2_dev|
pulp2_dev.vm.host_name = "pulp2.dev"
VAGRANT_SYNCED_FOLDERS.each do |host_path, guest_path|
# Use SSHFS instead of NFS. Requires the vagrant-sshfs plugin to be installed.
# Use SSHFS to share directories. The ``-o nonempty`` option is passed to allow
# mounts on non-empty directories.
pulp2_dev.vm.synced_folder host_path, guest_path, type: "sshfs", sshfs_opts_append: "-o nonempty"
# By default, Vagrant wants to mount with NFSv3, which will fail. Let's
# explicitly mount the code using NFSv4.
# pulp2_dev.vm.synced_folder host_path, guest_path, type: "nfs", nfs_version: 4, nfs_udp: false
end
pulp2_dev.vm.provider :libvirt do |domain, override|
domain.cpus = 4
# In some cases, the guest gets stuck at "Waiting for domain to get an IP address..." if
# the default cpu_mode, 'host-model', is used. Using 'host-passthrough' cpu_mode prevents
# VM migration between hosts with different CPUs. However, development environments are
# expected to live on a single host for the duration of their existence. Due to this known
# issue and our use case, the default cpu_mode is overridden.
domain.cpu_mode = "host-passthrough"
domain.graphics_type = "spice"
domain.memory = 3096
domain.video_type = "qxl"
# Uncomment this to expand the disk to the given size, in GB (default is usually 40)
# You'll also need to uncomment the provisioning step below that resizes the root partition
# do not set this to a size smaller than the base box, or you will be very sad
# domain.machine_virtual_size = 80
# Uncomment the following line if you would like to enable libvirt's unsafe cache
# mode. It is called unsafe for a reason, as it causes the virtual host to ignore all
# fsync() calls from the guest. Only do this if you are comfortable with the possibility of
# your development guest becoming corrupted (in which case you should only need to do a
# vagrant destroy and vagrant up to get a new one).
#
# domain.volume_cache = "unsafe"
# Uncomment this to resize the root partition and filesystem to fill the base box disk
# This script is only guaranteed to work with the default official fedora image, and is
# only needed it you changed machine_virtual_size above.
# For other boxen, use at your own risk
# override.vm.provision "shell", path: "scripts/vagrant-resize-disk.sh"
end
pulp2_dev.vm.provider :docker do |d, override|
require 'rbconfig'
os = RbConfig::CONFIG['host_os'].downcase
uid = Process.euid
gid = Process.egid
override.vm.box = nil
# Based on fedora official image, with vagrant's needs met:
# https://github.com/rohanpm/docker-fedora-vagrant
# plugins/providers/docker/action/login.rb
d.build_dir = 'docker/'
d.build_args = ["--build-arg=USER_EUID=#{uid}"]
unless os.include? "darwin" then
d.build_args.push("--build-arg=USER_EGID=#{gid}")
end
# use ssh for the sake of ansible
d.has_ssh = true
# Necessary for systemd to work
d.privileged = true
# Expose any ports other containers may want to connect to
d.expose = [80, 443, 5672, 27017]
VAGRANT_SYNCED_FOLDERS.each do |host_path, guest_path|
# Let the synced folders use docker's native mechanism
# (bind mounts) instead of NFS
override.vm.synced_folder host_path, guest_path, type: nil
end
end
pulp2_dev.vm.provision "shell", inline: "sudo -u vagrant bash /home/vagrant/devel/devel/scripts/vagrant-setup.sh"
pulp2_dev.vm.provision "shell", run: "always" do |s|
# only gofer and httpd strictly need this, but for consistency, we'll just restart them all
s.inline = "sudo systemctl restart goferd httpd pulp_celerybeat pulp_workers pulp_resource_manager"
end
end
end