Closed kbens closed 4 years ago
Matt Tremblay (@mattt on slack) has come up with a starting point for this idea. I will reply with the Vagrant file example.
Currently we have to add a disk on the fly, which works but cleanup is not perfect yet. Vagrant destroy requires and additional folder deletion.
1. Update the box option in vagrant file to use Oracle Linux vagrant box
# Define the box we'll be using and automatically download the latest version
vmconfig.vm.box = "ol7-latest"
vmconfig.vm.box_url = "https://yum.oracle.com/boxes/oraclelinux/latest/ol7-latest.box"
vmconfig.vm.box_check_update = true
2. Add 2nd disk and extend volume group in vagrant file
# add 2nd disk at 100GB
disk = "disk2.vmdk"
config.vm.provider "virtualbox" do | p |
unless File.exist?(disk)
p.customize ['createhd', '--filename', disk, '--size', 100 * 1024]
end
p.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', disk]
end
# extend default volume group to increase drive space
$script = <<-SCRIPT
echo #######Extending volume group...########
echo -e "o\nn\np\n1\n\n\nw" | fdisk /dev/sdb
pvcreate /dev/sdb1
vgextend vg_main /dev/sdb1
lvextend -l +100%FREE /dev/mapper/vg_main-lv_root
xfs_growfs /dev/mapper/vg_main-lv_root
SCRIPT
vmconfig.vm.provision "shell", inline: $script
#It will add the 2nd disk to the vagrant home directory, which may not be ideal for some. I found this example of adding the disk
#to the vm's virtualbox folder, but I am not heavily versed in vagrant, so I was unable to get it working.
https://gist.github.com/leifg/4713995
3. add missing packages and JR's ps-extras repo in vagrant file
# install required packages
$extras = <<-SCRIPT
echo #######adding packages and repos...########
curl -s https://packagecloud.io/install/repositories/jrbing/ps-extras/script.rpm.sh | bash
yum install -y "aria2" "unzip" "samba" "samba-client" "samba-common"
SCRIPT
vmconfig.vm.provision "shell", inline: $extras"
Below is a modified version of the ps-vagabond vagrant file with the changes that has worked.
#############################################################################################################################################
#############################################################################################################################################
#############################################################################################################################################
# -*- mode: ruby -*-
# vi: set ft=ruby :
require_relative 'config/config'
required_plugins = {
'vagrant-vbguest' => '~>0.13.0'
}
needs_restart = false
required_plugins.each do |name, version|
unless Vagrant.has_plugin? name, version
system "vagrant plugin install #{name} --plugin-version=\"#{version}\""
needs_restart = true
end
end
if needs_restart
exec "vagrant #{ARGV.join' '}"
end
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define 'ps-vagabond' do |vmconfig|
# Increase the timeout limit for booting the VM
vmconfig.vm.boot_timeout = 600
# Increase the timeout limit for halting the VM
vmconfig.vm.graceful_halt_timeout = 600
# Define the box we'll be using and automatically download the latest version
vmconfig.vm.box = "ol7-latest"
vmconfig.vm.box_url = "https://yum.oracle.com/boxes/oraclelinux/latest/ol7-latest.box"
vmconfig.vm.box_check_update = true
# Sync folder to be used for downloading the dpks
vmconfig.vm.synced_folder "#{DPK_LOCAL_DIR}", "#{DPK_REMOTE_DIR}"
# add 2nd disk
disk = "./disk2.vmdk"
config.vm.provider "virtualbox" do | p |
unless File.exist?(disk)
p.customize ['createhd', '--filename', disk, '--size', 100 * 1024]
end
p.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', disk]
end
# extend default volume group to increase drive space
$script = <<-SCRIPT
echo #######Extending volume group...########
echo -e "o\nn\np\n1\n\n\nw" | fdisk /dev/sdb
pvcreate /dev/sdb1
vgextend vg_main /dev/sdb1
lvextend -l +100%FREE /dev/mapper/vg_main-lv_root
xfs_growfs /dev/mapper/vg_main-lv_root
SCRIPT
vmconfig.vm.provision "shell", inline: $script
# install required packages
$extras = <<-SCRIPT
echo #######adding packages and repos...########
curl -s https://packagecloud.io/install/repositories/jrbing/ps-extras/script.rpm.sh | bash
yum install -y "aria2" "unzip" "samba" "samba-client" "samba-common"
SCRIPT
vmconfig.vm.provision "shell", inline: $extras
#############
# Network #
#############
vmconfig.vm.hostname = "#{FQDN}"
# Host-only network adapter
if NETWORK_SETTINGS[:type] == "hostonly"
config.vm.network "private_network", type: "dhcp"
config.vm.network "forwarded_port",
guest: NETWORK_SETTINGS[:guest_http_port],
host: NETWORK_SETTINGS[:host_http_port]
config.vm.network "forwarded_port",
guest: NETWORK_SETTINGS[:guest_listener_port],
host: NETWORK_SETTINGS[:host_listener_port]
end
# Bridged network adapter
if NETWORK_SETTINGS[:type] == "bridged"
vmconfig.vm.network "public_network", ip: "#{NETWORK_SETTINGS[:ip_address]}"
# The following is necessary when using the bridged network adapter
# in order to make the machine available from other networks.
config.vm.provision "shell",
run: "always",
inline: "route add default gw #{NETWORK_SETTINGS[:gateway]}"
config.vm.provision "shell",
run: "always",
inline: "eval `route -n | awk '{ if ($8 ==\"eth0\" && $2 != \"0.0.0.0\") print \"route del default gw \" $2; }'`"
end
################################
# Provider-specific Settings #
################################
# VirtualBox
vmconfig.vm.provider "virtualbox" do |vbox,override|
vbox.name = "#{DPK_VERSION}"
vbox.memory = 8192
vbox.cpus = 2
#vbox.linked_clone = true if Vagrant::VERSION =~ /^1.8/
end
# HyperV
vmconfig.vm.provider "hyperv" do |hyperv|
hyperv.vmname = "#{DPK_VERSION}"
hyperv.memory = 8192
hyperv.cpus = 2
hyperv.vm_integration_services = {
guest_service_interface: true,
heartbeat: true,
key_value_pair_exchange: true,
shutdown: true,
time_synchronization: true,
vss: true
}
end
##################
# Provisioning #
##################
vmconfig.vm.provision "shell" do |script|
script.path = "scripts/provision.sh"
script.upload_path = "/tmp/provision.sh"
script.env = {
"MOS_USERNAME" => "#{MOS_USERNAME}",
"MOS_PASSWORD" => "#{MOS_PASSWORD}",
"PATCH_ID" => "#{PATCH_ID}",
"DPK_INSTALL" => "#{DPK_REMOTE_DIR}/#{PATCH_ID}"
}
end
##################
# Notification #
##################
# Vagrant-Pushover Notification
# https://github.com/tcnksm/vagrant-pushover
# install: vagrant plugin install vagrant-pushover
# initialize: vagrant pushover-init
# configure: $EDITOR .vagrant/pushover.rb
if Vagrant.has_plugin?("vagrant-pushover")
config.pushover.read_key
end
#################
# Workarounds #
#################
# Workaround for issue with Vagrant 1.8.5
# https://github.com/mitchellh/vagrant/issues/7610
vmconfig.ssh.insert_key = false if Vagrant::VERSION == '1.8.5'
end
end
This does deserve revisiting. With PeopleTools 8.57 dropping and PI's shipping on it soon, we'll need to make some updates to the project anyway. To start with, we'd need to review the Packer scripts used to build the OEL box and see if we can move the build steps into Vagabond's provisioning.
https://github.com/psadmin-io/ps-vagabond-packer/tree/master/scripts/oel
Doing some work on this. Samba does not reliably start when building new PI's. Could not start Service[samba]: Execution of '/bin/systemctl start smb' returned 1
abdf62e54afc687aa1e6c209bcd827145bf5f99e
I have branch that is ready to test. oel-boxes
has code changes in place to support the ol7-latest
OEL Vagrant box from Oracle. @ostracize you can to build a PI with this branch and verify that the vagrant-vbguest issues go away when using the OEL box (#77).
Need to the output from the new functions when they are not run with DEBUG mode on. Output is pretty messy with these changes right now.
Taking another run at this. The official Oracle Vagrant boxes are not playing nice with adding a second disk so we have space for PeopleSoft. Looking at using the bento/oracle-7.7
box instead. Similar to the Oracle Vagrant boxes, they are updated more frequently and are vanilla.
Also looking to address #77 and the issues with the vbguest installation.
The changes for this were committed to master
with PR #88. Closing this issue.
Oracle is now shipping their own vagrant boxes for Oracle Linux. Should we change to use these? I know JR did some awesome work on trimming down the size, etc on the box we currently use. But using the official box might be easier to maintain going forward.
http://yum.oracle.com/boxes/