Multiply updates
* Fix output processing
for predictable qemu artifact naming
* install-recommends=false for ubuntu16
* add zerofree for lvm case
* Fix PACKER_ARGS pass
Change-Id: I023b73963aeb7c1d562dbc6b1e414363de913d90
diff --git a/common/zerodisk.sh b/common/zerodisk.sh
index 9b20b18..0a0a05f 100644
--- a/common/zerodisk.sh
+++ b/common/zerodisk.sh
@@ -1,4 +1,12 @@
+#!/bin/bash
+set -x
+
dd if=/dev/zero of=/EMPTY bs=1M || true
rm -f /EMPTY
+
+for m in $(cat /proc/mounts |grep '/dev/mapper/vg0' | awk '{print $2}'); do
+ dd if=/dev/zero of=${m}/EMPTY bs=1M || true
+ rm -fv ${m}/EMPTY
+done
echo 3 > /proc/sys/vm/drop_caches
sync
diff --git a/day01-image/template.json b/day01-image/template.json
index 485a4a9..455ed14 100644
--- a/day01-image/template.json
+++ b/day01-image/template.json
@@ -122,17 +122,17 @@
["-object","rng-random,id=objrng0,filename=/dev/urandom"],
["-device", "virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0x10" ]
],
- "vm_name": "{{ user `image_name` }}-{{ isotime \"200601021504\" }}",
+ "vm_name": "{{ user `image_name` }}-{{ isotime \"200601021504\" }}.qcow2",
"output_directory": "images/{{ user `image_name` }}-qemu-{{ isotime \"200601021504\" }}",
- "format": "qcow2",
"disk_compression": true,
+ "disk_size": "{{ user `disk_size`}}",
+ "format": "qcow2",
"iso_checksum": "566efef1d6f12e7d3a994c2405bdb642",
"iso_checksum_type": "md5",
"iso_url": "http://cloud-images.ubuntu.com/releases/xenial/release-20180306/ubuntu-16.04-server-cloudimg-amd64-disk1.img",
"iso_target_path": "{{ user `images_cache`}}/release-20180306_xenial-server-cloudimg-amd64-disk1.img",
"disk_image": true,
"accelerator": "kvm",
- "disk_size": "{{ user `disk_size`}}",
"headless": true,
"ssh_username": "{{user `user`}}",
"ssh_password": "{{user `password`}}",
diff --git a/mirror-image/template.json b/mirror-image/template.json
index 778edef..4469b8a 100644
--- a/mirror-image/template.json
+++ b/mirror-image/template.json
@@ -144,16 +144,16 @@
["-object","rng-random,id=objrng0,filename=/dev/urandom"],
["-device", "virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0x10" ]
],
- "vm_name": "{{ user `image_name` }}-{{ isotime \"200601021504\" }}",
+ "vm_name": "{{ user `image_name` }}-{{ isotime \"200601021504\" }}.qcow2",
"output_directory": "images/{{ user `image_name` }}-qemu-{{ isotime \"200601021504\" }}",
+ "disk_compression": true,
+ "disk_size": "{{ user `disk_size`}}",
"format": "qcow2",
"accelerator": "kvm",
- "disk_size": "{{ user `disk_size`}}",
"iso_url": "http://cloud-images.ubuntu.com/releases/xenial/release-20180306/ubuntu-16.04-server-cloudimg-amd64-disk1.img",
"iso_target_path": "{{ user `images_cache`}}/release-20180306_xenial-server-cloudimg-amd64-disk1.img",
"iso_checksum_type": "md5",
"disk_image": true,
- "disk_compression": true,
"iso_checksum": "566efef1d6f12e7d3a994c2405bdb642",
"http_directory": "http",
"headless": true,
diff --git a/packer-image-buid.groovy b/packer-image-buid.groovy
index a87918f..87ef652 100644
--- a/packer-image-buid.groovy
+++ b/packer-image-buid.groovy
@@ -135,7 +135,7 @@
}
stage("Build Instance") {
- def _packer_args = "${job_env.get(PACKER_ARGS, '')}"
+ def _packer_args = job_env.get('PACKER_ARGS', '')
def _packer_log = "${workspace}/packer.log"
// clean old log, for correct status grepping
if (fileExists(_packer_log)) {
@@ -237,8 +237,8 @@
// collect artifacts
// TODO make it possible, process multiply artifacts by one run.
dir('images/') {
- sh(script: 'find .', returnStdout: true)
- def _files = findFiles(glob: "*qemu*/${imageName}*")
+ sh(script: 'find .')
+ def _files = findFiles(glob: "*qemu*/*${imageName}*.qcow2")
if (_files.size() > 1) {
common.warningMsg("Multiply artifacts detected!Only first one will be processed!")
} else if (_files.size() == 0) {
diff --git a/trymcp-day01-image/template.json b/trymcp-day01-image/template.json
index 6660adb..aba2b31 100644
--- a/trymcp-day01-image/template.json
+++ b/trymcp-day01-image/template.json
@@ -102,17 +102,17 @@
"4"
]
],
- "vm_name": "{{ user `image_name` }}-{{ isotime \"200601021504\" }}",
+ "vm_name": "{{ user `image_name` }}-{{ isotime \"200601021504\" }}.qcow2",
"output_directory": "images/{{ user `image_name` }}-qemu-{{ isotime \"200601021504\" }}",
- "format": "qcow2",
"disk_compression": true,
+ "disk_size": "{{ user `disk_size`}}",
+ "format": "qcow2",
"iso_checksum": "566efef1d6f12e7d3a994c2405bdb642",
"iso_checksum_type": "md5",
"iso_url": "http://cloud-images.ubuntu.com/releases/xenial/release-20180306/ubuntu-16.04-server-cloudimg-amd64-disk1.img",
"iso_target_path": "{{ user `images_cache`}}/release-20180306_xenial-server-cloudimg-amd64-disk1.img",
"disk_image": true,
"accelerator": "kvm",
- "disk_size": "{{ user `disk_size`}}",
"headless": true,
"ssh_username": "{{user `user`}}",
"ssh_password": "{{user `password`}}",
@@ -123,4 +123,4 @@
"ssh_wait_timeout": "360s"
}
]
-}
\ No newline at end of file
+}
diff --git a/ubuntu-16.04/http/preseed.cfg b/ubuntu-16.04/http/preseed.cfg
index ed89955..a736274 100644
--- a/ubuntu-16.04/http/preseed.cfg
+++ b/ubuntu-16.04/http/preseed.cfg
@@ -1,6 +1,7 @@
choose-mirror-bin mirror/http/proxy string
d-i mirror/country string manual
d-i apt-setup/use_mirror boolean false
+d-i base-installer/install-recommends boolean false
d-i debian-installer/locale string en_US
d-i debian-installer/language string en
diff --git a/ubuntu-16.04/run.example.sh b/ubuntu-16.04/run.example.sh
index 2ed17e0..7341ce7 100755
--- a/ubuntu-16.04/run.example.sh
+++ b/ubuntu-16.04/run.example.sh
@@ -25,6 +25,6 @@
[ -f config-drive/cloudata.iso ] && rm -v config-drive/cloudata.iso
mkisofs -o config-drive/cloudata.iso -V cidata -r -J --quiet config-drive
# For qemu test-build:
-packer build -only=qemu -parallel=false -on-error=ask template.json
+packer build -machine-readable -only=qemu -parallel=false -on-error=ask template.json
#rm -rf ~/.packer.d/
diff --git a/ubuntu-16.04/template.json b/ubuntu-16.04/template.json
index 7b87e75..6ffd6dd 100644
--- a/ubuntu-16.04/template.json
+++ b/ubuntu-16.04/template.json
@@ -29,30 +29,6 @@
"SALTSTACK_REPO={{ user `saltstack_repo` }}"
],
"override": {
- "virtualbox-iso": {
- "scripts": [
- "scripts/base.sh",
- "scripts/motd.sh",
- "scripts/salt.sh",
- "scripts/network.sh",
- "scripts/vagrant.sh",
- "scripts/virtualbox.sh",
- "scripts/security.sh",
- "scripts/cleanup.sh",
- "scripts/zerodisk.sh"
- ]
- },
- "vmware-iso": {
- "scripts": [
- "scripts/base.sh",
- "scripts/motd.sh",
- "scripts/salt.sh",
- "scripts/vmware.sh",
- "scripts/security.sh",
- "scripts/cleanup.sh",
- "scripts/zerodisk.sh"
- ]
- },
"qemu": {
"scripts": [
"scripts/base.sh",
@@ -76,24 +52,6 @@
"scripts/info.sh",
"scripts/zerodisk.sh"
]
- },
- "docker": {
- "scripts": [
- "scripts/docker.sh",
- "scripts/base.sh",
- "scripts/motd.sh",
- "scripts/salt.sh",
- "scripts/cleanup.sh"
- ]
- },
- "digitalocean": {
- "scripts": [
- "scripts/base.sh",
- "scripts/motd.sh",
- "scripts/salt.sh",
- "scripts/security.sh",
- "scripts/cleanup.sh"
- ]
}
}
},
@@ -108,171 +66,8 @@
"destination": "/usr/bin"
}
],
- "post-processors": [
- {
- "type": "vagrant",
- "keep_input_artifact": true,
- "output": "images/{{ user `image_name` }}-{{.Provider}}-{{ isotime \"200601021504\" }}.box",
- "except": [
- "digitalocean",
- "docker"
- ]
- },
- {
- "type": "docker-tag",
- "repository": "tcpcloud/ubuntu",
- "tag": "16.04",
- "only": [
- "docker"
- ]
- },
- {
- "type": "docker-save",
- "path": "images/{{ user `image_name` }}-docker-{{ isotime \"200601021504\" }}.tar",
- "only": [
- "docker"
- ]
- }
- ],
"builders": [
{
- "type": "virtualbox-iso",
- "boot_command": [
- "<esc><wait>",
- "<esc><wait>",
- "<enter><wait>",
- "/install/vmlinuz<wait>",
- " auto<wait>",
- " console-setup/ask_detect=false<wait>",
- " console-setup/layoutcode=us<wait>",
- " console-setup/modelcode=pc105<wait>",
- " debconf/frontend=noninteractive<wait>",
- " debian-installer=en_US<wait>",
- " fb=false<wait>",
- " initrd=/install/initrd.gz<wait>",
- " kbd-chooser/method=us<wait>",
- " keyboard-configuration/layout=USA<wait>",
- " keyboard-configuration/variant=USA<wait>",
- " passwd/root-password={{ user `password` }} ",
- " passwd/root-password-again={{ user `password` }} ",
- " locale=en_US<wait>",
- " netcfg/get_hostname=ubuntu<wait>",
- " netcfg/get_domain=local<wait>",
- " noapic<wait>",
- " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<wait>",
- " -- <wait>",
- "<enter><wait>"
- ],
- "boot_wait": "5s",
- "disk_size": "{{ user `disk_size`}}",
- "output_directory": "images/{{ user `image_name`}}",
- "guest_os_type": "Ubuntu_64",
- "http_directory": "http",
- "iso_checksum": "10fcd20619dce11fe094e960c85ba4a9",
- "iso_checksum_type": "md5",
- "iso_url": "http://releases.ubuntu.com/16.04/ubuntu-16.04.3-server-amd64.iso",
- "ssh_username": "{{ user `user` }}",
- "ssh_password": "{{ user `password` }}",
- "ssh_port": 22,
- "ssh_wait_timeout": "10000s",
- "shutdown_command": "shutdown -P now",
- "headless": true,
- "vboxmanage": [
- [
- "modifyvm",
- "{{.Name}}",
- "--memory",
- "1024"
- ],
- [
- "modifyvm",
- "{{.Name}}",
- "--cpus",
- "2"
- ],
- [
- "modifyvm",
- "{{.Name}}",
- "--vrde",
- "on"
- ],
- [
- "modifyvm",
- "{{.Name}}",
- "--vrdeport",
- "5000-5050"
- ],
- [
- "modifyvm",
- "{{.Name}}",
- "--vrdeaddress",
- "127.0.0.1"
- ]
- ]
- },
- {
- "type": "vmware-iso",
- "boot_command": [
- "<esc><wait>",
- "<esc><wait>",
- "<enter><wait>",
- "/install/vmlinuz<wait>",
- " auto<wait>",
- " console-setup/ask_detect=false<wait>",
- " console-setup/layoutcode=us<wait>",
- " console-setup/modelcode=pc105<wait>",
- " debconf/frontend=noninteractive<wait>",
- " debian-installer=en_US<wait>",
- " fb=false<wait>",
- " initrd=/install/initrd.gz<wait>",
- " kbd-chooser/method=us<wait>",
- " keyboard-configuration/layout=USA<wait>",
- " keyboard-configuration/variant=USA<wait>",
- " passwd/root-password={{user `password`}} ",
- " passwd/root-password-again={{user `password`}} ",
- " locale=en_US<wait>",
- " netcfg/get_hostname=ubuntu<wait>",
- " netcfg/get_domain=local<wait>",
- " noapic<wait>",
- " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<wait>",
- " -- <wait>",
- "<enter><wait>"
- ],
- "boot_wait": "5s",
- "disk_size": "{{ user `disk_size`}}",
- "disk_type_id": 4,
- "vmdk_name": "{{ user `image_name`}}",
- "output_directory": "images/{{ user `image_name`}}",
- "guest_os_type": "linux",
- "http_directory": "http",
- "iso_checksum": "10fcd20619dce11fe094e960c85ba4a9",
- "iso_checksum_type": "md5",
- "iso_url": "http://releases.ubuntu.com/16.04/ubuntu-16.04.3-server-amd64.iso",
- "ssh_username": "{{user `user`}}",
- "ssh_password": "{{user `password`}}",
- "ssh_port": 22,
- "ssh_wait_timeout": "10000s",
- "shutdown_command": "shutdown -P now",
- "vmx_data": {
- "memsize": "1024",
- "numvcpus": "1",
- "cpuid.coresPerSocket": "1"
- }
- },
- {
- "type": "docker",
- "image": "ubuntu:16.04",
- "commit": true
- },
- {
- "type": "digitalocean",
- "api_token": "{{user `do_api_token`}}",
- "image": "{{user `image_name`}}",
- "snapshot_name": "{{ user `image_name` }}-{{ isotime \"200601021504\" }}",
- "region": "ams2",
- "size": "1gb"
- },
- {
"type": "qemu",
"qemuargs": [
["-m", "1024M"],
@@ -280,11 +75,12 @@
["-object","rng-random,id=objrng0,filename=/dev/urandom"],
["-device", "virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0x10"]
],
- "vm_name": "{{ user `image_name` }}",
- "output_directory": "images/{{ user `image_name`}}",
+ "vm_name": "{{ user `image_name` }}-{{ isotime \"200601021504\" }}.qcow2",
+ "output_directory": "images/{{ user `image_name` }}-qemu-{{ isotime \"200601021504\" }}",
+ "disk_compression": true,
+ "disk_size": "{{ user `disk_size`}}",
"boot_key_interval": "50ms",
"accelerator": "kvm",
- "disk_size": "{{ user `disk_size`}}",
"iso_checksum": "24636fd103a2a43c95659f1c3c63718e",
"iso_checksum_type": "md5",
"iso_url": "http://releases.ubuntu.com/16.04.5/ubuntu-16.04.5-server-amd64.iso",
diff --git a/ubuntu-16.04/template.json.qcow2 b/ubuntu-16.04/template.json.qcow2
index ef20aaa..06e0fb3 100644
--- a/ubuntu-16.04/template.json.qcow2
+++ b/ubuntu-16.04/template.json.qcow2
@@ -107,7 +107,7 @@
{
"type": "vagrant",
"keep_input_artifact": true,
- "output": "images/{{ user `image_name` }}-{{.Provider}}-{{ isotime \"200601021504\" }}.box",
+ "output": "images/{{ user `image_name` }}-qemu-{{ isotime \"200601021504\" }}.qcow2",
"except": [
"digitalocean",
"docker"