-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
302 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
#Generated by packer-kvm/build-packer-templates.yaml | ||
|
||
packer { | ||
required_plugins { | ||
qemu = { | ||
version = "~> 1" | ||
source = "github.com/hashicorp/qemu" | ||
} | ||
ansible = { | ||
version = ">= 1.1.2" | ||
source = "github.com/hashicorp/ansible" | ||
} | ||
} | ||
} | ||
|
||
variable "cpu" { | ||
type = string | ||
default = "2" | ||
} | ||
|
||
variable "destination_server" { | ||
type = string | ||
default = "download.goffinet.org" | ||
} | ||
|
||
variable "disk_size" { | ||
type = string | ||
default = "40000" | ||
} | ||
|
||
variable "headless" { | ||
type = string | ||
default = "true" | ||
} | ||
|
||
variable "iso_checksum" { | ||
type = string | ||
default = "file:https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/SHA256SUMS" | ||
} | ||
|
||
variable "iso_url" { | ||
type = string | ||
default = "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.3.0-amd64-netinst.iso" | ||
} | ||
|
||
variable "name" { | ||
type = string | ||
default = "debian" | ||
} | ||
|
||
variable "ram" { | ||
type = string | ||
default = "2048" | ||
} | ||
|
||
variable "ssh_password" { | ||
type = string | ||
default = "testtest" | ||
} | ||
|
||
variable "ssh_username" { | ||
type = string | ||
default = "root" | ||
} | ||
|
||
variable "version" { | ||
type = string | ||
default = "12" | ||
} | ||
|
||
source "qemu" "debian12" { | ||
accelerator = "kvm" | ||
boot_command = ["<esc><wait>", "auto <wait>", "console-keymaps-at/keymap=us <wait>", "console-setup/ask_detect=false <wait>", "debconf/frontend=noninteractive <wait>", "debian-installer=en_US <wait>", "fb=false <wait>", "install <wait>", "kbd-chooser/method=us <wait>", "keyboard-configuration/xkb-keymap=us <wait>", "locale=en_US <wait>", "netcfg/get_hostname=${var.name}${var.version} <wait>", "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/http/${var.config_file} <wait>", "<enter><wait>"] | ||
disk_cache = "none" | ||
disk_compression = true | ||
disk_discard = "unmap" | ||
disk_interface = "virtio" | ||
disk_size = var.disk_size | ||
format = "qcow2" | ||
headless = var.headless | ||
http_directory = "." | ||
iso_checksum = var.iso_checksum | ||
iso_url = var.iso_url | ||
net_device = "virtio-net" | ||
output_directory = "artifacts/qemu/${var.name}${var.version}" | ||
qemu_binary = "/usr/bin/qemu-system-x86_64" | ||
qemuargs = [["-m", "${var.ram}M"], ["-smp", "${var.cpu}"], ["-cpu", "host"]] | ||
shutdown_command = "sudo /usr/sbin/shutdown -h now" | ||
ssh_password = var.ssh_password | ||
ssh_username = var.ssh_username | ||
boot_wait = "3s" | ||
ssh_handshake_attempts = 500 | ||
ssh_timeout = "45m" | ||
ssh_wait_timeout = "45m" | ||
host_port_max = 2229 | ||
host_port_min = 2222 | ||
http_port_max = 10089 | ||
http_port_min = 10082 | ||
} | ||
|
||
build { | ||
sources = ["source.qemu.debian12"] | ||
|
||
provisioner "shell" { | ||
execute_command = "{{ .Vars }} sudo -E bash '{{ .Path }}'" | ||
inline = ["apt-get update", "apt -y install python3 python3-pip", "pip3 install ansible"] | ||
} | ||
|
||
provisioner "ansible-local" { | ||
playbook_dir = "ansible" | ||
playbook_file = "ansible/playbook.yml" | ||
} | ||
|
||
post-processor "shell-local" { | ||
environment_vars = ["IMAGE_NAME=${var.name}", "IMAGE_VERSION=${var.version}", "DESTINATION_SERVER=${var.destination_server}"] | ||
script = "scripts/push-image.sh" | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#cloud-config | ||
autoinstall: | ||
version: 1 | ||
identity: | ||
hostname: debian12 | ||
username: ubuntu | ||
password: $6$rounds=4096$mB3ZauOM8/HIycgS$iaaXsE86il1SLeotstYVkkQXG9md.tG0QMyWvszGlc4zye9SxK3W3lnyYT5K9vkgZWZa7QFwIOIqPE8umY7zg1 | ||
user-data: | ||
disable_root: false | ||
keyboard: | ||
layout: us | ||
locale: en_US | ||
network: | ||
ethernets: | ||
eth0: | ||
dhcp4: true | ||
dhcp-identifier: mac | ||
version: 2 | ||
ssh: | ||
allow-pw: true | ||
install-server: true | ||
storage: | ||
layout: | ||
name: lvm | ||
late-commands: | ||
- sed -i -e 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /target/etc/ssh/sshd_config | ||
- sed -i -e 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /target/etc/ssh/sshd_config | ||
- echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/ubuntu | ||
- sed -ie 's/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX="net.ifnames=0 ipv6.disable=1 biosdevname=0"/' /target/etc/default/grub | ||
- curtin in-target --target /target update-grub2 | ||
packages: | ||
- bc | ||
- curl | ||
- wget | ||
- openssh-server | ||
# - qemu-guest-agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
d-i pkgsel/install-language-support boolean false | ||
|
||
# locale | ||
d-i debian-installer/locale string en_US.UTF-8 | ||
|
||
# keyboard | ||
d-i keyboard-configuration/xkb-keymap select us | ||
|
||
# timezone | ||
d-i time/zone string Europe/Paris | ||
|
||
# Controls whether to use NTP to set the clock during the install | ||
d-i clock-setup/ntp boolean true | ||
|
||
# apt | ||
d-i mirror/country string manual | ||
d-i mirror/http/hostname string ftp.debian.org | ||
d-i mirror/http/directory string /debian | ||
d-i mirror/http/proxy string | ||
d-i apt-setup/use_mirror boolean true | ||
|
||
# users | ||
d-i passwd/root-password password testtest | ||
d-i passwd/root-password-again password testtest | ||
d-i passwd/make-user boolean false | ||
|
||
# partitioning | ||
d-i partman-auto/method string regular | ||
d-i partman-auto/choose_recipe select atomic | ||
d-i partman-partitioning/confirm_write_new_label boolean true | ||
d-i partman/choose_partition select finish | ||
d-i partman/confirm boolean true | ||
d-i partman/confirm_nooverwrite boolean true | ||
|
||
apt-cdrom-setup apt-setup/cdrom/set-first boolean false | ||
|
||
# software | ||
tasksel tasksel/first multiselect standard | ||
d-i pkgsel/include string qemu-guest-agent wget openssh-server vim sudo cloud-init | ||
popularity-contest popularity-contest/participate boolean false | ||
|
||
# grub | ||
d-i grub-installer/only_debian boolean true | ||
d-i grub-installer/bootdev string /dev/vda | ||
|
||
# script | ||
d-i preseed/late_command string in-target sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config | ||
|
||
# finish | ||
d-i finish-install/reboot_in_progress note |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
d-i pkgsel/install-language-support boolean false | ||
|
||
# locale | ||
d-i debian-installer/locale string en_US.UTF-8 | ||
|
||
# keyboard | ||
d-i keyboard-configuration/xkb-keymap select us | ||
|
||
# timezone | ||
d-i time/zone string Europe/Paris | ||
|
||
# Controls whether to use NTP to set the clock during the install | ||
d-i clock-setup/ntp boolean true | ||
|
||
# apt | ||
d-i mirror/country string manual | ||
d-i mirror/http/hostname string ftp.debian.org | ||
d-i mirror/http/directory string /debian | ||
d-i mirror/http/proxy string | ||
d-i apt-setup/use_mirror boolean true | ||
|
||
# users | ||
d-i passwd/root-password password testtest | ||
d-i passwd/root-password-again password testtest | ||
d-i passwd/make-user boolean false | ||
|
||
# partitioning | ||
d-i partman-auto/method string regular | ||
d-i partman-auto/choose_recipe select atomic | ||
d-i partman-partitioning/confirm_write_new_label boolean true | ||
d-i partman/choose_partition select finish | ||
d-i partman/confirm boolean true | ||
d-i partman/confirm_nooverwrite boolean true | ||
|
||
apt-cdrom-setup apt-setup/cdrom/set-first boolean false | ||
|
||
# software | ||
tasksel tasksel/first multiselect standard | ||
d-i pkgsel/include string qemu-guest-agent wget openssh-server vim sudo cloud-init | ||
popularity-contest popularity-contest/participate boolean false | ||
|
||
# grub | ||
d-i grub-installer/only_debian boolean true | ||
d-i grub-installer/bootdev string /dev/vda | ||
|
||
# script | ||
d-i preseed/late_command string in-target sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config | ||
|
||
# finish | ||
d-i finish-install/reboot_in_progress note |