Commit 8816acf5 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

Create debian12 images automatically

parent 280a4dfc
......@@ -14,12 +14,12 @@ How to build one VM?
mkdir /opt/packer/
cd /opt/packer/
wget https://releases.hashicorp.com/packer/1.7.6/packer_1.7.6_linux_amd64.zip
unzip packer_1.7.6_linux_amd64.zip
wget https://releases.hashicorp.com/packer/1.10.1/packer_1.10.1_linux_amd64.zip
unzip packer_1.10.1_linux_amd64.zip
PATH=/opt/packer:$PATH packer plugins install github.com/hashicorp/qemu
2) Building one VM (example)::
PATH=$PATH:/opt/packer packer build debian8.json
3) You can watch qemu working on a linux machine (with X running), you just
......
......@@ -12,8 +12,9 @@ How to build VM with differents images size?
mkdir /opt/packer/
cd /opt/packer/
wget https://releases.hashicorp.com/packer/1.7.6/packer_1.7.6_linux_amd64.zip
unzip packer_1.7.6_linux_amd64.zip
wget https://releases.hashicorp.com/packer/1.10.1/packer_1.10.1_linux_amd64.zip
unzip packer_1.10.1_linux_amd64.zip
PATH=/opt/packer:$PATH packer plugins install github.com/hashicorp/qemu
2) Check and install qemu
......
......@@ -39,6 +39,12 @@
- { 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 }}' debian12.json >> log/debian11-{{ item.name }}.log
args:
creates: output-debian12-{{ item.size }}G-{{ item.name }}
with_items:
- { name: "vm-bootstrap", size: "50", 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-18.04-server-amd64.json >> log/ubuntu-18.04-server-amd64-{{ item.name }}.log
args:
......@@ -176,6 +182,7 @@
- { name: "vm-bootstrap", size: "200", distro: "debian11"}
- { name: "vm-bootstrap", size: "50", distro: "debian11"}
- { name: "vm-bootstrap", size: "25", distro: "debian11"}
- { name: "vm-bootstrap", size: "50", distro: "debian12"}
- { name: "vm-bootstrap", size: "200", distro: "centos7"}
- { name: "vm-bootstrap", size: "50", distro: "centos7"}
- { name: "vm-bootstrap", size: "25", distro: "centos7"}
......
{
"builders": [
{
"accelerator": "kvm",
"boot_command": [
"<esc><wait><wait><wait><wait>",
"auto preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed-debian12.cfg ",
"debian-installer=en_US.UTF-8 locale=en_US keymap=fr ",
"netcfg/get_hostname={{ .Name }} ",
"netcfg/get_domain={{ user `domain`}} ",
"fb=false debconf/frontend=noninteractive ",
"passwd/user-fullname={{user `user`}} ",
"passwd/user-password={{user `password`}} ",
"passwd/user-password-again={{user `password`}} ",
"passwd/username={{user `user`}} ",
"<enter>"
],
"boot_wait": "5s",
"disk_size": "{{ user `disk_size`}}000",
"format": "qcow2",
"headless": true,
"http_directory": "http",
"iso_checksum": "sha256:013f5b44670d81280b5b1bc02455842b250df2f0c6763398feb69af1a805a14f",
"iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.5.0-amd64-netinst.iso",
"name": "debian12-{{ user `disk_size`}}G-{{ user `name`}}",
"shutdown_command": "echo '{{user `password`}}'|sudo -S shutdown -h now",
"ssh_password": "{{user `password`}}",
"ssh_timeout": "3600s",
"ssh_username": "{{user `user`}}",
"type": "qemu"
}
],
"provisioners": [
{
"execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"scripts": [
"scripts/update.sh",
"scripts/packages.sh",
"scripts/network-debian.sh",
"scripts/cleanup.sh",
"{{ user `custom_script` }}"
],
"type": "shell"
}
],
"variables": {
"custom_script": "scripts/empty.sh",
"disk_size": "100",
"domain": "",
"name": "image",
"password": "slapos",
"user": "slapos"
}
}
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