Skip to content

Commit

Permalink
update build machine to ubuntu 14.04.3
Browse files Browse the repository at this point in the history
Change-Id: Ie6b8bf920fb2c47d24678c13fb6158041e35ac74
Reviewed-on: http://photon-jenkins.eng.vmware.com/291
Tested-by: jenkins-photon <[email protected]>
Reviewed-by: Sharath George
  • Loading branch information
Ivan Porto Carrero authored and Sharath George committed Jan 6, 2016
1 parent f500105 commit 08594ed
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 96 deletions.
79 changes: 71 additions & 8 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,70 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

module OS
def OS.windows?
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
end

def OS.mac?
(/darwin/ =~ RUBY_PLATFORM) != nil
end

def OS.unix?
!OS.windows?
end

def OS.linux?
OS.unix? and not OS.mac?
end
end

ENV['VAGRANT_DEFAULT_PROVIDER'] ||= OS.mac? ? 'vmware_fusion' : "vmware_workstation"

fusion_path="/Applications/VMware Fusion.app/Contents/Library"
if File.directory?(fusion_path)
ENV['PATH'] = "#{fusion_path}:#{ENV['PATH']}"
end

appcatalyst_path="/opt/vmware/appcatalyst/libexec"
if File.directory?(appcatalyst_path)
ENV['PATH'] = "#{appcatalyst_path}:#{ENV['PATH']}"
end

# Hey Now! thanks StackOverflow: http://stackoverflow.com/a/28801317/1233435
req_plugins = %w(vagrant-triggers)

if OS.mac?
req_plugins << "vagrant-vmware-fusion" if File.directory?(fusion_path)
req_plugins << "vagrant-vmware-appcatalyst" if File.directory?(appcatalyst_path)
else
req_plugins << "vagrant-vmware-workstation"
end

# Cycle through the required plugins and install what's missing.
plugins_install = req_plugins.select { |plugin| !Vagrant.has_plugin? plugin }
licensed_plugins = plugins_install.select { |plugin| plugin =~ /vagrant-vmware-(?:fusion|workstation)$/ }
licensed_plugins.each do |plugin|
unless File.exist? "#{ENV["VAGRANT_VMWARE_LICENSE_FILE"]||"./#{plugin}.lic"}"
abort "Failed to configure license, you can configure the path with VAGRANT_VMWARE_LICENSE_FILE"
end
end

unless plugins_install.empty?
puts "Installing plugins: #{plugins_install.join(' ')}"
if system "vagrant plugin install #{plugins_install.join(' ')}"
exec "vagrant #{ARGV.join(' ')}"
else
abort 'Installation of one or more plugins has failed. Aborting.'
end
end

licensed_plugins.each do |plugin|
unless system "vagrant plugin license #{plugin} #{ENV["VAGRANT_VMWARE_LICENSE_FILE"]||"./#{plugin}.lic"}"
abort "Failed to configure license, you can configure the path with VAGRANT_VMWARE_LICENSE_FILE"
end
end

VAGRANTFILE_API_VERSION = '2'

# VM configuration, as we're compiling an OS from scratch, make sure the
Expand All @@ -14,14 +78,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

config.vm.box_check_update = false

config.vm.provider('vmware_fusion') do |v|
v.vmx['memsize'] = vm_config[:ram]
v.vmx['numvcpus'] = vm_config[:cpu]
end

config.vm.provider('vmware_workstation') do |v|
v.vmx['memsize'] = vm_config[:ram]
v.vmx['numvcpus'] = vm_config[:cpu]
%w(vmware_fusion vmware_workstation vmware_appcatalyst).each do |p|
config.vm.provider p do |v|
v.vmx['memsize'] = vm_config[:ram]
v.vmx['numvcpus'] = vm_config[:cpu]
v.vmx['ethernet0.virtualDev'] = 'vmxnet3'
v.vmx['vhv.enable'] = 'true'
end
end

# Sync the current folder as /workspaces/photon using rsync.
Expand Down
12 changes: 4 additions & 8 deletions support/package-builder/Logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,19 @@ def getLogger (mymodule, logpath=None):
# add formatter to handler
fhandler.setFormatter(formatter)
ch.setFormatter(formatter)

