Browse code

update build machine to ubuntu 14.04.3

Change-Id: Ie6b8bf920fb2c47d24678c13fb6158041e35ac74
Reviewed-on: http://photon-jenkins.eng.vmware.com/291
Tested-by: jenkins-photon <wangnan2015@hotmail.com>
Reviewed-by: Sharath George

Ivan Porto Carrero authored on 2015/12/08 05:00:21
Showing 8 changed files
... ...
@@ -1,6 +1,70 @@
1 1
 # -*- mode: ruby -*-
2 2
 # vi: set ft=ruby :
3 3
 
4
+module OS
5
+  def OS.windows?
6
+    (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
7
+  end
8
+
9
+  def OS.mac?
10
+   (/darwin/ =~ RUBY_PLATFORM) != nil
11
+  end
12
+
13
+  def OS.unix?
14
+    !OS.windows?
15
+  end
16
+
17
+  def OS.linux?
18
+    OS.unix? and not OS.mac?
19
+  end
20
+end
21
+
22
+ENV['VAGRANT_DEFAULT_PROVIDER'] ||= OS.mac? ? 'vmware_fusion' : "vmware_workstation"
23
+
24
+fusion_path="/Applications/VMware Fusion.app/Contents/Library"
25
+if File.directory?(fusion_path)
26
+  ENV['PATH'] = "#{fusion_path}:#{ENV['PATH']}"
27
+end
28
+
29
+appcatalyst_path="/opt/vmware/appcatalyst/libexec"
30
+if File.directory?(appcatalyst_path)
31
+  ENV['PATH'] = "#{appcatalyst_path}:#{ENV['PATH']}"
32
+end
33
+
34
+# Hey Now! thanks StackOverflow: http://stackoverflow.com/a/28801317/1233435
35
+req_plugins = %w(vagrant-triggers)
36
+
37
+if OS.mac?
38
+  req_plugins << "vagrant-vmware-fusion" if File.directory?(fusion_path)
39
+  req_plugins << "vagrant-vmware-appcatalyst" if File.directory?(appcatalyst_path)
40
+else
41
+  req_plugins << "vagrant-vmware-workstation"
42
+end
43
+
44
+# Cycle through the required plugins and install what's missing.
45
+plugins_install = req_plugins.select { |plugin| !Vagrant.has_plugin? plugin }
46
+licensed_plugins = plugins_install.select { |plugin| plugin =~ /vagrant-vmware-(?:fusion|workstation)$/ }
47
+licensed_plugins.each do |plugin|
48
+  unless File.exist? "#{ENV["VAGRANT_VMWARE_LICENSE_FILE"]||"./#{plugin}.lic"}"
49
+    abort "Failed to configure license, you can configure the path with VAGRANT_VMWARE_LICENSE_FILE"
50
+  end
51
+end
52
+
53
+unless plugins_install.empty?
54
+  puts "Installing plugins: #{plugins_install.join(' ')}"
55
+  if system "vagrant plugin install #{plugins_install.join(' ')}"
56
+    exec "vagrant #{ARGV.join(' ')}"
57
+  else
58
+    abort 'Installation of one or more plugins has failed. Aborting.'
59
+  end
60
+end
61
+
62
+licensed_plugins.each do |plugin|
63
+  unless system "vagrant plugin license #{plugin} #{ENV["VAGRANT_VMWARE_LICENSE_FILE"]||"./#{plugin}.lic"}"
64
+    abort "Failed to configure license, you can configure the path with VAGRANT_VMWARE_LICENSE_FILE"
65
+  end
66
+end
67
+
4 68
 VAGRANTFILE_API_VERSION = '2'
5 69
 
6 70
 # VM configuration, as we're compiling an OS from scratch, make sure the
... ...
@@ -14,14 +78,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
14 14
 
15 15
   config.vm.box_check_update = false
16 16
 
17
-  config.vm.provider('vmware_fusion') do |v|
18
-    v.vmx['memsize'] = vm_config[:ram]
19
-    v.vmx['numvcpus'] = vm_config[:cpu]
20
-  end
21
-
22
-  config.vm.provider('vmware_workstation') do |v|
23
-    v.vmx['memsize'] = vm_config[:ram]
24
-    v.vmx['numvcpus'] = vm_config[:cpu]
17
+  %w(vmware_fusion vmware_workstation vmware_appcatalyst).each do |p|
18
+    config.vm.provider p do |v|
19
+      v.vmx['memsize'] = vm_config[:ram]
20
+      v.vmx['numvcpus'] = vm_config[:cpu]
21
+      v.vmx['ethernet0.virtualDev'] = 'vmxnet3'
22
+      v.vmx['vhv.enable'] = 'true'
23
+    end
25 24
   end
26 25
 
27 26
   # Sync the current folder as /workspaces/photon using rsync.
... ...
@@ -19,23 +19,19 @@ class Logger(object):
19 19
             # add formatter to handler
20 20
             fhandler.setFormatter(formatter)
21 21
             ch.setFormatter(formatter)
22
-            
22
+
23 23
             logger.addHandler(ch)
24 24
             logger.addHandler(fhandler)
25 25
             logger.setLevel(logging.DEBUG)
26 26
             logger.info("--------------------------------------------------------------------------")
27
-            logger.info("Staring Log")
27
+            logger.info("Starting Log")
28 28
             logger.info("--------------------------------------------------------------------------")
29 29
         return logger
30
-        
30
+
31 31
 if __name__ == "__main__":
32 32
     #Logger.getLogger("my module")
33 33
     t1 =  Logger.getLogger("my module")
34 34
     t1.info("test1")
35
-    t2  = Logger.getLogger("my module")  
35
+    t2  = Logger.getLogger("my module")
36 36
     t2.info("test2")
37 37
     t1.info("test3")
38
-       
39
-    
40
-        
41
-        
... ...
@@ -1,67 +1,62 @@
1 1
 {
2
-  "builders": [
3
-    {
4
-      "name": "photon-build-machine",
5
-      "vm_name": "photon-build-machine",
6
-      "vmdk_name": "photon-build-machine-disk0",
7
-      "type": "vmware-iso",
8
-      "headless": true,
9
-      "disk_size": 40960,
10
-      "disk_type_id": 0,
11
-      "guest_os_type": "ubuntu-64",
12
-      "iso_url": "http://ubuntu.bhs.mirrors.ovh.net/ftp.ubuntu.com/releases/trusty/ubuntu-14.04.2-server-amd64.iso",
13
-      "iso_checksum": "3bfa6eac84d527380d0cc52db9092cde127f161e",
14
-      "iso_checksum_type": "sha1",
15
-      "ssh_username": "vagrant",
16
-      "ssh_password": "vagrant",
17
-      "ssh_wait_timeout": "60m",
18
-      "shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now",
19
-      "http_directory": ".",
20
-      "tools_upload_flavor": "linux",
21
-      "boot_command": [
22
-        "<esc><esc><enter><wait>",
23
-        "/install/vmlinuz noapic ",
24
-        "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/scripts/ubuntu-preseed.cfg ",
25
-        "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
26
-        "hostname=photon-build-machine ",
27
-        "fb=false debconf/frontend=noninteractive ",
28
-        "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
29
-        "keyboard-configuration/variant=USA console-setup/ask_detect=false ",
30
-        "initrd=/install/initrd.gz -- <enter>"
31
-      ]
32
-    }
33
-  ],
34
-  "provisioners": [
35
-    {
36
-      "type": "shell",
37
-      "execute_command": "echo 'vagrant' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
38
-      "script": "scripts/ubuntu-vmware-tools_install.sh"
39
-    },
40
-    {
41
-      "type": "shell",
42
-      "execute_command": "echo 'vagrant' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
43
-      "script": "scripts/ubuntu-puppet_install.sh"
44
-    },
45
-    {
46
-      "type": "puppet-masterless",
47
-      "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}}",
48
-      "manifest_file": "puppet/manifests/vagrant.pp",
49
-      "manifest_dir": "puppet/manifests",
50
-      "module_paths": [
51
-        "puppet/modules"
52
-      ]
53
-    },
54
-    {
55
-      "type": "shell",
56
-      "execute_command": "echo 'vagrant' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
57
-      "script": "scripts/ubuntu-vmware-final_cleanup.sh"
58
-    }
59
-  ],
60
- "post-processors": [
61
-   {
62
-     "type": "vagrant",
63
-     "compression_level": 9,
64
-     "output": "{{.BuildName}}.box"
65
-   }
66
- ]
2
+  "builders": [{
3
+    "name": "photon-build-machine",
4
+    "vm_name": "photon-build-machine",
5
+    "vmdk_name": "photon-build-machine-disk0",
6
+    "type": "vmware-iso",
7
+    "headless": true,
8
+    "disk_size": 40960,
9
+    "disk_type_id": 0,
10
+    "guest_os_type": "ubuntu-64",
11
+    "iso_url": "http://ubuntu.bhs.mirrors.ovh.net/ftp.ubuntu.com/releases/trusty/ubuntu-14.04.3-server-amd64.iso",
12
+    "iso_checksum": "0501c446929f713eb162ae2088d8dc8b6426224a",
13
+    "iso_checksum_type": "sha1",
14
+    "ssh_username": "vagrant",
15
+    "ssh_password": "vagrant",
16
+    "ssh_wait_timeout": "60m",
17
+    "shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now",
18
+    "http_directory": ".",
19
+    "tools_upload_flavor": "linux",
20
+    "boot_command": [
21
+      "<esc><esc><enter><wait>",
22
+      "/install/vmlinuz noapic ",
23
+      "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/scripts/ubuntu-preseed.cfg ",
24
+      "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
25
+      "hostname=photon-build-machine ",
26
+      "fb=false debconf/frontend=noninteractive ",
27
+      "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
28
+      "keyboard-configuration/variant=USA console-setup/ask_detect=false ",
29
+      "initrd=/install/initrd.gz -- <enter>"
30
+    ]
31
+  }],
32
+  "provisioners": [{
33
+    "type": "shell",
34
+    "execute_command": "echo 'vagrant' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
35
+    "script": "scripts/ubuntu-vmware-tools_install.sh"
36
+  }, {
37
+    "type": "shell",
38
+    "execute_command": "echo 'vagrant' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
39
+    "script": "scripts/ubuntu-puppet_install.sh"
40
+  }, {
41
+    "type": "puppet-masterless",
42
+    "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}}",
43
+    "manifest_file": "puppet/manifests/vagrant.pp",
44
+    "manifest_dir": "puppet/manifests",
45
+    "module_paths": [
46
+      "puppet/modules"
47
+    ]
48
+  }, {
49
+    "type": "shell",
50
+    "execute_command": "echo 'vagrant' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
51
+    "script": "scripts/ubuntu-install-docker.sh"
52
+  }, {
53
+    "type": "shell",
54
+    "execute_command": "echo 'vagrant' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
55
+    "script": "scripts/ubuntu-vmware-final_cleanup.sh"
56
+  }],
57
+  "post-processors": [{
58
+    "type": "vagrant",
59
+    "compression_level": 9,
60
+    "output": "{{.BuildName}}.box"
61
+  }]
67 62
 }
... ...
@@ -19,7 +19,6 @@ class photonbuildsetup {
19 19
             'cifs-utils',
20 20
             'createrepo',
21 21
             'rpm',
22
-            'git',
23 22
             'htop',
24 23
             'python-aptdaemon',
25 24
             'gdisk',
26 25
new file mode 100644
... ...
@@ -0,0 +1,7 @@
0
+#!/bin/bash
1
+
2
+echo "==> Setting up docker from apt.dockerproject.org"
3
+sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
4
+echo 'deb https://apt.dockerproject.org/repo ubuntu-trusty main' | sudo tee /etc/apt/sources.list.d/docker.list
5
+sudo apt-get update
6
+sudo apt-get install -y docker-engine
... ...
@@ -93,7 +93,7 @@ d-i pkgsel/install-language-support boolean false
93 93
 # manage the VM, build tools and the kernel headers to compile VMware Tools
94 94
 # addons
95 95
 
96
-d-i pkgsel/include string openssh-server build-essential linux-kernel-headers bc
96
+d-i pkgsel/include string openssh-server build-essential linux-kernel-headers bc git-core unzip
97 97
 
98 98
 # Boot loader installation
99 99
 # ------------------------
... ...
@@ -109,4 +109,4 @@ d-i grub-installer/only_debian boolean true
109 109
 # Ubuntu show a final message once the installation is complete. This message is
110 110
 # affirmed so it doesn't block the installation process.
111 111
 
112
-d-i finish-install/reboot_in_progress note
113 112
\ No newline at end of file
113
+d-i finish-install/reboot_in_progress note
... ...
@@ -1,12 +1,10 @@
1 1
 #!/bin/bash
2
- 
3
-sudo mount -o loop ~/linux.iso /media/cdrom
4
-sudo cp /media/cdrom/VMwareTools*.tar.gz ~/
5
-tar xfz VMwareTools*.tar.gz
6
-cd ~/vmware-tools-distrib
7
-sudo ./vmware-install.pl -d
8
-sudo umount /media/cdrom
9
-cd ~
10
-rm -rf vmware-tools-distrib
11
-rm -f VMwareTools*.tar.gz
12
-rm linux.iso
13 2
\ No newline at end of file
3
+
4
+git clone https://github.com/rasa/vmware-tools-patches.git
5
+cd vmware-tools-patches
6
+sudo ./download-tools.sh 8.0.2
7
+sudo ./untar-and-patch.sh
8
+cd vmware-tools-distrib
9
+sudo ./vmware-install.pl -f -d --clobber-kernel-modules=pvscsi,vmblock,vmci,vmhgfs,vmmemctl,vmsync,vmxnet,vmxnet3,vsock
10
+cd "$HOME"
11
+rm -rf vmware-tools-patches
... ...
@@ -37,4 +37,4 @@ fi
37 37
 echo "Cleanup the build..."
38 38
 sudo make clean
39 39
 echo "Shutting down the photon build machine..."
40
-sudo shutdown -h now
40
+# sudo shutdown -h now