Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

vagrant uses official fedora23 base box by default #2202

Merged
merged 1 commit into from Dec 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 22 additions & 12 deletions Vagrantfile.example
Expand Up @@ -4,7 +4,7 @@
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "https://dl.fedoraproject.org/pub/alt/purpleidea/vagrant/fedora-22/fedora-22.box"
config.vm.box = "fedora/23-cloud-base"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

# By default, Vagrant wants to mount the code in /vagrant with NFSv3, which will fail. Let's
# explicitly mount the code using NFSv4.
config.vm.synced_folder ".", "/vagrant", type: "nfs", nfs_version: 4, nfs_udp: false
Expand All @@ -16,17 +16,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.hostmanager.manage_host = true
end

# Comment this out to prevent resizing the root filesystem to fill the base box disk
config.vm.provision "shell", inline: "sudo xfs_growfs /dev/vda3"
# the command args above must match the filesystems and devices used in the base box

# Comment this line if you would like to disable the automatic update during provisioning
config.vm.provision "shell", inline: "sudo dnf upgrade -y"

config.vm.provision "ansible" do |ansible|
ansible.playbook = "playpen/ansible/vagrant-playbook.yml"
end

# install vagrant-cachier for some caching goodness
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
config.cache.synced_folder_opts = {
Expand All @@ -35,6 +25,15 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
}
end

# Comment this line if you would like to disable the automatic update during provisioning
config.vm.provision "shell", inline: "sudo dnf upgrade -y"

# bootstrap and run with ansible
config.vm.provision "shell", path: "playpen/bootstrap-ansible.sh"
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playpen/ansible/vagrant-playbook.yml"
end

# Create the "dev" box
config.vm.define "dev" do |dev|
dev.vm.host_name = "dev.example.com"
Expand All @@ -46,6 +45,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
domain.memory = 2048
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
Expand All @@ -55,6 +59,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# domain.volume_cache = "unsafe"
end

# 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
# dev.vm.provision "shell", path: "playpen/vagrant-resize-disk.sh"

dev.vm.provision "shell", inline: "sudo -u vagrant bash /home/vagrant/devel/pulp/playpen/vagrant-setup.sh"
end
end
10 changes: 8 additions & 2 deletions playpen/ansible/library/pulp_facts.py 100644 → 100755
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python2
"""
This module gathers Pulp specific Ansible facts about the remote machine.
"""
Expand All @@ -13,17 +13,23 @@
stdout, stderr = pipe.communicate()
pulp_27_beta_repo_enabled = 'enabled = True' in stdout

