- Added vCloud Air builds
- Build options for VMware and/or vCloud Air Vagrant artifacts
Signed-off-by: Tom McPhail <tmcphail@vmware.com>
| ... | ... |
@@ -18,7 +18,7 @@ else |
| 18 | 18 |
PHOTON_SOURCES := sources |
| 19 | 19 |
endif |
| 20 | 20 |
|
| 21 |
-.PHONY : all iso clean toolchain toolchain-minimal photon-build-machine photon-vagrant-box \ |
|
| 21 |
+.PHONY : all iso clean toolchain toolchain-minimal photon-build-machine photon-vagrant-build photon-vagrant-local \ |
|
| 22 | 22 |
check check-bison check-g++ check-gawk check-createrepo check-vagrant check-packer check-packer-ovf-plugin |
| 23 | 23 |
|
| 24 | 24 |
all: iso |
| ... | ... |
@@ -55,7 +55,7 @@ sources: |
| 55 | 55 |
@cd $(PHOTON_PULL_SOURCES_DIR) && \ |
| 56 | 56 |
$(PHOTON_PULL_SOURCES) $(PHOTON_SRCS_DIR) |
| 57 | 57 |
|
| 58 |
-sources-cached: |
|
| 58 |
+sources-cached: |
|
| 59 | 59 |
@echo "Using cached SOURCES..." |
| 60 | 60 |
@$(MKDIR) -p $(PHOTON_SRCS_DIR) && \ |
| 61 | 61 |
$(CP) -rf $(PHOTON_SOURCES_PATH)/* $(PHOTON_SRCS_DIR)/ |
| ... | ... |
@@ -140,18 +140,33 @@ photon-build-machine: check-packer check-vagrant |
| 140 | 140 |
@cd $(PHOTON_PACKER_TEMPLATES) && \ |
| 141 | 141 |
$(PACKER) build photon-build-machine.json |
| 142 | 142 |
@echo "Adding box to Vagrant boxes..." |
| 143 |
- @$(VAGRANT) box add $(PHOTON_PACKER_TEMPLATES)/photon-build-machine-vmware.box --name photon-build-machine --force && \ |
|
| 144 |
- $(RM) $(PHOTON_PACKER_TEMPLATES)/photon-build-machine-vmware.box |
|
| 143 |
+ @$(VAGRANT) box add $(PHOTON_PACKER_TEMPLATES)/photon-build-machine.box --name photon-build-machine --force && \ |
|
| 144 |
+ $(RM) $(PHOTON_PACKER_TEMPLATES)/photon-build-machine.box |
|
| 145 | 145 |
|
| 146 |
-photon-vagrant-box: check-packer check-vagrant |
|
| 147 |
- @echo "Building a photon based Vagrant box with Packer..." |
|
| 146 |
+photon-vagrant-build: check-vagrant |
|
| 147 |
+ @echo "Starting Photon build using Vagrant..." |
|
| 148 |
+ @cd $(SRCROOT) && \ |
|
| 149 |
+ $(VAGRANT) up && \ |
|
| 150 |
+ $(VAGRANT) destroy -f |
|
| 151 |
+ |
|
| 152 |
+ifeq ($(VAGRANT_BUILD),all) |
|
| 153 |
+PACKER_ARGS="" |
|
| 154 |
+else |
|
| 155 |
+PACKER_ARGS="-only=$(VAGRANT_BUILD)" |
|
| 156 |
+endif |
|
| 157 |
+ |
|
| 158 |
+photon-vagrant-local: check-packer check-vagrant |
|
| 159 |
+ |
|
| 160 |
+ @echo "Building a Photon Vagrant box with Packer..." |
|
| 148 | 161 |
@if [ -e $(PHOTON_STAGE)/photon.iso ]; then \ |
| 149 | 162 |
cd $(PHOTON_PACKER_TEMPLATES) && \ |
| 150 |
- $(SED) -i "" -e "s#\"iso_checksum_value\":.*#\"iso_checksum_value\": \"$$($(SHASUM) ../../stage/photon.iso | cut -f 1 -d ' ')\"#" photon.json && \ |
|
| 151 |
- $(PACKER) build photon.json && \ |
|
| 152 |
- $(SED) -i "" -e "s#\"iso_checksum_value\":.*#\"iso_checksum_value\": \"\"#" photon.json && \ |
|
| 163 |
+ $(SED) -i "" -e "s#\"iso_checksum_value\":.*#\"iso_checksum_value\": \"$$($(SHASUM) ../../stage/photon.iso | cut -f 1 -d ' ')\",#" photon.json && \ |
|
| 164 |
+ $(PACKER) build $(PACKER_ARGS) photon.json && \ |
|
| 165 |
+ $(SED) -i "" -e "s#\"iso_checksum_value\":.*#\"iso_checksum_value\": \"\",#" photon.json; \ |
|
| 153 | 166 |
echo "Moving boxes to $(PHOTON_STAGE)..." && \ |
| 154 | 167 |
$(MV) *.box $(PHOTON_STAGE); \ |
| 168 |
+ else \ |
|
| 169 |
+ echo "Unable to find $(PHOTON_STAGE)/photon.iso ... aborting build"; \ |
|
| 155 | 170 |
fi |
| 156 | 171 |
|
| 157 | 172 |
check: check-bison check-g++ check-gawk check-createrepo |
| ... | ... |
@@ -171,7 +186,14 @@ check-createrepo: |
| 171 | 171 |
check-vagrant: check-packer |
| 172 | 172 |
@command -v $(VAGRANT) >/dev/null 2>&1 || { echo "Vagrant not installed or wrong path, expecting $(VAGRANT). Aborting" >&2; exit 1; }
|
| 173 | 173 |
|
| 174 |
+ |
|
| 175 |
+ifeq ($(VAGRANT_BUILD),vcloudair) |
|
| 176 |
+check-packer: check-packer-ovf-plugin |
|
| 177 |
+else ifeq ($(VAGRANT_BUILD),all) |
|
| 174 | 178 |
check-packer: check-packer-ovf-plugin |
| 179 |
+else |
|
| 180 |
+check-packer: |
|
| 181 |
+endif |
|
| 175 | 182 |
@command -v $(PACKER) >/dev/null 2>&1 || { echo "Packer not installed or wrong path, expecting $(PACKER). Aborting" >&2; exit 1; }
|
| 176 | 183 |
|
| 177 | 184 |
check-packer-ovf-plugin: |
| ... | ... |
@@ -2,23 +2,26 @@ |
| 2 | 2 |
|
| 3 | 3 |
This directory contains [Packer](http://packer.io) templates for `photon-build-machine` and to build a generic `photon` Vagrant box with `docker` binding on `0.0.0.0:2375`. |
| 4 | 4 |
|
| 5 |
-`photon-build-machine` is a Ubuntu 14.04.1 that contains all the prerequisites to build Photon from scratch, and is the box referenced by the top-level Vagrantfile, to build this machine you will need: |
|
| 5 |
+`photon-build-machine` is a Ubuntu 14.04.2 that contains all the prerequisites to build Photon from scratch, and is the box referenced by the top-level Vagrantfile, to build this machine you will need: |
|
| 6 | 6 |
|
| 7 | 7 |
- VMware Workstation (on Windows and Linux) or Fusion (on Mac OS X) |
| 8 | 8 |
- A recent Packer install (tested on v0.7.5) |
| 9 |
+- Packer OVF Post Processor from [GitHub](https://github.com/gosddc/packer-post-processor-vagrant-vmware-ovf) (Optional for vCloud Air build) |
|
| 10 |
+- Vagrant vCloud Air Provider from [GitHub](https://github.com/gosddc/vagrant-vcloudair) (Optional for vCloud Air usage) |
|
| 9 | 11 |
|
| 10 | 12 |
### Automatic build machine |
| 11 | 13 |
To automatically build the `photon-build-machine` and push into the local Vagrant box repository use the make target from the root of the Photon source: |
| 12 | 14 |
``` |
| 13 |
-sudo make photon-build-machine |
|
| 15 |
+make photon-build-machine |
|
| 14 | 16 |
``` |
| 15 | 17 |
|
| 16 | 18 |
### Build an ISO using a Vagrant based build machine |
| 17 |
-To automatically build the `photon-build-machine` and push into the local Vagrant box repository use the make target: |
|
| 19 |
+Assuming that the `photon-build-machine` has been created and resides in your local Vagrant repository, running `vagrant up` from the source root will automatically build a new `photon.iso` using the `photon-build-machine` Vagrant box and copy this onto the host into the `stage` directory. The machine will be halted at the completion of the build and can be reused or destroyed using `vagrant destroy` |
|
| 20 |
+ |
|
| 21 |
+Alternatively use the convenience make target to run the build process and destroy the machine on completion: |
|
| 18 | 22 |
``` |
| 19 |
-sudo make photon-build-machine |
|
| 23 |
+make photon-vagrant-build |
|
| 20 | 24 |
``` |
| 21 |
-Running `vagrant up` from the source root will automatically build a new `photon.iso` using the `photon-build-machine` Vagrant box and copy this onto the host into the `stage` directory. The machine will be halted at the completion of the build and can be reused or destroyed using `vagrant destroy` |
|
| 22 | 25 |
|
| 23 | 26 |
#### Troubleshooting |
| 24 | 27 |
|
| ... | ... |
@@ -27,8 +30,16 @@ By default Packer will run headless when building the `photon-build-machine` vm, |
| 27 | 27 |
## Photon Vagrant box with Docker |
| 28 | 28 |
To build a new Photon Vagrant box and make it available in the `stage` directory use the make target from the root of the Photon source: |
| 29 | 29 |
``` |
| 30 |
-sudo make photon-vagrant-box |
|
| 30 |
+make photon-vagrant-local |
|
| 31 | 31 |
``` |
| 32 |
+By default this process will build a Vagrant box using the vmware provider which can be used with VMware Fusion or Workstation. Setting the VAGRANT_BUILD variable allows finer control of the build output: |
|
| 33 |
+ |
|
| 34 |
+1. Vagrant only (default) ```make photon-vagrant-local``` OR explicit version ```make photon-vagrant-local VAGRANT_BUILD=vagrant``` |
|
| 35 |
+2. vCloud Air or vCloud ```make photon-vagrant-local VAGRANT_BUILD=vcloudair``` |
|
| 36 |
+3. All builds ```make photon-vagrant-local VAGRANT_BUILD=all``` |
|
| 37 |
+ |
|
| 32 | 38 |
The Vagrant box is configured to start a Docker service daemon bound to 0.0.0.0:2375 which is remapped to your host for convenience. Export DOCKER_HOST=tcp://127.0.0.1:2375 to use. |
| 33 | 39 |
|
| 40 |
+A sample Vagrantfile for use with vCloud Air resides in ```support/vagrant/Vagrantfile_VCA_Sample```, refer to the [vagrant-vcloudair](https://github.com/gosddc/vagrant-vcloudair) for advanced usage details. |
|
| 41 |
+ |
|
| 34 | 42 |
The box is configured to match the Vagrant base box standards, however it is not meant as an official Vagrant box build for Photon but rather as a starting point to create your own. |
| ... | ... |
@@ -49,7 +49,7 @@ |
| 49 | 49 |
"manifest_dir": "puppet/manifests", |
| 50 | 50 |
"module_paths": [ |
| 51 | 51 |
"puppet/modules" |
| 52 |
- ] |
|
| 52 |
+ ] |
|
| 53 | 53 |
}, |
| 54 | 54 |
{
|
| 55 | 55 |
"type": "shell", |
| ... | ... |
@@ -61,7 +61,7 @@ |
| 61 | 61 |
{
|
| 62 | 62 |
"type": "vagrant", |
| 63 | 63 |
"compression_level": 9, |
| 64 |
- "output": "{{.BuildName}}-{{.Provider}}.box"
|
|
| 64 |
+ "output": "{{.BuildName}}.box"
|
|
| 65 | 65 |
} |
| 66 | 66 |
] |
| 67 | 67 |
} |
| ... | ... |
@@ -1,38 +1,80 @@ |
| 1 | 1 |
{
|
| 2 | 2 |
"variables": {
|
| 3 | 3 |
"iso_file": "../../stage/photon.iso", |
| 4 |
- "iso_checksum_value": "" |
|
| 4 |
+ "iso_checksum_value": "99afd5b3280ba91be67907ae2d3be79c05ba3067", |
|
| 5 |
+ "product_name": "Photon", |
|
| 6 |
+ "product_version": "1.0", |
|
| 7 |
+ "headless": "true", |
|
| 8 |
+ "disk_size": "204080", |
|
| 9 |
+ "ssh_password": "VMware123!", |
|
| 10 |
+ "ssh_wait_timeout": "5m", |
|
| 11 |
+ "shutdown_command": "shutdown -h now" |
|
| 5 | 12 |
}, |
| 6 | 13 |
"builders": [ |
| 7 | 14 |
{
|
| 8 |
- "name": "photon", |
|
| 15 |
+ "name": "vagrant", |
|
| 9 | 16 |
"vm_name": "photon", |
| 10 | 17 |
"vmdk_name": "photon-disk0", |
| 11 | 18 |
"type": "vmware-iso", |
| 12 |
- "headless": true, |
|
| 13 |
- "disk_size": 20480, |
|
| 19 |
+ "headless": "{{user `headless`}}",
|
|
| 20 |
+ "disk_size": "{{user `disk_size`}}",
|
|
| 14 | 21 |
"disk_type_id": 0, |
| 15 | 22 |
"guest_os_type": "other3xlinux-64", |
| 16 | 23 |
"iso_url": "{{user `iso_file`}}",
|
| 17 | 24 |
"iso_checksum": "{{user `iso_checksum_value`}}",
|
| 18 | 25 |
"iso_checksum_type": "sha1", |
| 19 | 26 |
"ssh_username": "root", |
| 20 |
- "ssh_password": "VMware123!", |
|
| 21 |
- "ssh_wait_timeout": "60m", |
|
| 27 |
+ "ssh_password": "{{user `ssh_password`}}",
|
|
| 28 |
+ "ssh_wait_timeout": "{{user `ssh_wait_timeout`}}",
|
|
| 22 | 29 |
"shutdown_command": "shutdown -h now", |
| 23 | 30 |
"http_directory": ".", |
| 24 | 31 |
"boot_command": [ |
| 25 | 32 |
"<enter>", |
| 26 |
- "<wait5><enter><enter>", |
|
| 33 |
+ "<wait5><enter><enter><enter>", |
|
| 27 | 34 |
"<down><down><enter><wait>", |
| 28 | 35 |
"photon<enter><wait>", |
| 29 |
- "VMware123!<enter><wait>", |
|
| 36 |
+ "{{user `ssh_password`}}<enter>",
|
|
| 37 |
+ "<wait10><wait10><wait10><wait10><wait10><wait10><wait10>", |
|
| 30 | 38 |
"<enter>", |
| 31 |
- "<wait10><wait10><wait10><wait10><wait10><wait10>", |
|
| 32 |
- "root<enter><wait>VMware123!<enter><wait>", |
|
| 39 |
+ "<wait10><wait10><wait10>", |
|
| 40 |
+ "root<enter><wait>{{user `ssh_password`}}<enter><wait>",
|
|
| 33 | 41 |
"sed -i -e 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config<enter>", |
| 34 |
- "<wait10><wait10><wait10><wait10><wait10><wait10>", |
|
| 35 |
- "systemctl restart sshd.service<enter>" |
|
| 42 |
+ "<wait>", |
|
| 43 |
+ "systemctl restart sshd.service<enter>", |
|
| 44 |
+ "<wait5>" |
|
| 45 |
+ ] |
|
| 46 |
+ }, |
|
| 47 |
+ {
|
|
| 48 |
+ "name": "vcloudair", |
|
| 49 |
+ "vm_name": "photon", |
|
| 50 |
+ "vmdk_name": "photon-disk0", |
|
| 51 |
+ "type": "vmware-iso", |
|
| 52 |
+ "headless": "{{user `headless`}}",
|
|
| 53 |
+ "disk_size": "{{user `disk_size`}}",
|
|
| 54 |
+ "disk_type_id": 0, |
|
| 55 |
+ "guest_os_type": "other3xlinux-64", |
|
| 56 |
+ "iso_url": "{{user `iso_file`}}",
|
|
| 57 |
+ "iso_checksum": "{{user `iso_checksum_value`}}",
|
|
| 58 |
+ "iso_checksum_type": "sha1", |
|
| 59 |
+ "ssh_username": "root", |
|
| 60 |
+ "ssh_password": "{{user `ssh_password`}}",
|
|
| 61 |
+ "ssh_wait_timeout": "{{user `ssh_wait_timeout`}}",
|
|
| 62 |
+ "shutdown_command": "shutdown -h now", |
|
| 63 |
+ "http_directory": ".", |
|
| 64 |
+ "boot_command": [ |
|
| 65 |
+ "<enter>", |
|
| 66 |
+ "<wait5><enter><enter><enter>", |
|
| 67 |
+ "<down><down><enter><wait>", |
|
| 68 |
+ "photon<enter><wait>", |
|
| 69 |
+ "{{user `ssh_password`}}<enter>",
|
|
| 70 |
+ "<wait10><wait10><wait10><wait10><wait10><wait10><wait10>", |
|
| 71 |
+ "<enter>", |
|
| 72 |
+ "<wait10><wait10><wait10>", |
|
| 73 |
+ "root<enter><wait>{{user `ssh_password`}}<enter><wait>",
|
|
| 74 |
+ "sed -i -e 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config<enter>", |
|
| 75 |
+ "<wait>", |
|
| 76 |
+ "systemctl restart sshd.service<enter>", |
|
| 77 |
+ "<wait5>" |
|
| 36 | 78 |
] |
| 37 | 79 |
} |
| 38 | 80 |
], |
| ... | ... |
@@ -50,8 +92,17 @@ |
| 50 | 50 |
"post-processors": [ |
| 51 | 51 |
{
|
| 52 | 52 |
"type": "vagrant", |
| 53 |
+ "only": ["vagrant"], |
|
| 54 |
+ "compression_level": 9, |
|
| 55 |
+ "vagrantfile_template": "scripts/photon-vagrantfile_template.rb", |
|
| 56 |
+ "output": "{{user `product_name`}}-{{.BuildName}}.box"
|
|
| 57 |
+ }, |
|
| 58 |
+ {
|
|
| 59 |
+ "type": "vagrant-vmware-ovf", |
|
| 60 |
+ "only": ["vcloudair"], |
|
| 53 | 61 |
"compression_level": 9, |
| 54 |
- "vagrantfile_template": "scripts/photon-vagrantfile_template.rb" |
|
| 62 |
+ "vagrantfile_template": "scripts/photon-vagrantfile_template.rb", |
|
| 63 |
+ "output": "{{user `product_name`}}-{{.BuildName}}.box"
|
|
| 55 | 64 |
} |
| 56 | 65 |
] |
| 57 | 66 |
|
| 58 | 67 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,38 @@ |
| 0 |
+# -*- mode: ruby -*- |
|
| 1 |
+# vi: set ft=ruby : |
|
| 2 |
+ |
|
| 3 |
+# Set our default provider for this Vagrantfile to 'vcloudair' |
|
| 4 |
+ENV['VAGRANT_DEFAULT_PROVIDER'] = 'vcloudair' |
|
| 5 |
+ |
|
| 6 |
+Vagrant.configure('2') do |config|
|
|
| 7 |
+ |
|
| 8 |
+ # vCloud Air provider settings |
|
| 9 |
+ config.vm.provider :vcloudair do |vcloudair| |
|
| 10 |
+ |
|
| 11 |
+ vcloudair.username = '<username@domain>' |
|
| 12 |
+ vcloudair.password = '<password>' |
|
| 13 |
+ |
|
| 14 |
+ # if you're using a vCloud Air Dedicated Cloud, put the cloud id here, if |
|
| 15 |
+ # you're using a Virtual Private Cloud, skip this parameter. |
|
| 16 |
+ vcloudair.cloud_id = '<dedicated cloud id>' |
|
| 17 |
+ vcloudair.vdc_name = '<vdc name>' |
|
| 18 |
+ |
|
| 19 |
+ # Set the network to deploy our VM on |
|
| 20 |
+ vcloudair.vdc_network_name = '<vdc network name>' |
|
| 21 |
+ |
|
| 22 |
+ # Set our Edge Gateway and the public IP we're going to use. |
|
| 23 |
+ vcloudair.vdc_edge_gateway = '<vdc edge gateway>' |
|
| 24 |
+ vcloudair.vdc_edge_gateway_ip = '<vdc edge gateway public ip>' |
|
| 25 |
+ |
|
| 26 |
+ # Catalog that holds our templates. |
|
| 27 |
+ vcloudair.catalog_name = 'Vagrant' |
|
| 28 |
+ |
|
| 29 |
+ # Set our Memory and CPU to a sensible value for Docker. |
|
| 30 |
+ vcloudair.memory = 2048 |
|
| 31 |
+ vcloudair.cpus = 2 |
|
| 32 |
+ end |
|
| 33 |
+ |
|
| 34 |
+ #Configure the box to use |
|
| 35 |
+ config.vm.box = 'box-name' |
|
| 36 |
+ |
|
| 37 |
+end |
| ... | ... |
@@ -2,8 +2,8 @@ |
| 2 | 2 |
|
| 3 | 3 |
################################################# |
| 4 | 4 |
# Title: photon-build-machine-init # |
| 5 |
-# Date: 2015-03-17 # |
|
| 6 |
-# Version: 1.0 # |
|
| 5 |
+# Date: 2015-04-16 # |
|
| 6 |
+# Version: 1.1 # |
|
| 7 | 7 |
# Author: tmcphail@vmware.com # |
| 8 | 8 |
# Options: # |
| 9 | 9 |
################################################# |
| ... | ... |
@@ -22,7 +22,9 @@ sudo make toolchain |
| 22 | 22 |
sudo make iso |
| 23 | 23 |
|
| 24 | 24 |
# Remove the old stage directory on the host and copy the newly built one |
| 25 |
-if [[ -d ${PHOTON_HOST}/stage ]] ; then
|
|
| 25 |
+if [ ! -e ${PHOTON_WORKING}/stage/discus.iso ]; then
|
|
| 26 |
+ echo "The build failed..." |
|
| 27 |
+elif [ -d ${PHOTON}/stage ]; then
|
|
| 26 | 28 |
echo "Refreshing the host stage directory content..." |
| 27 | 29 |
rm -rf ${PHOTON_HOST}/stage
|
| 28 | 30 |
cp -R ${PHOTON_WORKING}/stage ${PHOTON_HOST}/stage
|