aboutsummaryrefslogtreecommitdiff
path: root/packer
diff options
context:
space:
mode:
Diffstat (limited to 'packer')
-rw-r--r--packer/debian-server-bookworm/debian-server-bookworm.pkr.hcl25
-rw-r--r--packer/debian-server-bookworm/files/cloud.cfg99
-rw-r--r--packer/debian-server-bookworm/http/preseed.cfg4
3 files changed, 109 insertions, 19 deletions
diff --git a/packer/debian-server-bookworm/debian-server-bookworm.pkr.hcl b/packer/debian-server-bookworm/debian-server-bookworm.pkr.hcl
index 902105b..bffea00 100644
--- a/packer/debian-server-bookworm/debian-server-bookworm.pkr.hcl
+++ b/packer/debian-server-bookworm/debian-server-bookworm.pkr.hcl
@@ -118,33 +118,24 @@ build {
name = "debian-server-bookworm-test-1"
sources = ["source.proxmox-iso.debian-server-bookworm-test-1"]
- # Provisioning the VM Template for Cloud-Init Integration in Proxmox #1
+ # Copy default cloud-init config
+ provisioner "file" {
+ source = "files/cloud.cfg"
+ destination = "/tmp/cloud.cfg"
+ }
+
provisioner "shell" {
- inline = [
- "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done",
- "sudo rm /etc/ssh/ssh_host_*",
- "sudo truncate -s 0 /etc/machine-id",
- "sudo apt -y autoremove --purge",
- "sudo apt -y clean",
- "sudo apt -y autoclean",
- "sudo cloud-init clean",
- "sudo sync"
- ]
+ inline = ["sudo cp /tmp/cloud.cfg /etc/cloud/cloud.cfg"]
}
- # Provisioning the VM Template for Cloud-Init Integration in Proxmox #2
+ # Copy Proxmox cloud-init config
provisioner "file" {
source = "files/99-pve.cfg"
destination = "/tmp/99-pve.cfg"
}
- # Provisioning the VM Template for Cloud-Init Integration in Proxmox #3
provisioner "shell" {
inline = ["sudo cp /tmp/99-pve.cfg /etc/cloud/cloud.cfg.d/99-pve.cfg"]
}
- # Random personal test, ID #4
- provisioner "shell" {
- inline = ["id"]
- }
}
diff --git a/packer/debian-server-bookworm/files/cloud.cfg b/packer/debian-server-bookworm/files/cloud.cfg
new file mode 100644
index 0000000..29d451e
--- /dev/null
+++ b/packer/debian-server-bookworm/files/cloud.cfg
@@ -0,0 +1,99 @@
+# The top level settings are used as module
+# and system configuration.
+
+# If this is set, 'root' will not be able to ssh in and they
+# will get a message to login instead as the above $user (debian)
+disable_root: true
+
+# Update apt database on first boot (run 'apt-get update')
+apt_update: true
+
+# Upgrade the instance on first boot
+apt_upgrade: true
+
+# Reboot after package install/update if necessary
+apt_reboot_if_required: true
+
+# The modules that run in the 'init' stage
+cloud_init_modules:
+ - migrator
+ - seed_random
+ - bootcmd
+ - write-files
+ - growpart
+ - resizefs
+ - disk_setup
+ - mounts
+ - set_hostname
+ - update_hostname
+ - update_etc_hosts
+ - ca-certs
+ - rsyslog
+ - users-groups
+ - ssh
+
+# The modules that run in the 'config' stage
+cloud_config_modules:
+# Emit the cloud config ready event
+# this can be used by upstart jobs for 'start on cloud-config'.
+ - emit_upstart
+ - ssh-import-id
+ - locale
+ - set-passwords
+ - grub-dpkg
+ - apt-pipelining
+ - apt-configure
+ - ntp
+ - timezone
+ - disable-ec2-metadata
+ - runcmd
+ - byobu
+
+# The modules that run in the 'final' stage
+cloud_final_modules:
+ - package-update-upgrade-install
+ - fan
+ - puppet
+ - chef
+ - salt-minion
+ - mcollective
+ - rightscale_userdata
+ - scripts-vendor
+ - scripts-per-once
+ - scripts-per-boot
+ - scripts-per-instance
+ - scripts-user
+ - ssh-authkey-fingerprints
+ - keys-to-console
+ - phone-home
+ - final-message
+ - power-state-change
+
+final_message: "The system is finally up, after $UPTIME seconds"
+
+# System and/or distro specific settings
+# (not accessible to handlers/transforms)
+system_info:
+ # This will affect which distro class gets used
+ distro: debian
+ # Default user name + that default users groups (if added/used)
+ default_user:
+ name: mas
+ lock_passwd: True
+ gecos: Debian
+ groups: [adm, sudo]
+ sudo: ["ALL=(ALL) NOPASSWD:ALL"]
+ shell: /bin/bash
+ # Don't forget to add your public key here -- if you want. You can still add account after cloning thanks to Cloud-Init
+ #ssh_authorized_keys:
+ # Other config here will be given to the distro class and/or path classes
+ paths:
+ cloud_dir: /var/lib/cloud/
+ templates_dir: /etc/cloud/templates/
+ upstart_dir: /etc/init/
+ package_mirrors:
+ - arches: [default]
+ failsafe:
+ primary: http://deb.debian.org/debian
+ security: http://security.debian.org/
+ ssh_svcname: ssh
diff --git a/packer/debian-server-bookworm/http/preseed.cfg b/packer/debian-server-bookworm/http/preseed.cfg
index cf696e0..887dfd4 100644
--- a/packer/debian-server-bookworm/http/preseed.cfg
+++ b/packer/debian-server-bookworm/http/preseed.cfg
@@ -16,7 +16,7 @@ d-i keymap select us
### Network configuration
d-i netcfg/choose_interface select auto
-d-i netcfg/get_hostname string debian
+#d-i netcfg/get_hostname string debian
d-i netcfg/get_domain string local
### Set time zone and clock settings
@@ -51,7 +51,7 @@ d-i user-setup/encrypt-home boolean false
tasksel tasksel/first multiselect standard, ssh-server
### Install additional packages
-d-i pkgsel/include string openssh-server qemu-guest-agent sudo neovim tmux
+d-i pkgsel/include string openssh-server qemu-guest-agent sudo neovim tmux cloud-init
### SSH setup (Disable password authentication, allow only SSH key)
d-i preseed/late_command string \