# Determine if the fedora-23 repo is available yet
proc = subprocess.Popen(
'/usr/bin/curl -s -f https://repos.fedorapeople.org/repos/pulp/pulp/beta/2.7/fedora-23/',
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
pulp_27_beta_f23_repo_available = (proc.wait() == 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hahaha, nice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naw, but really it isn't


# Determine if selinux is Enforcing or not
pipe = subprocess.Popen('/usr/sbin/getenforce', stdout=subprocess.PIPE,
stderr=subprocess.PIPE, shell=True)
stdout, stderr = pipe.communicate()
selinux_enabled = 'Enforcing' in stdout


# Build the facts for Ansible
facts = {
'ansible_facts': {
'pulp_27_beta_repo_enabled': pulp_27_beta_repo_enabled,
'pulp_27_beta_f23_repo_available': pulp_27_beta_f23_repo_available,
'selinux_enabled': selinux_enabled}}


Expand Down
2 changes: 1 addition & 1 deletion playpen/ansible/roles/db/tasks/main.yml
Expand Up @@ -14,4 +14,4 @@
notify: restart mongod

- name: Start and enable services
service: name=mongod state=started enabled=yes
service: name=mongod state=started enabled=yes
26 changes: 25 additions & 1 deletion playpen/ansible/roles/dev/tasks/main.yml
Expand Up @@ -17,9 +17,33 @@
dest: /etc/yum.repos.d/fedora-pulp.repo

- name: Enable Pulp 2.7 beta repository
command: yum-config-manager --enable pulp-2.7-beta
command: dnf config-manager --set-enabled pulp-2.7-beta
when: pulp_27_beta_repo_enabled == false

# This and its related fact should go away when we do have an f23 build, since it'll be a noop at that point
- name: Rejigger the repo file if fedora 23 builds aren't available
replace:
dest: /etc/yum.repos.d/fedora-pulp.repo
regexp: 'fedora-\$releasever'
replace: fedora-22
when: not pulp_27_beta_f23_repo_available and
ansible_distribution == 'Fedora' and
ansible_distribution_version == '23'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sneaky!


# These can go away when https://fedorahosted.org/spin-kickstarts/ticket/59 is fixed
- stat:
path: /etc/sudoers.d/vagrant-nopasswd
name: Detect vagrant sudoers file
register: vagrant_nopasswd
- lineinfile:
dest: "{{ vagrant_nopasswd.stat.path }}"
regexp: '^vagrant'
line: 'vagrant ALL=(ALL) NOPASSWD: ALL'
validate: 'visudo -cf %s'
mode: 0440
when: vagrant_nopasswd.stat.exists
name: Rejigger vagrant sudoers file

- name: Install packages
dnf: name={{ item }} state=present
with_items:
Expand Down
11 changes: 8 additions & 3 deletions playpen/ansible/roles/qpidd/tasks/main.yml
Expand Up @@ -2,10 +2,15 @@
- name: Install packages
dnf: name={{ item }} state=present
with_items:
- qpid-cpp-server
- qpid-cpp-server-store
# qpid is broken in f23, so we have to install the compat packages:
# https://bugzilla.redhat.com/show_bug.cgi?id=1286881
# - qpid-cpp-server
# - qpid-cpp-server-linerstore
- compat-qpid-cpp-server
- compat-qpid-cpp-server-store
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these packages exist on F22? If not, we may need a when statement to do this only for F23 and do the other for F22. Or not and we can force everyone to switch boxes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The F23 box is so significantly different from purpleidea's F22 box that I opted to give up on backward compatibility between boxes. My assumption is that now that we're tracking the official fedora cloud images we've got a good excuse to start fresh at this point.

- qpid-tools

- name: Start and enable services
service: name={{ item }} state=started enabled=yes
with_items:
- qpidd
- qpidd
5 changes: 5 additions & 0 deletions playpen/bootstrap-ansible.sh
@@ -0,0 +1,5 @@
#!/bin/sh

# minimal bootstrapping before kicking off ansible:
# install only what ansible needs to survive, or doesn't know how to do
sudo dnf -y install python2 python2-dnf libselinux-python
21 changes: 21 additions & 0 deletions playpen/vagrant-resize-disk.sh
@@ -0,0 +1,21 @@
#!/bin/sh
# this assumes that vda has only one partition, which contains an ext filesystem

# remote-control fdisk to blindly delete and re-create the first partition on vda
# (d)elete the only partition, create a (n)ew (p)rimary partition numbered (1),
# accept some defaults (the two newlines), (w)rite the new table
sudo fdisk /dev/vda <<EOF
d
n
p
1


w
EOF
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahaha, nice technique.


# refresh partition tables
sudo partprobe

# fill the new space if needed
sudo resize2fs /dev/vda1
7 changes: 7 additions & 0 deletions playpen/vagrant-setup.sh
@@ -1,5 +1,12 @@
#!/usr/bin/bash

# Important things:
# - this file is still in-use, but deprecated in favor of ansible
# - the contents of this file are being converted to ansible tasks
# - add to the ansible playbook instead of adding to or altering this file
# - dev-setup script calls this script after running ansible, so (despite the
# unfortunate name), it is *not* vagrant-specific
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1


. ~/.bashrc

pushd devel
Expand Down