Commit a4d03a18 authored by Rafael Monnerat's avatar Rafael Monnerat

packer: Add packer config to generate a ready to use disk image

parent 269b8f0d
{
"variables": {
"user": "slapos",
"password": "slapos",
"domain": "",
"disk_size": "6",
"name": "image",
"custom_script": "scripts/empty.sh",
"re6st_token": "{{env `RE6STTOKEN`}}",
"computer_token": "{{env `COMPUTERTOKEN`}}"
"computer_name": "{{env `COMPUTERNAME`}}"
},
"builders":
[
{
"name": "debian9-rs-base-{{ user `disk_size`}}G-{{ user `name`}}",
"type": "qemu",
"format": "raw",
"accelerator": "kvm",
"disk_size": "{{ user `disk_size`}}000",
"iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/9.9.0/amd64/iso-cd/debian-9.9.0-amd64-netinst.iso",
"iso_checksum": "e494e78d531352f0f3fdb210f13f7577",
"iso_checksum_type": "md5",
"http_directory": "http",
"ssh_username": "{{user `user`}}",
"ssh_password": "{{user `password`}}",
"ssh_wait_timeout": "1800s",
"shutdown_command": "echo '{{user `password`}}'|sudo -S shutdown -h now",
"headless": true,
"boot_wait": "2s",
"boot_command": [
"<esc><wait><wait>",
"install auto ",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed-debian9.cfg ",
"debian-installer=en_US 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>"
]
}
],
"provisioners": [
{
"type": "shell",
"execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"environment_vars": ["re6st_token={{ user `re6st_token` }}", "computer_name={{user `computer_name`}}", "computer_token={{ user `computer_token` }}"],
"scripts": [
"scripts/update.sh",
"scripts/packages.sh",
"scripts/network-debian9.sh",
"scripts/cleanup.sh",
"scripts/setup-base-slapos.sh",
"{{ user `custom_script` }}"
]
}
]
}
#!/bin/bash
set -e
aptitude -y install --without-recommends python-setuptools
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
pip2 install --exists-action=i six
pip2 install --exists-action=i requests
pip2 install --exists-action=i slapcache
wget http://deploy.erp5.net/vifib-base -O /root/run-vifib-base
RE6STTOKEN=$re6st_token
COMPUTERTOKEN=$computer_token
COMPUTERNAME=$computer_name
bash /root/run-vifib-base
re6st-conf --registry http://re6stnet.gnet.erp5.cn/ --token $RE6STTOKEN -r title $RE6STTOKEN -d /etc/re6stnet
slapos node register --token $COMPUTERTOKEN --interface-name lo $COMPUTERNAME
# Re-run after the register to finish up the configuration
bash /root/run-vifib-base
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