logger.addHandler(ch)
logger.addHandler(fhandler)
logger.setLevel(logging.DEBUG)
logger.info("--------------------------------------------------------------------------")
logger.info("Staring Log")
logger.info("Starting Log")
logger.info("--------------------------------------------------------------------------")
return logger

if __name__ == "__main__":
#Logger.getLogger("my module")
t1 = Logger.getLogger("my module")
t1.info("test1")
t2 = Logger.getLogger("my module")
t2 = Logger.getLogger("my module")
t2.info("test2")
t1.info("test3")




125 changes: 60 additions & 65 deletions support/packer-templates/photon-build-machine.json
Original file line number Diff line number Diff line change
@@ -1,67 +1,62 @@
{
"builders": [
{
"name": "photon-build-machine",
"vm_name": "photon-build-machine",
"vmdk_name": "photon-build-machine-disk0",
"type": "vmware-iso",
"headless": true,
"disk_size": 40960,
"disk_type_id": 0,
"guest_os_type": "ubuntu-64",
"iso_url": "http://ubuntu.bhs.mirrors.ovh.net/ftp.ubuntu.com/releases/trusty/ubuntu-14.04.2-server-amd64.iso",
"iso_checksum": "3bfa6eac84d527380d0cc52db9092cde127f161e",
"iso_checksum_type": "sha1",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "60m",
"shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now",
"http_directory": ".",
"tools_upload_flavor": "linux",
"boot_command": [
"<esc><esc><enter><wait>",
"/install/vmlinuz noapic ",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/scripts/ubuntu-preseed.cfg ",
"debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
"hostname=photon-build-machine ",
"fb=false debconf/frontend=noninteractive ",
"keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
"keyboard-configuration/variant=USA console-setup/ask_detect=false ",
"initrd=/install/initrd.gz -- <enter>"
]
}
],
"provisioners": [
{
"type": "shell",
"execute_command": "echo 'vagrant' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
"script": "scripts/ubuntu-vmware-tools_install.sh"
},
{
"type": "shell",
"execute_command": "echo 'vagrant' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
"script": "scripts/ubuntu-puppet_install.sh"
},
{
"type": "puppet-masterless",
"execute_command": "{{.FacterVars}}{{if .Sudo}} echo 'vagrant' | sudo -E -S {{end}} puppet apply --verbose --modulepath='{{.ModulePath}}' {{if ne .HieraConfigPath \"\"}}--hiera_config='{{.HieraConfigPath}}' {{end}} {{if ne .ManifestDir \"\"}}--manifestdir='{{.ManifestDir}}' {{end}} --detailed-exitcodes {{.ManifestFile}}",
"manifest_file": "puppet/manifests/vagrant.pp",
"manifest_dir": "puppet/manifests",
"module_paths": [
"puppet/modules"
]
},
{
"type": "shell",
"execute_command": "echo 'vagrant' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
"script": "scripts/ubuntu-vmware-final_cleanup.sh"
}
],
"post-processors": [
{
"type": "vagrant",
"compression_level": 9,
"output": "{{.BuildName}}.box"
}
]
"builders": [{
"name": "photon-build-machine",
"vm_name": "photon-build-machine",
"vmdk_name": "photon-build-machine-disk0",
"type": "vmware-iso",
"headless": true,
"disk_size": 40960,
"disk_type_id": 0,
"guest_os_type": "ubuntu-64",
"iso_url": "http://ubuntu.bhs.mirrors.ovh.net/ftp.ubuntu.com/releases/trusty/ubuntu-14.04.3-server-amd64.iso",
"iso_checksum": "0501c446929f713eb162ae2088d8dc8b6426224a",
"iso_checksum_type": "sha1",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "60m",
"shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now",
"http_directory": ".",
"tools_upload_flavor": "linux",
"boot_command": [
"<esc><esc><enter><wait>",
"/install/vmlinuz noapic ",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/scripts/ubuntu-preseed.cfg ",
"debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
"hostname=photon-build-machine ",
"fb=false debconf/frontend=noninteractive ",
"keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
"keyboard-configuration/variant=USA console-setup/ask_detect=false ",
"initrd=/install/initrd.gz -- <enter>"
]
}],
"provisioners": [{
"type": "shell",
"execute_command": "echo 'vagrant' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
"script": "scripts/ubuntu-vmware-tools_install.sh"
}, {
"type": "shell",
"execute_command": "echo 'vagrant' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
"script": "scripts/ubuntu-puppet_install.sh"
}, {
"type": "puppet-masterless",
"execute_command": "{{.FacterVars}}{{if .Sudo}} echo 'vagrant' | sudo -E -S {{end}} puppet apply --verbose --modulepath='{{.ModulePath}}' {{if ne .HieraConfigPath \"\"}}--hiera_config='{{.HieraConfigPath}}' {{end}} {{if ne .ManifestDir \"\"}}--manifestdir='{{.ManifestDir}}' {{end}} --detailed-exitcodes {{.ManifestFile}}",
"manifest_file": "puppet/manifests/vagrant.pp",
"manifest_dir": "puppet/manifests",
"module_paths": [
"puppet/modules"
]
}, {
"type": "shell",
"execute_command": "echo 'vagrant' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
"script": "scripts/ubuntu-install-docker.sh"
}, {
"type": "shell",
"execute_command": "echo 'vagrant' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
"script": "scripts/ubuntu-vmware-final_cleanup.sh"
}],
"post-processors": [{
"type": "vagrant",
"compression_level": 9,
"output": "{{.BuildName}}.box"
}]
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
'cifs-utils',
'createrepo',
'rpm',
'git',
'htop',
'python-aptdaemon',
'gdisk',
Expand Down
7 changes: 7 additions & 0 deletions support/packer-templates/scripts/ubuntu-install-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

echo "==> Setting up docker from apt.dockerproject.org"
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo 'deb https://apt.dockerproject.org/repo ubuntu-trusty main' | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
sudo apt-get install -y docker-engine
4 changes: 2 additions & 2 deletions support/packer-templates/scripts/ubuntu-preseed.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ d-i pkgsel/install-language-support boolean false
# manage the VM, build tools and the kernel headers to compile VMware Tools
# addons

d-i pkgsel/include string openssh-server build-essential linux-kernel-headers bc
d-i pkgsel/include string openssh-server build-essential linux-kernel-headers bc git-core unzip

# Boot loader installation
# ------------------------
Expand All @@ -109,4 +109,4 @@ d-i grub-installer/only_debian boolean true
# Ubuntu show a final message once the installation is complete. This message is
# affirmed so it doesn't block the installation process.

d-i finish-install/reboot_in_progress note
d-i finish-install/reboot_in_progress note
20 changes: 9 additions & 11 deletions support/packer-templates/scripts/ubuntu-vmware-tools_install.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/bin/bash

sudo mount -o loop ~/linux.iso /media/cdrom
sudo cp /media/cdrom/VMwareTools*.tar.gz ~/
tar xfz VMwareTools*.tar.gz
cd ~/vmware-tools-distrib
sudo ./vmware-install.pl -d
sudo umount /media/cdrom
cd ~
rm -rf vmware-tools-distrib
rm -f VMwareTools*.tar.gz
rm linux.iso

git clone https://github.com/rasa/vmware-tools-patches.git
cd vmware-tools-patches
sudo ./download-tools.sh 8.0.2
sudo ./untar-and-patch.sh
cd vmware-tools-distrib
sudo ./vmware-install.pl -f -d --clobber-kernel-modules=pvscsi,vmblock,vmci,vmhgfs,vmmemctl,vmsync,vmxnet,vmxnet3,vsock
cd "$HOME"
rm -rf vmware-tools-patches
2 changes: 1 addition & 1 deletion support/vagrant/photon-build-machine-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ fi
echo "Cleanup the build..."
sudo make clean
echo "Shutting down the photon build machine..."
sudo shutdown -h now
# sudo shutdown -h now

0 comments on commit 08594ed

Please sign in to comment.