push
This commit is contained in:
commit
e550f2f5a1
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
output-virtualbox-iso
|
||||
builds/*.box
|
||||
.vagrant
|
||||
7
LICENSE
Normal file
7
LICENSE
Normal file
@ -0,0 +1,7 @@
|
||||
Copyright 2026 Jeff Geerling, GregLebreton
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
47
README.md
Executable file
47
README.md
Executable file
@ -0,0 +1,47 @@
|
||||
# Build Vagrant box Debian 13 with virtualbox
|
||||
|
||||
Debian 13 Vagrant box builder (Packer) from the project [Packer boxes](https://github.com/geerlingguy/packer-boxes) [Jeff Geerling](https://www.jeffgeerling.com), author of [Ansible for DevOps](https://www.ansiblefordevops.com)
|
||||
|
||||
## Requirements
|
||||
|
||||
The following software must be installed/present on your local machine before you can use Packer to build any of these Vagrant boxes:
|
||||
|
||||
- [Packer](http://www.packer.io/)
|
||||
- [Vagrant](http://vagrantup.com/)
|
||||
- [VirtualBox](https://www.virtualbox.org/)
|
||||
- [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html)
|
||||
|
||||
## Usage
|
||||
|
||||
Make sure all the required software (listed above) is installed, then cd into one of the box directories and run:
|
||||
|
||||
$ packer build -var 'version=1.2.0' box-config.json
|
||||
|
||||
After a few minutes, Packer should tell you the box was generated successfully, and the box was uploaded to Vagrant Cloud.
|
||||
|
||||
> **Note**: This configuration includes a post-processor that pushes the built box to Vagrant Cloud (which requires a `VAGRANT_CLOUD_TOKEN` environment variable to be set); remove the `vagrant-cloud` post-processor from the Packer template to build the box locally and not push it to Vagrant Cloud. You don't need to specify a `version` variable either, if not using the `vagrant-cloud` post-processor.
|
||||
|
||||
|
||||
## Testing built boxes
|
||||
|
||||
There's an included Vagrantfile that allows quick testing of the built Vagrant boxes. From the same box directory, run the following command after building the box:
|
||||
|
||||
$ vagrant up
|
||||
|
||||
Test that the box works correctly, then tear it down with:
|
||||
|
||||
$ vagrant destroy -f
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
## Config
|
||||
|
||||
- Modifier
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
packer build -var 'version=1.0.0' box-config.json
|
||||
```
|
||||
25
Vagrantfile
vendored
Normal file
25
Vagrantfile
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.ssh.insert_key = false
|
||||
# config.vm.synced_folder '.', '/vagrant', type: 'nfs'
|
||||
|
||||
# VirtualBox.
|
||||
config.vm.define "virtualbox" do |virtualbox|
|
||||
virtualbox.vm.hostname = "virtualbox-debian13"
|
||||
virtualbox.vm.box = "file://builds/virtualbox-debian13.box"
|
||||
virtualbox.vm.network :private_network, ip: "192.168.60.2"
|
||||
|
||||
config.vm.provider :virtualbox do |v|
|
||||
v.gui = false
|
||||
v.memory = 1024
|
||||
v.cpus = 1
|
||||
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
|
||||
v.customize ["modifyvm", :id, "--ioapic", "on"]
|
||||
end
|
||||
|
||||
config.vm.provision "shell", inline: "echo Hello, World"
|
||||
end
|
||||
|
||||
end
|
||||
90
box-config.json
Executable file
90
box-config.json
Executable file
@ -0,0 +1,90 @@
|
||||
{
|
||||
"variables": {
|
||||
"version": ""
|
||||
},
|
||||
"provisioners": [
|
||||
{
|
||||
"type": "shell",
|
||||
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
|
||||
"script": "scripts/ansible.sh"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
|
||||
"script": "scripts/setup.sh"
|
||||
},
|
||||
{
|
||||
"type": "ansible-local",
|
||||
"playbook_file": "../shared/main.yml",
|
||||
"galaxy_file": "../shared/requirements.yml"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
|
||||
"script": "scripts/cleanup.sh"
|
||||
}
|
||||
],
|
||||
"builders": [
|
||||
{
|
||||
"type": "virtualbox-iso",
|
||||
"boot_command": [
|
||||
"<esc><wait>",
|
||||
"install <wait>",
|
||||
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg <wait>",
|
||||
"debian-installer=en_US.UTF-8 <wait>",
|
||||
"auto <wait>",
|
||||
"locale=en_US.UTF-8 <wait>",
|
||||
"kbd-chooser/method=us <wait>",
|
||||
"keyboard-configuration/xkb-keymap=us <wait>",
|
||||
"netcfg/get_hostname={{ .Name }} <wait>",
|
||||
"netcfg/get_domain=vagrantup.com <wait>",
|
||||
"fb=false <wait>",
|
||||
"debconf/frontend=noninteractive <wait>",
|
||||
"console-setup/ask_detect=false <wait>",
|
||||
"console-keymaps-at/keymap=us <wait>",
|
||||
"grub-installer/bootdev=/dev/sda <wait>",
|
||||
"<enter><wait>"
|
||||
],
|
||||
"boot_wait": "5s",
|
||||
"disk_size": 81920,
|
||||
"guest_os_type": "Debian_64",
|
||||
"headless": true,
|
||||
"http_directory": "http",
|
||||
"iso_urls": [
|
||||
"debian-13.3.0-amd64-netinst.iso",
|
||||
"https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-13.3.0-amd64-netinst.iso"
|
||||
],
|
||||
"iso_checksum": "sha512:1ada40e4c938528dd8e6b9c88c19b978a0f8e2a6757b9cf634987012d37ec98503ebf3e05acbae9be4c0ec00b52e8852106de1bda93a2399d125facea45400f8",
|
||||
"ssh_username": "vagrant",
|
||||
"ssh_password": "vagrant",
|
||||
"ssh_port": 22,
|
||||
"ssh_wait_timeout": "1800s",
|
||||
"shutdown_command": "echo 'vagrant'|sudo -S shutdown -P now",
|
||||
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
|
||||
"virtualbox_version_file": ".vbox_version",
|
||||
"vm_name": "packer-debian-13-amd64",
|
||||
"vboxmanage": [
|
||||
[
|
||||
"modifyvm",
|
||||
"{{.Name}}",
|
||||
"--memory",
|
||||
"1024"
|
||||
],
|
||||
[
|
||||
"modifyvm",
|
||||
"{{.Name}}",
|
||||
"--cpus",
|
||||
"1"
|
||||
]
|
||||
]
|
||||
}
|
||||
],
|
||||
"post-processors": [
|
||||
[
|
||||
{
|
||||
"output": "builds/{{.Provider}}-debian13.box",
|
||||
"type": "vagrant"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
48
http/preseed.cfg
Normal file
48
http/preseed.cfg
Normal file
@ -0,0 +1,48 @@
|
||||
choose-mirror-bin mirror/http/proxy string
|
||||
d-i apt-setup/use_mirror boolean true
|
||||
d-i base-installer/kernel/override-image string linux-server
|
||||
d-i clock-setup/utc boolean true
|
||||
d-i clock-setup/utc-auto boolean true
|
||||
d-i finish-install/reboot_in_progress note
|
||||
d-i grub-installer/only_debian boolean true
|
||||
d-i grub-installer/with_other_os boolean true
|
||||
d-i keymap select us
|
||||
d-i mirror/country string manual
|
||||
d-i mirror/http/directory string /debian
|
||||
d-i mirror/http/hostname string httpredir.debian.org
|
||||
d-i mirror/http/proxy string
|
||||
d-i partman-auto-lvm/guided_size string max
|
||||
d-i partman-auto/choose_recipe select atomic
|
||||
d-i partman-auto/method string lvm
|
||||
d-i partman-lvm/confirm boolean true
|
||||
d-i partman-lvm/confirm boolean true
|
||||
d-i partman-lvm/confirm_nooverwrite boolean true
|
||||
d-i partman-lvm/device_remove_lvm boolean true
|
||||
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 passwd/root-login boolean false
|
||||
d-i passwd/root-password-again password vagrant
|
||||
d-i passwd/root-password password vagrant
|
||||
d-i passwd/user-fullname string vagrant
|
||||
d-i passwd/user-uid string 1000
|
||||
d-i passwd/user-password password vagrant
|
||||
d-i passwd/user-password-again password vagrant
|
||||
d-i passwd/username string vagrant
|
||||
d-i pkgsel/include string sudo bzip2 acpid cryptsetup zlib1g-dev wget curl dkms make nfs-common net-tools openssh-server
|
||||
d-i pkgsel/install-language-support boolean false
|
||||
d-i pkgsel/update-policy select none
|
||||
d-i pkgsel/upgrade select none
|
||||
# Prevent packaged version of VirtualBox Guest Additions being installed:
|
||||
# d-i preseed/early_command string sed -i \
|
||||
# '/in-target/idiscover(){/sbin/discover|grep -v VirtualBox;}' \
|
||||
# /usr/lib/pre-pkgsel.d/20install-hwpackages
|
||||
d-i time/zone string UTC
|
||||
d-i user-setup/allow-password-weak boolean true
|
||||
d-i user-setup/encrypt-home boolean false
|
||||
d-i preseed/late_command string sed -i '/^deb cdrom:/s/^/#/' /target/etc/apt/sources.list
|
||||
apt-cdrom-setup apt-setup/cdrom/set-first boolean false
|
||||
apt-mirror-setup apt-setup/use_mirror boolean true
|
||||
popularity-contest popularity-contest/participate boolean false
|
||||
tasksel tasksel/first multiselect standard, ssh-server
|
||||
9
scripts/ansible.sh
Normal file
9
scripts/ansible.sh
Normal file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash -eux
|
||||
|
||||
# Install Ansible dependencies.
|
||||
apt -y update && apt-get -y upgrade && apt -y install -y ansible
|
||||
# apt -y update && apt-get -y upgrade
|
||||
# apt -y install python3-pip python3-dev
|
||||
|
||||
# # Install Ansible.
|
||||
# pip3 install ansible
|
||||
24
scripts/cleanup.sh
Normal file
24
scripts/cleanup.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash -eux
|
||||
|
||||
# Uninstall Ansible and dependencies.
|
||||
apt-get remove --purge ansible
|
||||
rm -rf /home/vagrant/.ansible
|
||||
|
||||
# Apt cleanup.
|
||||
apt update -y
|
||||
apt autoremove -y
|
||||
|
||||
# Blank netplan machine-id (DUID) so machines get unique ID generated on boot.
|
||||
truncate -s 0 /etc/machine-id
|
||||
rm /var/lib/dbus/machine-id
|
||||
ln -s /etc/machine-id /var/lib/dbus/machine-id
|
||||
|
||||
# Delete unneeded files.
|
||||
rm -f /home/vagrant/*.sh
|
||||
|
||||
# Zero out the rest of the free space using dd, then delete the written file.
|
||||
dd if=/dev/zero of=/EMPTY bs=1M
|
||||
rm -f /EMPTY
|
||||
|
||||
# Add `sync` so Packer doesn't quit too early, before the large file is deleted.
|
||||
sync
|
||||
8
scripts/setup.sh
Normal file
8
scripts/setup.sh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash -eux
|
||||
|
||||
# Add vagrant user to sudoers.
|
||||
echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
|
||||
|
||||
# Disable daily apt unattended updates. Is this needed for Debian?
|
||||
# echo 'APT::Periodic::Enable "0";' >> /etc/apt/apt.conf.d/10periodic
|
||||
Loading…
x
Reference in New Issue
Block a user