Commit 2f9bead0 authored by Alain Takoudjou's avatar Alain Takoudjou

packer: add ubuntu-16.04-server template, fix boot issue on ubuntu-16.xx images

parent 626d9eb4
......@@ -37,6 +37,14 @@
- { name: "vm-bootstrap", size: "50", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "25", script: "scripts/vm-bootstrap.sh"}
- shell: PATH=$PATH:/opt/packer/ packer build -var 'disk_size={{ item.size }}' -var 'name={{ item.name }}' -var 'custom_script={{ item.script }}' ubuntu-16.04-server-amd64.json >> log/ubuntu-16.04-server-amd64-{{ item.name }}.log
args:
creates: output-ubuntu-16.04-server-{{ item.size }}G-{{ item.name }}
with_items:
- { name: "vm-bootstrap", size: "200", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "50", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "25", script: "scripts/vm-bootstrap.sh"}
- shell: PATH=$PATH:/opt/packer/ packer build -var 'disk_size={{ item.size }}' -var 'name={{ item.name }}' -var 'custom_script={{ item.script }}' ubuntu-16.10-server-amd64.json >> log/ubuntu-16-server-amd64-{{ item.name }}.log
args:
creates: output-ubuntu-16-server-{{ item.size }}G-{{ item.name }}
......@@ -91,6 +99,15 @@
- { name: "vm-bootstrap", size: "25"}
ignore_errors: True
- shell: gzip output-ubuntu-16.04-server-{{ item.size }}G-{{ item.name }}/packer-ubuntu-16.04-server-{{ item.size }}G-{{ item.name }}
args:
creates: output-ubuntu-16.04-server-{{ item.size }}G-{{ item.name }}/packer-ubuntu-16.04-server-{{ item.size }}G-{{ item.name }}.gz
with_items:
- { name: "vm-bootstrap", size: "200"}
- { name: "vm-bootstrap", size: "50"}
- { name: "vm-bootstrap", size: "25"}
ignore_errors: True
- shell: gzip output-ubuntu-16-server-{{ item.size }}G-{{ item.name }}/packer-ubuntu-16-server-{{ item.size }}G-{{ item.name }}
args:
creates: output-ubuntu-16-server-{{ item.size }}G-{{ item.name }}/packer-ubuntu-16-server-{{ item.size }}G-{{ item.name }}.gz
......@@ -143,6 +160,9 @@
- { name: "vm-bootstrap", size: "200", distro: "ubuntu-14-server"}
- { name: "vm-bootstrap", size: "50", distro: "ubuntu-14-server"}
- { name: "vm-bootstrap", size: "25", distro: "ubuntu-14-server"}
- { name: "vm-bootstrap", size: "200", distro: "ubuntu-16.04-server"}
- { name: "vm-bootstrap", size: "50", distro: "ubuntu-16.04-server"}
- { name: "vm-bootstrap", size: "25", distro: "ubuntu-16.04-server"}
- { name: "vm-bootstrap", size: "200", distro: "ubuntu-16-server"}
- { name: "vm-bootstrap", size: "50", distro: "ubuntu-16-server"}
- { name: "vm-bootstrap", size: "25", distro: "ubuntu-16-server"}
......@@ -176,6 +196,9 @@
- { name: "vm-bootstrap", size: "200", distro: "ubuntu-14-server"}
- { name: "vm-bootstrap", size: "50", distro: "ubuntu-14-server"}
- { name: "vm-bootstrap", size: "25", distro: "ubuntu-14-server"}
- { name: "vm-bootstrap", size: "200", distro: "ubuntu-16.04-server"}
- { name: "vm-bootstrap", size: "50", distro: "ubuntu-16.04-server"}
- { name: "vm-bootstrap", size: "25", distro: "ubuntu-16.04-server"}
- { name: "vm-bootstrap", size: "200", distro: "ubuntu-16-server"}
- { name: "vm-bootstrap", size: "50", distro: "ubuntu-16-server"}
- { name: "vm-bootstrap", size: "25", distro: "ubuntu-16-server"}
......
......@@ -17,7 +17,7 @@ d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman/confirm_write_new_label boolean true
d-i pkgsel/include string openssh-server
d-i pkgsel/include string openssh-server sudo curl vim
d-i pkgsel/install-language-support boolean false
d-i pkgsel/update-policy select unattended-upgrades
d-i pkgsel/upgrade select none
......
d-i preseed/include string ../preseed-ubuntu.cfg
d-i preseed/early_command string \
mkdir -p /usr/lib/post-base-installer.d && \
echo "sed -i -e 's/^in-target.*tasksel.*/#\\0/' /var/lib/dpkg/info/pkgsel.postinst" > /usr/lib/post-base-installer.d/90skip-tasksel && \
chmod +x /usr/lib/post-base-installer.d/90skip-tasksel
d-i preseed/late_command string \
echo 'Defaults:slapos !requiretty' > /target/etc/sudoers.d/slapos; \
echo 'slapos ALL=(ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/slapos; \
chmod 440 /target/etc/sudoers.d/slapos ; \
ln -sf /dev/null /target/etc/systemd/network/99-default.link; \
in-target update-initramfs -u
# Show grub on boot
sed -i 's/GRUB_HIDDEN_TIMEOUT/#GRUB_HIDDEN_TIMEOUT/' /etc/default/grub
# prevent graphic card failure to block boot
sed -i 's#GRUB_CMDLINE_LINUX_DEFAULT=.*#GRUB_CMDLINE_LINUX_DEFAULT=""#' /etc/default/grub
# reduce grub timeout
sed -i 's#GRUB_TIMEOUT=.*#GRUB_TIMEOUT=5#' /etc/default/grub
update-grub
{
"variables": {
"user": "slapos",
"password": "slapos",
"domain": "",
"disk_size": "100",
"name": "image",
"custom_script": "scripts/empty.sh"
},
"builders":
[
{
"name": "ubuntu-16.04-server-{{ user `disk_size`}}G-{{ user `name`}}",
"type": "qemu",
"format": "qcow2",
"accelerator": "kvm",
"disk_size": "{{ user `disk_size`}}000",
"headless": true,
"iso_url": "http://releases.ubuntu.com/16.04/ubuntu-16.04.2-server-amd64.iso",
"iso_checksum": "2bce60d18248df9980612619ff0b34e6",
"iso_checksum_type": "md5",
"http_directory": "http",
"ssh_username": "{{user `user`}}",
"ssh_password": "{{user `password`}}",
"ssh_wait_timeout": "1800s",
"shutdown_command": "sudo systemctl poweroff",
"boot_wait": "3s",
"boot_command": [
"<enter><wait>",
"<f6><esc>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs>",
"/install/vmlinuz ",
"initrd=/install/initrd.gz ",
"hostname={{ .Name }} ",
"net.ifnames=0 ",
"auto-install/enable=true ",
"debconf/priority=critical ",
"passwd/user-fullname={{user `user`}} ",
"passwd/user-password-again={{user `password`}} ",
"passwd/user-password={{user `password`}} ",
"passwd/username={{user `user`}} ",
"noapic ",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed-ubuntu16.04.cfg ",
"<enter>"
]
}
],
"provisioners": [
{
"type": "shell",
"execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"scripts": [
"scripts/update-ubuntu.sh",
"scripts/packages-ubuntu.sh",
"scripts/grub-ubuntu.sh",
"{{ user `custom_script` }}"
]
}
]
}
......@@ -33,19 +33,19 @@
"boot_wait": "2s",
"boot_command": [
"<esc><esc><enter><wait>",
"/install/vmlinuz url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed-ubuntu.cfg ",
"debian-installer=en_US auto locale=en_US kbd-chooser/method=fr ",
"/install/vmlinuz ",
"initrd=/install/initrd.gz ",
"hostname={{ .Name }} ",
"keyboard-configuration/modelcode=pc101 ",
"keyboard-configuration/layoutcode=fr ",
"net.ifnames=0 ",
"auto-install/enable=true ",
"debconf/priority=critical ",
"passwd/user-fullname={{user `user`}} ",
"passwd/user-password-again={{user `password`}} ",
"passwd/user-password={{user `password`}} ",
"passwd/username={{user `user`}} ",
"initrd=/install/initrd.gz -- <enter>"
"noapic ",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed-ubuntu16.04.cfg ",
"-- <enter>"
]
}
],
......@@ -57,7 +57,7 @@
"scripts": [
"scripts/update-ubuntu.sh",
"scripts/packages-ubuntu.sh",
"scripts/network-ubuntu.sh",
"scripts/grub-ubuntu.sh",
"{{ user `custom_script` }}"
]
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment