├── .gitignore ├── scripts ├── debian-update.sh ├── debian-vmware.sh ├── debian-storage.sh ├── debian-system.sh ├── debian-network.sh ├── debian-hashicorp.sh ├── debian-docker.sh ├── debian-cleanup.sh └── debian-settings.sh ├── debian-builder.json ├── debian-minimal-version-11.0.0.json ├── debian-minimal-version-11.1.0.json ├── debian-minimal-version-11.2.0.json ├── debian-minimal-version-11.3.0.json ├── debian-minimal-version-11.4.0.json ├── debian-minimal-version-11.5.0.json ├── debian-minimal-version-11.6.0.json ├── debian-minimal-version-11.7.0.json ├── debian-minimal-version-12.0.0.json ├── debian-minimal-version-12.1.0.json ├── debian-toolbox-version-11.0.0.json ├── debian-toolbox-version-11.1.0.json ├── debian-toolbox-version-11.2.0.json ├── debian-toolbox-version-11.3.0.json ├── debian-toolbox-version-11.4.0.json ├── debian-toolbox-version-11.5.0.json ├── debian-toolbox-version-11.6.0.json ├── debian-toolbox-version-11.7.0.json ├── debian-toolbox-version-12.0.0.json ├── debian-toolbox-version-12.1.0.json ├── LICENSE ├── files ├── bash_profile.sh ├── bash_prompt.sh └── debian-init.py ├── postprocess-ova-properties ├── add_ovf_properties.sh └── appliance.xml.template ├── README.md ├── http └── preseed.cfg ├── debian-minimal.json └── debian-toolbox.json /.gitignore: -------------------------------------------------------------------------------- 1 | *.iso 2 | *.ova 3 | -------------------------------------------------------------------------------- /scripts/debian-update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | 3 | ## 4 | ## Debian Updates 5 | ## Upgrade to latest packages 6 | ## 7 | 8 | echo '> Installing Debian updates...' 9 | 10 | apt-get update 11 | apt-get -y upgrade 12 | 13 | echo '> Done' -------------------------------------------------------------------------------- /scripts/debian-vmware.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | 3 | ## 4 | ## VMware related stuff 5 | ## Install VMware related tools 6 | ## 7 | 8 | echo '> Installing VMware Software...' 9 | 10 | apt-get install -y \ 11 | open-vm-tools 12 | 13 | echo '> Done' -------------------------------------------------------------------------------- /debian-builder.json: -------------------------------------------------------------------------------- 1 | { 2 | "builder_host": "esx.packer.zpod.io", 3 | "builder_host_username": "root", 4 | "builder_host_password": "VMware1!", 5 | "builder_host_datastore": "NFS-01", 6 | "builder_host_folder": "/isos", 7 | "builder_host_portgroup": "VM Network" 8 | } 9 | -------------------------------------------------------------------------------- /scripts/debian-storage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | 3 | ## 4 | ## Debian Storage 5 | ## Install Storage utilities 6 | ## 7 | 8 | echo '> Installing Storage utilities...' 9 | 10 | apt-get install -y \ 11 | pydf \ 12 | yafc \ 13 | pure-ftpd \ 14 | nfs-kernel-server 15 | 16 | echo '> Done' -------------------------------------------------------------------------------- /scripts/debian-system.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | 3 | ## 4 | ## Debian system 5 | ## Install system utilities 6 | ## 7 | 8 | echo '> Installing System Utilities...' 9 | 10 | apt-get install -y \ 11 | jq \ 12 | grc \ 13 | git \ 14 | tmux \ 15 | htop \ 16 | unzip 17 | 18 | echo '> Done' -------------------------------------------------------------------------------- /scripts/debian-network.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | 3 | ## 4 | ## Debian Network 5 | ## Install Network utilities 6 | ## 7 | 8 | 9 | echo '> Installing Network utilities...' 10 | 11 | apt-get install -y \ 12 | ntp \ 13 | frr \ 14 | curl \ 15 | wget \ 16 | rsync \ 17 | telnet \ 18 | netcat-traditional \ 19 | dnsmasq \ 20 | mtr-tiny \ 21 | speedometer \ 22 | bridge-utils 23 | 24 | echo '> Done' 25 | -------------------------------------------------------------------------------- /scripts/debian-hashicorp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | 3 | ## 4 | ## Debian 5 | ## Setup HashiCorp apt repository 6 | ## 7 | 8 | echo '> Setup HashiCorp Repository...' 9 | 10 | # Install pre-requisites 11 | apt-get -y install \ 12 | apt-transport-https \ 13 | ca-certificates \ 14 | curl \ 15 | gnupg2 \ 16 | software-properties-common 17 | 18 | curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - 19 | apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" 20 | 21 | # Refresh sources 22 | apt-get update 23 | 24 | echo '> Done' 25 | 26 | -------------------------------------------------------------------------------- /debian-minimal-version-11.0.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "11.0.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-minimal-11.0.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "ae6d563d2444665316901fe7091059ac34b8f67ba30f9159f7cef7d2fdc5bf8a", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.0.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-minimal-version-11.1.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "11.1.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-minimal-11.1.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "8488abc1361590ee7a3c9b00ec059b29dfb1da40f8ba4adf293c7a30fa943eb2", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.1.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-minimal-version-11.2.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "11.2.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-minimal-11.2.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "45c9feabba213bdc6d72e7469de71ea5aeff73faea6bfb109ab5bad37c3b43bd", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.2.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-minimal-version-11.3.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "11.3.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-minimal-11.3.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "7892981e1da216e79fb3a1536ce5ebab157afdd20048fe458f2ae34fbc26c19b", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.3.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-minimal-version-11.4.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "11.4.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-minimal-11.4.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "d490a35d36030592839f24e468a5b818c919943967012037d6ab3d65d030ef7f", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.4.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-minimal-version-11.5.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "11.5.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-minimal-11.5.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "e307d0e583b4a8f7e5b436f8413d4707dd4242b70aea61eb08591dc0378522f3", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.5.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-minimal-version-11.6.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "11.6.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-minimal-11.6.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "e482910626b30f9a7de9b0cc142c3d4a079fbfa96110083be1d0b473671ce08d", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.6.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-minimal-version-11.7.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "11.7.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-minimal-11.7.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "eb3f96fd607e4b67e80f4fc15670feb7d9db5be50f4ca8d0bf07008cb025766b", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.7.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-minimal-version-12.0.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "12.0.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-minimal-12.0.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "3b0e9718e3653435f20d8c2124de6d363a51a1fd7f911b9ca0c6db6b3d30d53e", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.0.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-minimal-version-12.1.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "12.1.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-minimal-12.1.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "9f181ae12b25840a508786b1756c6352a0e58484998669288c4eec2ab16b8559", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.1.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-toolbox-version-11.0.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "11.0.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-toolbox-11.0.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "ae6d563d2444665316901fe7091059ac34b8f67ba30f9159f7cef7d2fdc5bf8a", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.0.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-toolbox-version-11.1.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "11.1.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-toolbox-11.1.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "8488abc1361590ee7a3c9b00ec059b29dfb1da40f8ba4adf293c7a30fa943eb2", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.1.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-toolbox-version-11.2.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "11.2.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-toolbox-11.2.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "45c9feabba213bdc6d72e7469de71ea5aeff73faea6bfb109ab5bad37c3b43bd", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.2.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-toolbox-version-11.3.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "11.3.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-toolbox-11.3.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "7892981e1da216e79fb3a1536ce5ebab157afdd20048fe458f2ae34fbc26c19b", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.3.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-toolbox-version-11.4.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "11.4.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-toolbox-11.4.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "d490a35d36030592839f24e468a5b818c919943967012037d6ab3d65d030ef7f", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.4.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-toolbox-version-11.5.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "11.5.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-toolbox-11.5.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "e307d0e583b4a8f7e5b436f8413d4707dd4242b70aea61eb08591dc0378522f3", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.5.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-toolbox-version-11.6.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "11.6.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-toolbox-11.6.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "e482910626b30f9a7de9b0cc142c3d4a079fbfa96110083be1d0b473671ce08d", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.6.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-toolbox-version-11.7.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "11.7.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-toolbox-11.7.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "eb3f96fd607e4b67e80f4fc15670feb7d9db5be50f4ca8d0bf07008cb025766b", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.7.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-toolbox-version-12.0.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "12.0.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-toolbox-12.0.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "3b0e9718e3653435f20d8c2124de6d363a51a1fd7f911b9ca0c6db6b3d30d53e", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.0.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /debian-toolbox-version-12.1.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "12.1.0", 3 | "author": "Timo Sugliani", 4 | "website": "https://cloud.tsugliani.fr", 5 | "description": "VMware vSphere Debian Template", 6 | "vm_name": "debian-toolbox-12.1.0", 7 | "guest_os_type": "debian10-64", 8 | "hostname": "debian", 9 | "numvcpus": "2", 10 | "ramsize": "2048", 11 | "disk_size": "8000", 12 | "iso_checksum": "9f181ae12b25840a508786b1756c6352a0e58484998669288c4eec2ab16b8559", 13 | "iso_checksum_type": "sha256", 14 | "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.1.0-amd64-netinst.iso", 15 | "guest_username": "root", 16 | "guest_password": "VMware1!" 17 | } -------------------------------------------------------------------------------- /scripts/debian-docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | 3 | ## 4 | ## Debian Docker 5 | ## Install Docker 6 | ## 7 | 8 | echo '> Installing Docker...' 9 | 10 | # Install pre-requisites 11 | apt-get -y install \ 12 | apt-transport-https \ 13 | ca-certificates \ 14 | curl \ 15 | gnupg2 \ 16 | software-properties-common 17 | 18 | # Fetch Docker official GPG key 19 | curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - 20 | 21 | # Add Docker official repository 22 | add-apt-repository \ 23 | "deb [arch=amd64] https://download.docker.com/linux/debian \ 24 | $(lsb_release -cs) \ 25 | stable" 26 | 27 | # Update sources & install docker 28 | apt-get update 29 | apt-get install -y docker-ce 30 | 31 | echo '> Done' 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Timo Sugliani 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /files/bash_profile.sh: -------------------------------------------------------------------------------- 1 | # Add `~/bin` to the `$PATH` 2 | export PATH="$HOME/bin:$PATH"; 3 | 4 | # Load the shell dotfiles, and then some: 5 | # * ~/.path can be used to extend `$PATH`. 6 | # * ~/.extra can be used for other settings you don’t want to commit. 7 | for file in ~/.{path,bash_prompt,exports,aliases,functions,extra}; do 8 | [ -r "$file" ] && [ -f "$file" ] && source "$file"; 9 | done; 10 | unset file; 11 | 12 | # Case-insensitive globbing (used in pathname expansion) 13 | shopt -s nocaseglob; 14 | 15 | # Append to the Bash history file, rather than overwriting it 16 | shopt -s histappend; 17 | 18 | # Autocorrect typos in path names when using `cd` 19 | shopt -s cdspell; 20 | 21 | # Enable some Bash 4 features when possible: 22 | # * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux` 23 | # * Recursive globbing, e.g. `echo **/*.txt` 24 | for option in autocd globstar; do 25 | shopt -s "$option" 2> /dev/null; 26 | done; 27 | 28 | # Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards 29 | [ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2- | tr ' ' '\n')" scp sftp ssh; 30 | 31 | export LC_ALL=en_US.UTF-8 32 | -------------------------------------------------------------------------------- /scripts/debian-cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | 3 | ## 4 | ## Debian Cleanup 5 | ## Cleaning VM before OVA Export 6 | ## 7 | 8 | # Clean up 9 | echo '> Removing unnecessary packages...' 10 | apt-get -y remove linux-headers-$(uname -r) build-essential 11 | apt-get -y purge $(dpkg --list | grep '^rc' | awk '{print $2}') 12 | 13 | echo '> Removing package manager unused files' 14 | apt-get -y autoremove 15 | apt-get -y clean 16 | apt-get -y autoclean 17 | 18 | echo '> Removing unused locales...' 19 | DEBIAN_FRONTEND=noninteractive apt-get -y install localepurge 20 | sed -i -e 's|^USE_DPKG|#USE_DPKG|' /etc/locale.nopurge 21 | localepurge 22 | apt-get -y purge localepurge 23 | 24 | # cleanup installer resolv.conf 25 | echo "" > /etc/resolv.conf 26 | 27 | # Cleanup log files 28 | echo '> Removing Log files...' 29 | cat /dev/null > /var/log/wtmp 2>/dev/null 30 | logrotate -f /etc/logrotate.conf 2>/dev/null 31 | find /var/log -type f -delete 32 | rm -f /var/lib/dhcp/* 33 | 34 | # Zero out the free space to save space in the final image, blocking 'til 35 | # written otherwise, the disk image won't be zeroed, and/or Packer will try to 36 | # kill the box while the disk is still full and that's bad. The dd will run 37 | # 'til failure, so (due to the 'set -e' above), ignore that failure. Also, 38 | # really make certain that both the zeros and the file removal really sync; the 39 | # extra sleep 1 and sync shouldn't be necessary, but...) 40 | 41 | echo '> Zeroing device to make space...' 42 | dd if=/dev/zero of=/EMPTY bs=1M || true; sync; sleep 1; sync 43 | rm -f /EMPTY; sync; sleep 1; sync 44 | 45 | echo '> Done' 46 | -------------------------------------------------------------------------------- /scripts/debian-settings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | 3 | ## 4 | ## Debian Settings 5 | ## Misc configuration 6 | ## 7 | 8 | echo '> Debian Settings...' 9 | 10 | echo '> Installing resolvconf...' 11 | apt-get install -y resolvconf-admin 12 | echo "nameserver 8.8.8.8" > /etc/resolv.conf 13 | echo "" 14 | 15 | echo '> SSH directory' 16 | mkdir -vp $HOME/.ssh 17 | 18 | echo '> Debian acts as a Router now' 19 | sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf 20 | 21 | echo '> Disable IPv6' 22 | echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf 23 | 24 | echo '> Setup Appliance Banner for /etc/issue & /etc/issue.net' 25 | echo ">>" | tee /etc/issue /etc/issue.net > /dev/null 26 | echo ">> Debian vSphere Appliance $(cat /etc/debian_version)" | tee -a /etc/issue /etc/issue.net > /dev/null 27 | echo ">>" | tee -a /etc/issue /etc/issue.net > /dev/null 28 | sed -i 's/#Banner none/Banner \/etc\/issue.net/g' /etc/ssh/sshd_config 29 | 30 | echo '> Enable rc.local facility for debian-init.py' 31 | cat << EOF > /etc/rc.local 32 | #!/bin/sh -e 33 | # 34 | # rc.local 35 | # 36 | # This script is executed at the end of each multiuser runlevel. 37 | # Make sure that the script will "exit 0" on success or any other 38 | # value on error. 39 | # 40 | # In order to enable or disable this script just change the execution 41 | # bits. 42 | # 43 | # By default this script does nothing. 44 | 45 | if [ ! -f /etc/debian.config ]; then 46 | /sbin/debian-init.py 47 | echo "\$(date)" > /etc/debian.config 48 | fi 49 | 50 | exit 0 51 | EOF 52 | chmod +x /etc/rc.local 53 | systemctl daemon-reload 54 | 55 | echo '> Done' -------------------------------------------------------------------------------- /postprocess-ova-properties/add_ovf_properties.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Original Script from: https://github.com/lamw/vcenter-event-broker-appliance / William Lam 4 | 5 | OUTPUT_PATH="../output-${APPLIANCE_NAME}" 6 | 7 | rm -f ${OUTPUT_PATH}/${APPLIANCE_NAME}.mf 8 | 9 | sed "s/{{APPLIANCE_VERSION}}/${APPLIANCE_VERSION}/g" appliance.xml.template > appliance.xml 10 | 11 | if [ "$(uname)" == "Darwin" ]; then 12 | sed -i .bak1 's///g' ${OUTPUT_PATH}/${APPLIANCE_NAME}.ovf 13 | sed -i .bak2 "/ <\/vmw:BootOrderSection>/ r appliance.xml" ${OUTPUT_PATH}/${APPLIANCE_NAME}.ovf 14 | sed -i .bak3 '/^ //g' ${OUTPUT_PATH}/${APPLIANCE_NAME}.ovf 18 | sed -i "/ <\/vmw:BootOrderSection>/ r appliance.xml" ${OUTPUT_PATH}/${APPLIANCE_NAME}.ovf 19 | sed -i '/^ /dev/null 2>&1; then 7 | export TERM='gnome-256color'; 8 | elif infocmp xterm-256color >/dev/null 2>&1; then 9 | export TERM='xterm-256color'; 10 | fi; 11 | 12 | if tput setaf 1 &> /dev/null; then 13 | tput sgr0; # reset colors 14 | bold=$(tput bold); 15 | reset=$(tput sgr0); 16 | # Solarized colors, taken from http://git.io/solarized-colors. 17 | black=$(tput setaf 0); 18 | blue=$(tput setaf 33); 19 | cyan=$(tput setaf 37); 20 | green=$(tput setaf 64); 21 | orange=$(tput setaf 166); 22 | purple=$(tput setaf 125); 23 | red=$(tput setaf 124); 24 | violet=$(tput setaf 61); 25 | white=$(tput setaf 15); 26 | yellow=$(tput setaf 136); 27 | else 28 | bold=''; 29 | reset="\e[0m"; 30 | black="\e[1;30m"; 31 | blue="\e[1;34m"; 32 | cyan="\e[1;36m"; 33 | green="\e[1;32m"; 34 | orange="\e[1;33m"; 35 | purple="\e[1;35m"; 36 | red="\e[1;31m"; 37 | violet="\e[1;35m"; 38 | white="\e[1;37m"; 39 | yellow="\e[1;33m"; 40 | fi; 41 | 42 | # Highlight the user name when logged in as root. 43 | userStyle="${orange}"; 44 | 45 | # Highlight the hostname when connected via SSH. 46 | hostStyle="${yellow}"; 47 | 48 | # Set the terminal title and prompt. 49 | PS1="\[\033]0;\W\007\]"; # working directory base name 50 | PS1+="\[${bold}\]\n"; # newline 51 | PS1+="\[${userStyle}\]\u"; # username 52 | PS1+="\[${white}\] at "; 53 | PS1+="\[${hostStyle}\]$(hostname -A | xargs)"; # host 54 | PS1+="\[${white}\] in "; 55 | PS1+="\[${green}\]\w"; # working directory full path 56 | PS1+="\n"; 57 | PS1+="\[${white}\]\$ \[${reset}\]"; # `$` (and reset color) 58 | export PS1; 59 | 60 | PS2="\[${yellow}\]→ \[${reset}\]"; 61 | export PS2; 62 | -------------------------------------------------------------------------------- /http/preseed.cfg: -------------------------------------------------------------------------------- 1 | choose-mirror-bin mirror/http/proxy string 2 | d-i apt-setup/use_mirror boolean true 3 | d-i base-installer/kernel/override-image string linux-server 4 | d-i clock-setup/utc boolean true 5 | d-i clock-setup/utc-auto boolean true 6 | d-i finish-install/reboot_in_progress note 7 | d-i grub-installer/only_debian boolean true 8 | d-i grub-installer/with_other_os boolean true 9 | d-i keymap select us 10 | d-i mirror/country string manual 11 | d-i mirror/http/directory string /debian 12 | d-i mirror/http/hostname string http.debian.net 13 | d-i mirror/http/proxy string 14 | d-i partman-auto-lvm/guided_size string max 15 | d-i partman-auto/choose_recipe select atomic 16 | d-i partman-auto/method string regular 17 | d-i partman-lvm/confirm boolean true 18 | d-i partman-lvm/confirm_nooverwrite boolean true 19 | d-i partman-lvm/device_remove_lvm boolean true 20 | d-i partman/choose_partition select finish 21 | d-i partman/confirm boolean true 22 | d-i partman/confirm_nooverwrite boolean true 23 | d-i partman/confirm_write_new_label boolean true 24 | d-i passwd/root-login boolean true 25 | d-i passwd/root-password password VMware1! 26 | d-i passwd/root-password-again password VMware1! 27 | d-i passwd/make-user boolean false 28 | d-i pkgsel/include string openssh-server sudo wget curl 29 | d-i pkgsel/install-language-support boolean false 30 | d-i pkgsel/update-policy select unattended-upgrades 31 | d-i pkgsel/upgrade select full-upgrade 32 | d-i time/zone string UTC 33 | d-i user-setup/allow-password-weak boolean true 34 | d-i user-setup/encrypt-home boolean false 35 | d-i preseed/late_command string \ 36 | sed -i '/^deb cdrom:/s/^/#/' /target/etc/apt/sources.list; \ 37 | echo 'PermitRootLogin yes' >> /target/etc/ssh/sshd_config; 38 | 39 | apt-cdrom-setup apt-setup/cdrom/set-first boolean false 40 | apt-mirror-setup apt-setup/use_mirror boolean true 41 | popularity-contest popularity-contest/participate boolean false 42 | tasksel tasksel/first multiselect minimal 43 | d-i grub-installer/only_debian boolean true 44 | d-i grub-installer/bootdev string 45 | d-i grub-installer/choose_bootdev select /dev/sda -------------------------------------------------------------------------------- /postprocess-ova-properties/appliance.xml.template: -------------------------------------------------------------------------------- 1 | 2 | A Practical Debian Appliance 3 | VMware vSphere Debian Appliance 4 | Timo Sugliani 5 | {{APPLIANCE_VERSION}} 6 | https://github.com/tsugliani/packer-vsphere-debian-appliance 7 | https://cloud.tsugliani.fr 8 | Networking 9 | 10 | 11 | Hostname of system 12 | 13 | 14 | 15 | IP Address of the system (Leave blank for DHCP) 16 | 17 | 18 | 19 | Network CIDR Prefix (Example: 24) 20 | 21 | 22 | 23 | Gateway of the system (Leave blank for DHCP) 24 | 25 | 26 | 27 | DNS Servers (space separated) 28 | 29 | 30 | 31 | Domain 32 | 33 | OS Credentials 34 | 35 | 36 | Password to login in as root. Please use a secure password 37 | 38 | 39 | 40 | Leverage an SSH Key to login as root with no password 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /debian-minimal.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_command": [ 5 | "", 6 | "install ", 7 | "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ", 8 | "debian-installer=en_US ", 9 | "auto ", 10 | "net.ifnames=0 ", 11 | "biosdevname=0 ", 12 | "locale=en_US ", 13 | "kbd-chooser/method=us ", 14 | "keyboard-configuration/xkb-keymap=us ", 15 | "netcfg/choose_interface=eth0 ", 16 | "netcfg/get_hostname={{ user `hostname` }} ", 17 | "netcfg/get_domain=vmware.lab ", 18 | "fb=false ", 19 | "debconf/frontend=noninteractive ", 20 | "console-setup/ask_detect=false ", 21 | "console-keymaps-at/keymap=us ", 22 | "" 23 | ], 24 | "boot_wait": "10s", 25 | "disk_type_id": "zeroedthick", 26 | "format": "ovf", 27 | "headless": false, 28 | "http_directory": "http", 29 | "iso_checksum": "{{ user `iso_checksum_type` }}:{{ user `iso_checksum` }}", 30 | "iso_url": "{{ user `iso_url` }}", 31 | "name": "{{ user `vm_name` }}", 32 | "ovftool_options": "--noImageFiles", 33 | "remote_datastore": "{{ user `builder_host_datastore` }}", 34 | "remote_host": "{{ user `builder_host` }}", 35 | "remote_password": "{{ user `builder_host_password` }}", 36 | "remote_type": "esx5", 37 | "remote_username": "{{ user `builder_host_username` }}", 38 | "shutdown_command": "/sbin/shutdown -Ph now", 39 | "shutdown_timeout": "10s", 40 | "skip_compaction": true, 41 | "ssh_password": "{{ user `guest_password` }}", 42 | "ssh_port": 22, 43 | "ssh_timeout": "60m", 44 | "ssh_username": "{{ user `guest_username` }}", 45 | "type": "vmware-iso", 46 | "version": 14, 47 | "vm_name": "{{ user `vm_name` }}", 48 | "vmdk_name": "{{ user `vm_name` }}-disk0", 49 | "vmx_data": { 50 | "ethernet0.addressType": "generated", 51 | "ethernet0.networkName": "{{ user `builder_host_portgroup` }}", 52 | "ethernet0.present": "TRUE", 53 | "ethernet0.startConnected": "TRUE", 54 | "ethernet0.virtualDev": "vmxnet3", 55 | "ethernet0.wakeOnPcktRcv": "FALSE", 56 | "memsize": "{{ user `ramsize` }}", 57 | "numvcpus": "{{ user `numvcpus` }}" 58 | }, 59 | "vnc_disable_password": true 60 | } 61 | ], 62 | "post-processors": [ 63 | { 64 | "environment_vars": [ 65 | "APPLIANCE_NAME={{ user `vm_name` }}", 66 | "APPLIANCE_VERSION={{ user `version` }}", 67 | "APPLIANCE_OVA={{ user `vm_name` }}_{{user `version`}}" 68 | ], 69 | "inline": [ 70 | "cd postprocess-ova-properties", 71 | "./add_ovf_properties.sh" 72 | ], 73 | "type": "shell-local" 74 | } 75 | ], 76 | "provisioners": [ 77 | { 78 | "destination": "/root/.bash_profile", 79 | "source": "files/bash_profile.sh", 80 | "type": "file" 81 | }, 82 | { 83 | "destination": "/root/.bash_prompt", 84 | "source": "files/bash_prompt.sh", 85 | "type": "file" 86 | }, 87 | { 88 | "destination": "/sbin/debian-init.py", 89 | "source": "files/debian-init.py", 90 | "type": "file" 91 | }, 92 | { 93 | "type": "shell", 94 | "environment_vars": ["DEBIAN_FRONTEND=noninteractive"], 95 | "scripts": [ 96 | "scripts/debian-update.sh", 97 | "scripts/debian-vmware.sh", 98 | "scripts/debian-settings.sh", 99 | "scripts/debian-cleanup.sh" 100 | ] 101 | } 102 | ] 103 | } 104 | 105 | -------------------------------------------------------------------------------- /debian-toolbox.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_command": [ 5 | "", 6 | "install ", 7 | "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ", 8 | "debian-installer=en_US ", 9 | "auto ", 10 | "net.ifnames=0 ", 11 | "biosdevname=0 ", 12 | "locale=en_US ", 13 | "kbd-chooser/method=us ", 14 | "keyboard-configuration/xkb-keymap=us ", 15 | "netcfg/choose_interface=eth0 ", 16 | "netcfg/get_hostname={{ user `hostname` }} ", 17 | "netcfg/get_domain=vmware.lab ", 18 | "fb=false ", 19 | "debconf/frontend=noninteractive ", 20 | "console-setup/ask_detect=false ", 21 | "console-keymaps-at/keymap=us ", 22 | "" 23 | ], 24 | "boot_wait": "10s", 25 | "disk_type_id": "zeroedthick", 26 | "format": "ovf", 27 | "headless": false, 28 | "http_directory": "http", 29 | "iso_checksum": "{{ user `iso_checksum_type` }}:{{ user `iso_checksum` }}", 30 | "iso_url": "{{ user `iso_url` }}", 31 | "name": "{{ user `vm_name` }}", 32 | "ovftool_options": "--noImageFiles", 33 | "remote_datastore": "{{ user `builder_host_datastore` }}", 34 | "remote_host": "{{ user `builder_host` }}", 35 | "remote_password": "{{ user `builder_host_password` }}", 36 | "remote_type": "esx5", 37 | "remote_username": "{{ user `builder_host_username` }}", 38 | "shutdown_command": "/sbin/shutdown -Ph now", 39 | "shutdown_timeout": "10s", 40 | "skip_compaction": true, 41 | "ssh_password": "{{ user `guest_password` }}", 42 | "ssh_port": 22, 43 | "ssh_timeout": "60m", 44 | "ssh_username": "{{ user `guest_username` }}", 45 | "type": "vmware-iso", 46 | "version": 14, 47 | "vm_name": "{{ user `vm_name` }}", 48 | "vmdk_name": "{{ user `vm_name` }}-disk0", 49 | "vmx_data": { 50 | "ethernet0.addressType": "generated", 51 | "ethernet0.networkName": "{{ user `builder_host_portgroup` }}", 52 | "ethernet0.present": "TRUE", 53 | "ethernet0.startConnected": "TRUE", 54 | "ethernet0.virtualDev": "vmxnet3", 55 | "ethernet0.wakeOnPcktRcv": "FALSE", 56 | "memsize": "{{ user `ramsize` }}", 57 | "numvcpus": "{{ user `numvcpus` }}" 58 | }, 59 | "vnc_disable_password": true 60 | } 61 | ], 62 | "post-processors": [ 63 | { 64 | "environment_vars": [ 65 | "APPLIANCE_NAME={{ user `vm_name` }}", 66 | "APPLIANCE_VERSION={{ user `version` }}", 67 | "APPLIANCE_OVA={{ user `vm_name` }}_{{user `version`}}" 68 | ], 69 | "inline": [ 70 | "cd postprocess-ova-properties", 71 | "./add_ovf_properties.sh" 72 | ], 73 | "type": "shell-local" 74 | } 75 | ], 76 | "provisioners": [ 77 | { 78 | "destination": "/root/.bash_profile", 79 | "source": "files/bash_profile.sh", 80 | "type": "file" 81 | }, 82 | { 83 | "destination": "/root/.bash_prompt", 84 | "source": "files/bash_prompt.sh", 85 | "type": "file" 86 | }, 87 | { 88 | "destination": "/sbin/debian-init.py", 89 | "source": "files/debian-init.py", 90 | "type": "file" 91 | }, 92 | { 93 | "type": "shell", 94 | "environment_vars": ["DEBIAN_FRONTEND=noninteractive"], 95 | "scripts": [ 96 | "scripts/debian-update.sh", 97 | "scripts/debian-system.sh", 98 | "scripts/debian-storage.sh", 99 | "scripts/debian-network.sh", 100 | "scripts/debian-docker.sh", 101 | "scripts/debian-hashicorp.sh", 102 | "scripts/debian-vmware.sh", 103 | "scripts/debian-settings.sh", 104 | "scripts/debian-cleanup.sh" 105 | ] 106 | } 107 | ] 108 | } 109 | 110 | -------------------------------------------------------------------------------- /files/debian-init.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Debian Init script 6 | Based on https://vuptime.io/2017/03/06/vmware-dive-into-ovf-properties/ 7 | (password & initial python code for ovfenv properties) 8 | """ 9 | 10 | import subprocess 11 | from xml.dom.minidom import parseString 12 | 13 | 14 | def appliance_get_ovf_properties(): 15 | """ 16 | Return a dict of OVF properties in the ovfenv 17 | """ 18 | ovfenv_cmd = "/usr/bin/vmtoolsd --cmd 'info-get guestinfo.ovfEnv'" 19 | 20 | properties = {} 21 | xml_parts = subprocess.Popen(ovfenv_cmd, shell=True, stdout=subprocess.PIPE).stdout.read() 22 | raw_data = parseString(xml_parts) 23 | 24 | # [0] as we have all the ovfenv sections from the vApp & VMs 25 | appliancePropertySection = raw_data.getElementsByTagName("PropertySection")[0] 26 | 27 | for property in appliancePropertySection.getElementsByTagName('Property'): 28 | key, value = [ 29 | property.attributes['oe:key'].value, 30 | property.attributes['oe:value'].value 31 | ] 32 | properties[key] = value 33 | return properties 34 | 35 | 36 | def appliance_create_network_config(properties): 37 | """ 38 | Create debian /etc/network/interfaces file & restart networking. 39 | if properties['guestinfo.ipaddress'] exists, setup static network 40 | -> This assumes all the other ovf variables are correct 41 | else 42 | -> This assumes this VM will leverage DHCP 43 | """ 44 | 45 | if properties['guestinfo.ipaddress']: 46 | 47 | network_cmd = """cat << EOF > /etc/network/interfaces 48 | # This file describes the network interfaces available on your system 49 | # and how to activate them. For more information, see interfaces(5). 50 | 51 | source /etc/network/interfaces.d/* 52 | 53 | # The loopback network interface 54 | auto lo 55 | iface lo inet loopback 56 | 57 | # The primary network interface 58 | auto eth0 59 | iface eth0 inet static 60 | address {ipaddress}/{netprefix} 61 | gateway {gateway} 62 | dns-nameservers {dns} 63 | EOF 64 | systemctl restart networking 65 | """.format( 66 | ipaddress=properties['guestinfo.ipaddress'], 67 | netprefix=properties['guestinfo.netprefix'], 68 | gateway=properties['guestinfo.gateway'], 69 | dns=properties['guestinfo.dns'] 70 | ) 71 | 72 | subprocess.Popen(network_cmd, shell=True, stdout=subprocess.PIPE).stdout.read() 73 | 74 | 75 | def appliance_create_hostfile_config(properties): 76 | """ 77 | Create debian /etc/hosts file for dnsmasq expand-hosts directive. 78 | """ 79 | 80 | if properties['guestinfo.hostname'] and \ 81 | properties['guestinfo.ipaddress'] and \ 82 | properties['guestinfo.domain']: 83 | 84 | hostfile_cmd = """cat << EOF > /etc/hosts 85 | 127.0.0.1 localhost 86 | {ipaddress} {hostname}.{domain} {hostname} 87 | 88 | EOF 89 | hostnamectl set-hostname {hostname} 90 | """.format( 91 | hostname=properties['guestinfo.hostname'], 92 | ipaddress=properties['guestinfo.ipaddress'], 93 | domain=properties['guestinfo.domain'] 94 | ) 95 | 96 | subprocess.Popen(hostfile_cmd, shell=True, stdout=subprocess.PIPE).stdout.read() 97 | 98 | 99 | def appliance_update_credentials(properties): 100 | """ 101 | Update Appliance root password & SSH KEY 102 | """ 103 | 104 | if properties['guestinfo.password']: 105 | password_cmd = """echo root:{password} | chpasswd""".format(password=properties['guestinfo.password']) 106 | subprocess.Popen(password_cmd, shell=True, stdout=subprocess.PIPE).stdout.read() 107 | 108 | if properties['guestinfo.sshkey']: 109 | sshkey_cmd = """echo '{sshkey}' >> /root/.ssh/authorized_keys""".format(sshkey=properties['guestinfo.sshkey']) 110 | subprocess.Popen(sshkey_cmd, shell=True, stdout=subprocess.PIPE).stdout.read() 111 | 112 | # Appliance configuration flow. 113 | # Fetch properties from OVF Environment 114 | # 1. Setup Appliance Networking 115 | # 2. Setup /etc/hosts & /etc/hostname file 116 | # 3. Update Root password & SSH Key 117 | # 4. Update banners & login ttys 118 | # 119 | 120 | 121 | properties = appliance_get_ovf_properties() 122 | appliance_create_network_config(properties) 123 | appliance_create_hostfile_config(properties) 124 | appliance_update_credentials(properties) 125 | --------------------------------------------------------------------------------