diff --git a/doc/PACKER.md b/doc/PACKER.md new file mode 100644 index 0000000..b278f36 --- /dev/null +++ b/doc/PACKER.md @@ -0,0 +1,67 @@ +# [Packer](https://www.packer.io) Templates + +The most of settings are specified as variables. This allows to override them +with `-var` key without template modification. A few environment variables +should be specified as a safety measure. See `debian.json` `ubuntu.json` with +the post-processors section with all details about deploying the Vagrant Boxes +to Atlas. + +## Custom builds + +### Ubuntu build + +```sh + UBUNTU_MAJOR_VERSION=16.04 \ + UBUNTU_MINOR_VERSION=.1 \ + UBUNTU_TYPE=server \ + ARCH=amd64 \ + HEADLESS=true \ + packer build -var 'cpus=2' ubuntu.json +``` + +### Debian build +```sh + DEBIAN_MAJOR_VERSION=8 \ + DEBIAN_MINOR_VERSION=5 \ + ARCH=amd64 \ + HEADLESS=true \ + packer build -var 'cpus=2' debian.json +``` + +## Login Credentials + +(root password is "vagrant" or is not set ) + +* Username: vagrant +* Password: vagrant + +SSH_USER may be used to create a different user whci may be used later to +access environment. + +## VM Specifications + +* Vagrant Libvirt Provider +* Vagrant Virtualbox Provider + +### qemu + +* VirtIO dynamic Hard Disk (up to 10 GiB) + +#### Customized installation + +Debian configuration is based on +[jessie preseed](https://www.debian.org/releases/jessie/example-preseed.txt). +Ubuntu configuration is based on +[xenial preseed](https://help.ubuntu.com/lts/installation-guide/example-preseed.txt). +A few modifications have been made. Use `diff` for more details. + +##### Debian/Ubuntu installation + +* en_US.UTF-8 +* keymap for standard US keyboard +* UTC timezone +* NTP enabled (default configuration) +* full-upgrade +* unattended-upgrades +* /dev/vda1 mounted on / using ext4 filesystem (all files in one partition) +* no swap diff --git a/utils/packer/.gitignore b/utils/packer/.gitignore new file mode 100644 index 0000000..1b95e5d --- /dev/null +++ b/utils/packer/.gitignore @@ -0,0 +1,2 @@ +packer_cache +*.retry diff --git a/utils/packer/Vagrantfile-qemu.template b/utils/packer/Vagrantfile-qemu.template new file mode 100644 index 0000000..2dbfab1 --- /dev/null +++ b/utils/packer/Vagrantfile-qemu.template @@ -0,0 +1,6 @@ + +Vagrant.configure("2") do |config| + config.vm.provider :libvirt do |domain| + domain.disk_bus = "virtio" + end +end diff --git a/utils/packer/debian.json b/utils/packer/debian.json new file mode 100644 index 0000000..4d2a4b8 --- /dev/null +++ b/utils/packer/debian.json @@ -0,0 +1,169 @@ +{ + "_comment": "Build with `PACKER_LOG=1 DEBIAN_MAJOR_VERSION=8 DEBIAN_MINOR_VERSION=5 ARCH=amd64 HEADLESS=true packer build debian.json`", + + "variables": { + "name": "debian-{{ env `DEBIAN_MAJOR_VERSION` }}.{{ env `DEBIAN_MINOR_VERSION` }}.0-{{ env `ARCH` }}", + "iso_name": "debian-{{ env `DEBIAN_MAJOR_VERSION` }}.{{ env `DEBIAN_MINOR_VERSION` }}.0-{{ env `ARCH` }}-netinst", + "debian_type": "{{ env `DEBIAN_TYPE` }}", + "debian_version": "{{ env `DEBIAN_MAJOR_VERSION` }}.{{ env `DEBIAN_MINOR_VERSION` }}.0", + "debian_mirror": "http://cdimage.debian.org/cdimage/release/", + "debian_archive": "http://cdimage.debian.org/mirror/cdimage/archive/", + "ssh_username": "vagrant", + "ssh_password": "vagrant", + "ssh_wait_timeout": "30m", + "preseed_file_name": "debian-{{ env `DEBIAN_MAJOR_VERSION`}}/preseed.cfg", + "accelerator": "kvm", + "cpus": "1", + "memory": "1024", + "disk_size": "10240", + "headless": "{{ env `HEADLESS` }}", + "boot_wait": "10s", + "install_vagrant_key": "true", + "update": "true" + }, + + "builders": + [ + { + "type": "qemu", + "vm_name": "qemu-{{ user `name` }}", + "iso_checksum_type": "sha256", + "iso_checksum_url": "{{ user `debian_mirror` }}/{{ user `debian_version` }}/amd64/iso-cd/SHA256SUMS", + "iso_urls": [ + "{{ user `debian_mirror` }}/{{ user `debian_version` }}/amd64/iso-cd/{{ user `iso_name` }}.iso" + ], + "shutdown_command": "echo '{{ user `ssh_password` }}' | sudo -S shutdown -P now", + "disk_size": "{{ user `disk_size` }}", + "headless": "{{ user `headless` }}", + "http_directory": "http", + "ssh_username": "{{ user `ssh_username` }}", + "ssh_password": "{{ user `ssh_password` }}", + "ssh_wait_timeout": "{{ user `ssh_wait_timeout` }}", + + "accelerator": "{{ user `accelerator` }}", + "qemuargs": [ + [ "-smp", "{{ user `cpus` }}" ], + [ "-m", "{{ user `memory` }}M" ] + ], + + "boot_wait": "{{ user `boot_wait` }}", + "boot_command": + [ + "", + "install ", + "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{ user `preseed_file_name` }} ", + "debian-installer=en_US ", + "auto=true ", + "locale=en_US ", + "kbd-chooser/method=us ", + "keyboard-configuration/xkb-keymap=us ", + "fb=false ", + "debconf/frontend=noninteractive ", + "console-setup/ask_detect=false ", + "console-keymaps-at/keymap=us ", + "domain=localhost ", + "hostname=localhost ", + "net.ifnames=0 ", + "" + ] + }, + { + "type": "virtualbox-iso", + "vm_name": "virtualbox-{{ user `name` }}", + "iso_checksum_type": "sha256", + "iso_checksum_url": "{{ user `debian_mirror` }}/{{ user `debian_version` }}/amd64/iso-cd/SHA256SUMS", + "iso_urls": [ + "{{ user `debian_mirror` }}/{{ user `debian_version` }}/amd64/iso-cd/{{ user `iso_name` }}.iso" + ], + "shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now", + "disk_size": "{{ user `disk_size` }}", + "headless": "{{ user `headless` }}", + "http_directory": "http", + "ssh_username": "{{ user `ssh_username` }}", + "ssh_password": "{{ user `ssh_password` }}", + "ssh_wait_timeout": "{{ user `ssh_wait_timeout` }}", + + "guest_os_type": "Ubuntu_64", + "guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso", + "virtualbox_version_file": ".vbox_version", + + "vboxmanage": [ + [ "modifyvm", "{{.Name}}", "--cpus", "{{ user `cpus` }}" ], + [ "modifyvm", "{{.Name}}", "--memory", "{{ user `memory` }}" ] + ], + + "boot_wait": "{{ user `boot_wait` }}", + "boot_command": + [ + "", + "install ", + "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{ user `preseed_file_name` }} ", + "debian-installer=en_US ", + "auto=true ", + "locale=en_US ", + "kbd-chooser/method=us ", + "keyboard-configuration/xkb-keymap=us ", + "fb=false ", + "debconf/frontend=noninteractive ", + "console-setup/ask_detect=false ", + "console-keymaps-at/keymap=us ", + "domain=localhost ", + "hostname=localhost ", + "net.ifnames=0 ", + "" + ] + } + ], + + "provisioners": [ + { + "type": "shell", + "environment_vars": [ + "INSTALL_VAGRANT_KEY={{ user `install_vagrant_key` }}", + "UPDATE={{ user `update` }}", + "DEBIAN_FRONTEND=noninteractive" + ], + "execute_command": "echo '{{ user `ssh_password` }}' | {{.Vars}} sudo -S -E bash -x '{{.Path}}'", + "scripts": [ + "scripts/debian/update.sh", + "scripts/debian/packages.sh", + "scripts/debian/console.sh", + "scripts/debian/setup.sh", + "scripts/vagrant.sh", + "scripts/sshd.sh", + "scripts/vmtool.sh" + ] + }, + { + "type": "shell", + "execute_command": "echo '{{ user `ssh_password` }}' | {{.Vars}} sudo -S -E bash -x '{{.Path}}'", + "scripts": [ + "scripts/debian/cleanup.sh", + "scripts/minimize.sh" + ] + } + ], + + "post-processors": [ + { + "type": "shell-local", + "only": [ "qemu" ], + "inline": [ + "qemu-img convert -c -f qcow2 -O qcow2 -o cluster_size=2M ./output-qemu/qemu-{{user `name`}} {{user `name`}}.qcow2" + ] + }, + { + "type": "vagrant", + "only": [ "qemu" ], + "compression_level": 9, + "vagrantfile_template": "Vagrantfile-qemu.template", + "output": "{{ user `name` }}-{{.Provider}}.box" + }, + { + "type": "vagrant", + "only": [ "virtualbox-iso" ], + "compression_level": 9, + "output": "{{ user `name` }}-{{.Provider}}.box" + } + ] +} diff --git a/utils/packer/debian8.5/debian-8.5-amd64.json b/utils/packer/debian8.5/debian-8.5-amd64.json deleted file mode 100644 index 9e14f4e..0000000 --- a/utils/packer/debian8.5/debian-8.5-amd64.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "variables": { - "name": "debian-85-jessie", - "user": "vagrant", - "password": "vagrant", - "disk_size": "100000" - }, - - "builders": - [ - { - "name": "{{user `name`}}", - - "iso_url": "http://cdimage.debian.org/cdimage/release/8.5.0/amd64/iso-cd/debian-8.5.0-amd64-netinst.iso", - "iso_checksum": "ad4e8c27c561ad8248d5ebc1d36eb172f884057bfeb2c22ead823f59fa8c3dff", - "iso_checksum_type": "SHA256", - - "type": "qemu", - "accelerator": "kvm", - "disk_size": "{{ user `disk_size`}}", - "disk_cache": "unsafe", - "disk_discard": "unmap", - "format": "qcow2", - "headless": true, - - "http_directory": "http", - - "ssh_username": "{{user `user`}}", - "ssh_password": "{{user `password`}}", - "ssh_wait_timeout": "10m", - "shutdown_command": "echo '{{user `password`}}'|sudo -S shutdown -P now", - - "boot_wait": "10s", - "boot_command": [ - "", - "install ", - "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed_jessie.cfg ", - "debian-installer=en_US ", - "auto=true ", - "locale=en_US ", - "kbd-chooser/method=us ", - "keyboard-configuration/xkb-keymap=us ", - "fb=false ", - "hostname=debian85 ", - "domain=debian85 ", - "console-setup/ask_detect=false ", - "console-keymaps-at/keymap=us ", - "" - ] - } - ], - - "provisioners": [ - { - "type": "shell", - "execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S bash '{{.Path}}'", - "scripts": [ - "scripts/packages.sh", - "scripts/setup.sh", - "scripts/cleanup.sh" - ] - } - ], - - "post-processors": [ - { - "type": "shell-local", - "inline": ["qemu-img convert -c -f qcow2 -O qcow2 -o cluster_size=2M ./output-{{user `name`}}/packer-{{user `name`}} ./output-{{user `name`}}/packer-{{user `name`}}.qcow2"] - } - ] -} diff --git a/utils/packer/debian8.5/http/preseed_jessie.cfg b/utils/packer/debian8.5/http/preseed_jessie.cfg deleted file mode 100644 index 471db7b..0000000 --- a/utils/packer/debian8.5/http/preseed_jessie.cfg +++ /dev/null @@ -1,49 +0,0 @@ -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 grub-installer/bootdev string /dev/vda -d-i keymap select us -d-i mirror/country string manual -d-i mirror/http/directory string /debian -d-i mirror/http/hostname string http.debian.net -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 regular -d-i partman-lvm/device_remove_lvm boolean true -d-i partman-md/device_remove_md boolean true -d-i partman-lvm/confirm 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 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 -d-i partman-basicfilesystems/no_mount_point yes -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 900 -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 openssh-server sudo -d-i pkgsel/install-language-support boolean false -d-i pkgsel/update-policy select unattended-upgrades -d-i pkgsel/upgrade select full-upgrade -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, ubuntu-server diff --git a/utils/packer/debian8.5/scripts/cleanup.sh b/utils/packer/debian8.5/scripts/cleanup.sh deleted file mode 100644 index 2ff9175..0000000 --- a/utils/packer/debian8.5/scripts/cleanup.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -eux - -apt-get -y autoremove --purge -find /var/cache -type f -exec rm -rf {} \; -find /var/lib/apt -type f | xargs rm -f - -rm -rf /dev/.udev/ -rm -f /lib/udev/rules.d/75-persistent-net-generator.rules -rm -f /etc/udev/rules.d/70-persistent-net.rules -mkdir -p /etc/udev/rules.d/70-persistent-net.rules - -if [ -d "/var/lib/dhcp" ]; then - rm -f /var/lib/dhcp/* -fi - -rm -rf /tmp/* - -unset HISTFILE -rm -f /root/.bash_history -rm -f /home/vagrant/.bash_history - -find /var/log -type f | while read f; do echo -ne '' > $f; done; - ->/var/log/lastlog ->/var/log/wtmp ->/var/log/btmp - -sync diff --git a/utils/packer/debian8.5/scripts/setup.sh b/utils/packer/debian8.5/scripts/setup.sh deleted file mode 100644 index 45ee91e..0000000 --- a/utils/packer/debian8.5/scripts/setup.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -eux - -# configure serial console: -cat >> /etc/default/grub < /etc/sudoers.d/vagrant -sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers - -# Setup key-based authentication between VMs: -mkdir /home/vagrant/.ssh -cat > /home/vagrant/.ssh/id_rsa_vagrant.pub <> /home/vagrant/.ssh/authorized_keys -cat > /home/vagrant/.ssh/id_rsa_vagrant <> /etc/rsyslog.d/50-default.conf - -# add default user to necessary groups: -# workaround for Docker not being installed yet: -groupadd -f docker -usermod -aG docker vagrant - -# Set vim as a default editor -update-alternatives --set editor /usr/bin/vim.basic diff --git a/utils/packer/deploy.sh b/utils/packer/deploy.sh new file mode 100755 index 0000000..56b57a9 --- /dev/null +++ b/utils/packer/deploy.sh @@ -0,0 +1,47 @@ +#!/bin/bash -x + +USER=${ATLAS_USER:-mirantis} +DEBIAN_MAJOR_VERSION=${DEBIAN_MAJOR_VERSION:-8} +DEBIAN_MINOR_VERSION=${DEBIAN_MINOR_VERSION:-5} +ARCH=${ARCH:-amd64} +TYPE=${TYPE:-libvirt} +NAME="debian-${DEBIAN_MAJOR_VERSION}.${DEBIAN_MINOR_VERSION}.0-${ARCH}" + +create_atlas_box() { + if curl -sSL https://atlas.hashicorp.com/api/v1/box/${USER}/${NAME} | grep -q "Resource not found"; then + #Create box, because it doesn't exists + echo "*** Creating box: ${NAME}, Short Description: ${SHORT_DESCRIPTION}" + curl -s https://atlas.hashicorp.com/api/v1/boxes -X POST -d box[name]="${NAME}" -d box[short_description]="${SHORT_DESCRIPTION}" -d box[is_private]=false -d access_token="${ATLAS_TOKEN}" + fi +} + +remove_atlas_box() { + echo "*** Removing box: ${USER}/${NAME}" + curl -sSL https://atlas.hashicorp.com/api/v1/box/${USER}/${NAME} -X DELETE -d access_token="${ATLAS_TOKEN}" +} + +remove_atlas_box_version() { + echo "*** Removing previous version: https://atlas.hashicorp.com/api/v1/box/$USER/$NAME/version/$1" + curl -s https://atlas.hashicorp.com/api/v1/box/$USER/$NAME/version/$1 -X DELETE -d access_token="$ATLAS_TOKEN" > /dev/null +} + +upload_boxfile_to_atlas() { + echo "*** Getting current version of the box (if exists)" + local CURRENT_VERSION=$(curl -sS -L https://atlas.hashicorp.com/api/v1/box/${USER}/${NAME} -X GET -d access_token="${ATLAS_TOKEN}" | jq 'if .current_version.version == null then "0" else .current_version.version end | tonumber') + local VERSION=$(echo "${CURRENT_VERSION} + 0.1" | bc | sed 's/^\./0./') + echo "*** Uploading a version: ${VERSION}" + curl -sSL https://atlas.hashicorp.com/api/v1/box/${USER}/${NAME}/versions -X POST -d version[version]="${VERSION}" -d access_token="${ATLAS_TOKEN}" > /dev/null + curl -sSL https://atlas.hashicorp.com/api/v1/box/${USER}/${NAME}/version/${VERSION} -X PUT -d version[description]="${DESCRIPTION}" -d access_token="${ATLAS_TOKEN}" > /dev/null + curl -sSL https://atlas.hashicorp.com/api/v1/box/${USER}/${NAME}/version/${VERSION}/providers -X POST -d provider[name]="${TYPE}" -d access_token="${ATLAS_TOKEN}" > /dev/null + UPLOAD_PATH=$(curl -sS https://atlas.hashicorp.com/api/v1/box/${USER}/${NAME}/version/${VERSION}/provider/${TYPE}/upload?access_token=${ATLAS_TOKEN} | jq -r '.upload_path') + echo "*** Uploding \"${NAME}-${TYPE}.box\" to ${UPLOAD_PATH}" + curl -sSL -X PUT --upload-file ${NAME}-${TYPE}.box ${UPLOAD_PATH} + curl -sSL https://atlas.hashicorp.com/api/v1/box/${USER}/${NAME}/version/${VERSION}/release -X PUT -d access_token="${ATLAS_TOKEN}" > /dev/null +} + +export DESCRIPTION=$(cat ../../doc/PACKER.md) +export SHORT_DESCRIPTION="${NAME} for ${TYPE}" +create_atlas_box +upload_boxfile_to_atlas + +#remove_atlas_box diff --git a/utils/packer/http/debian-8/preseed.cfg b/utils/packer/http/debian-8/preseed.cfg new file mode 100644 index 0000000..73a8c1e --- /dev/null +++ b/utils/packer/http/debian-8/preseed.cfg @@ -0,0 +1,438 @@ +#### Contents of the preconfiguration file (for jessie) +### Localization +# Preseeding only locale sets language, country and locale. +d-i debian-installer/locale string en_US + +# The values can also be preseeded individually for greater flexibility. +d-i debian-installer/language string en +d-i debian-installer/country string US +d-i debian-installer/locale string en_US.UTF-8 +# Optionally specify additional locales to be generated. +#d-i localechooser/supported-locales multiselect en_US.UTF-8, nl_NL.UTF-8 + +# Keyboard selection. +d-i keyboard-configuration/xkb-keymap select us +# d-i keyboard-configuration/toggle select No toggling + +### Network configuration +# Disable network configuration entirely. This is useful for cdrom +# installations on non-networked devices where the network questions, +# warning and long timeouts are a nuisance. +#d-i netcfg/enable boolean false + +# netcfg will choose an interface that has link if possible. This makes it +# skip displaying a list if there is more than one interface. +d-i netcfg/choose_interface select auto + +# To pick a particular interface instead: +#d-i netcfg/choose_interface select eth1 + +# To set a different link detection timeout (default is 3 seconds). +# Values are interpreted as seconds. +#d-i netcfg/link_wait_timeout string 10 + +# If you have a slow dhcp server and the installer times out waiting for +# it, this might be useful. +#d-i netcfg/dhcp_timeout string 60 +#d-i netcfg/dhcpv6_timeout string 60 + +# If you prefer to configure the network manually, uncomment this line and +# the static network configuration below. +#d-i netcfg/disable_autoconfig boolean true + +# If you want the preconfiguration file to work on systems both with and +# without a dhcp server, uncomment these lines and the static network +# configuration below. +#d-i netcfg/dhcp_failed note +#d-i netcfg/dhcp_options select Configure network manually + +# Static network configuration. +# +# IPv4 example +#d-i netcfg/get_ipaddress string 192.168.1.42 +#d-i netcfg/get_netmask string 255.255.255.0 +#d-i netcfg/get_gateway string 192.168.1.1 +#d-i netcfg/get_nameservers string 192.168.1.1 +#d-i netcfg/confirm_static boolean true +# +# IPv6 example +#d-i netcfg/get_ipaddress string fc00::2 +#d-i netcfg/get_netmask string ffff:ffff:ffff:ffff:: +#d-i netcfg/get_gateway string fc00::1 +#d-i netcfg/get_nameservers string fc00::1 +#d-i netcfg/confirm_static boolean true + +# Any hostname and domain names assigned from dhcp take precedence over +# values set here. However, setting the values still prevents the questions +# from being shown, even if values come from dhcp. +d-i netcfg/get_hostname string unassigned-hostname +d-i netcfg/get_domain string unassigned-domain + +# If you want to force a hostname, regardless of what either the DHCP +# server returns or what the reverse DNS entry for the IP is, uncomment +# and adjust the following line. +#d-i netcfg/hostname string somehost + +# Disable that annoying WEP key dialog. +d-i netcfg/wireless_wep string +# The wacky dhcp hostname that some ISPs use as a password of sorts. +#d-i netcfg/dhcp_hostname string radish + +# If non-free firmware is needed for the network or other hardware, you can +# configure the installer to always try to load it, without prompting. Or +# change to false to disable asking. +#d-i hw-detect/load_firmware boolean true + +### Network console +# Use the following settings if you wish to make use of the network-console +# component for remote installation over SSH. This only makes sense if you +# intend to perform the remainder of the installation manually. +#d-i anna/choose_modules string network-console +#d-i network-console/authorized_keys_url string http://10.0.0.1/openssh-key +#d-i network-console/password password r00tme +#d-i network-console/password-again password r00tme + +### Mirror settings +# If you select ftp, the mirror/country string does not need to be set. +#d-i mirror/protocol string ftp +d-i mirror/country string manual +d-i mirror/http/hostname string http.us.debian.org +d-i mirror/http/directory string /debian +d-i mirror/http/proxy string + +# Suite to install. +#d-i mirror/suite string testing +# Suite to use for loading installer components (optional). +#d-i mirror/udeb/suite string testing + +### Account setup +# Skip creation of a root account (normal user account will be able to +# use sudo). +d-i passwd/root-login boolean false +# Alternatively, to skip creation of a normal user account. +#d-i passwd/make-user boolean false + +# Root password, either in clear text +d-i passwd/root-password password vagrant +d-i passwd/root-password-again password vagrant +# or encrypted using an MD5 hash. +#d-i passwd/root-password-crypted password [MD5 hash] + +# To create a normal user account. +d-i passwd/user-fullname string vagrant +d-i passwd/username string vagrant +# Normal user's password, either in clear text +d-i passwd/user-password password vagrant +d-i passwd/user-password-again password vagrant +# or encrypted using an MD5 hash. +#d-i passwd/user-password-crypted password [MD5 hash] +# Create the first user with the specified UID instead of the default. +#d-i passwd/user-uid string 1010 +d-i user-setup/allow-password-weak boolean true + +# The user account will be added to some standard initial groups. To +# override that, use this. +#d-i passwd/user-default-groups string audio cdrom video + +### Clock and time zone setup +# Controls whether or not the hardware clock is set to UTC. +d-i clock-setup/utc boolean true + +# You may set this to any valid setting for $TZ; see the contents of +# /usr/share/zoneinfo/ for valid values. +d-i time/zone string UTC + +# Controls whether to use NTP to set the clock during the install +d-i clock-setup/ntp boolean true +# NTP server to use. The default is almost always fine here. +#d-i clock-setup/ntp-server string ntp.example.com + +### Partitioning +## Partitioning example +# If the system has free space you can choose to only partition that space. +# This is only honoured if partman-auto/method (below) is not set. +#d-i partman-auto/init_automatically_partition select biggest_free + +# Alternatively, you may specify a disk to partition. If the system has only +# one disk the installer will default to using that, but otherwise the device +# name must be given in traditional, non-devfs format (so e.g. /dev/sda +# and not e.g. /dev/discs/disc0/disc). +# For example, to use the first SCSI/SATA hard disk: +#d-i partman-auto/disk string /dev/sda +# In addition, you'll need to specify the method to use. +# The presently available methods are: +# - regular: use the usual partition types for your architecture +# - lvm: use LVM to partition the disk +# - crypto: use LVM within an encrypted partition +d-i partman-auto/method string regular + +# If one of the disks that are going to be automatically partitioned +# contains an old LVM configuration, the user will normally receive a +# warning. This can be preseeded away... +d-i partman-lvm/device_remove_lvm boolean true +# The same applies to pre-existing software RAID array: +d-i partman-md/device_remove_md boolean true +# And the same goes for the confirmation to write the lvm partitions. +d-i partman-lvm/confirm boolean true +d-i partman-lvm/confirm_nooverwrite boolean true + +# You can choose one of the three predefined partitioning recipes: +# - atomic: all files in one partition +# - home: separate /home partition +# - multi: separate /home, /var, and /tmp partitions +d-i partman-auto/choose_recipe select atomic + +# Or provide a recipe of your own... +# If you have a way to get a recipe file into the d-i environment, you can +# just point at it. +#d-i partman-auto/expert_recipe_file string /hd-media/recipe + +# If not, you can put an entire recipe into the preconfiguration file in one +# (logical) line. This example creates a small /boot partition, suitable +# swap, and uses the rest of the space for the root partition: +#d-i partman-auto/expert_recipe string \ +# boot-root :: \ +# 40 50 100 ext3 \ +# $primary{ } $bootable{ } \ +# method{ format } format{ } \ +# use_filesystem{ } filesystem{ ext3 } \ +# mountpoint{ /boot } \ +# . \ +# 500 10000 1000000000 ext3 \ +# method{ format } format{ } \ +# use_filesystem{ } filesystem{ ext3 } \ +# mountpoint{ / } \ +# . \ +# 64 512 300% linux-swap \ +# method{ swap } format{ } \ +# . + +d-i partman-basicfilesystems/no_swap boolean false +d-i partman-auto/expert_recipe string + boot-root :: \ + 10240 1 -1 ext4 \ + $primary{ } $bootable{ } \ + method{ format } format{ } \ + use_filesystem{ } filesystem{ ext4 } \ + label{ root } mountpoint{ / } \ + +# The full recipe format is documented in the file partman-auto-recipe.txt +# included in the 'debian-installer' package or available from D-I source +# repository. This also documents how to specify settings such as file +# system labels, volume group names and which physical devices to include +# in a volume group. + +# This makes partman automatically partition without confirmation, provided +# that you told it what to do using one of the methods above. +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 + +## Partitioning using RAID +# The method should be set to "raid". +#d-i partman-auto/method string raid +# Specify the disks to be partitioned. They will all get the same layout, +# so this will only work if the disks are the same size. +#d-i partman-auto/disk string /dev/sda /dev/sdb + +# Next you need to specify the physical partitions that will be used. +#d-i partman-auto/expert_recipe string \ +# multiraid :: \ +# 1000 5000 4000 raid \ +# $primary{ } method{ raid } \ +# . \ +# 64 512 300% raid \ +# method{ raid } \ +# . \ +# 500 10000 1000000000 raid \ +# method{ raid } \ +# . + +# Last you need to specify how the previously defined partitions will be +# used in the RAID setup. Remember to use the correct partition numbers +# for logical partitions. RAID levels 0, 1, 5, 6 and 10 are supported; +# devices are separated using "#". +# Parameters are: +# \ +# + +#d-i partman-auto-raid/recipe string \ +# 1 2 0 ext3 / \ +# /dev/sda1#/dev/sdb1 \ +# . \ +# 1 2 0 swap - \ +# /dev/sda5#/dev/sdb5 \ +# . \ +# 0 2 0 ext3 /home \ +# /dev/sda6#/dev/sdb6 \ +# . + +# For additional information see the file partman-auto-raid-recipe.txt +# included in the 'debian-installer' package or available from D-I source +# repository. + +# This makes partman automatically partition without confirmation. +d-i partman-md/confirm boolean true +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 + +## Controlling how partitions are mounted +# The default is to mount by UUID, but you can also choose "traditional" to +# use traditional device names, or "label" to try filesystem labels before +# falling back to UUIDs. +#d-i partman/mount_style select uuid + +### Base system installation +# Configure APT to not install recommended packages by default. Use of this +# option can result in an incomplete system and should only be used by very +# experienced users. +#d-i base-installer/install-recommends boolean false + +# The kernel image (meta) package to be installed; "none" can be used if no +# kernel is to be installed. +#d-i base-installer/kernel/image string linux-image-586 + +### Apt setup +# You can choose to install non-free and contrib software. +#d-i apt-setup/non-free boolean true +#d-i apt-setup/contrib boolean true +# Uncomment this if you don't want to use a network mirror. +#d-i apt-setup/use_mirror boolean false +# Select which update services to use; define the mirrors to be used. +# Values shown below are the normal defaults. +#d-i apt-setup/services-select multiselect security, updates +#d-i apt-setup/security_host string security.debian.org + +# Additional repositories, local[0-9] available +#d-i apt-setup/local0/repository string \ +# http://local.server/debian stable main +#d-i apt-setup/local0/comment string local server +# Enable deb-src lines +#d-i apt-setup/local0/source boolean true +# URL to the public key of the local repository; you must provide a key or +# apt will complain about the unauthenticated repository and so the +# sources.list line will be left commented out +#d-i apt-setup/local0/key string http://local.server/key + +# By default the installer requires that repositories be authenticated +# using a known gpg key. This setting can be used to disable that +# authentication. Warning: Insecure, not recommended. +#d-i debian-installer/allow_unauthenticated boolean true + +# Uncomment this to add multiarch configuration for i386 +#d-i apt-setup/multiarch string i386 + + +### Package selection +tasksel tasksel/first multiselect none + +# Individual additional packages to install +d-i pkgsel/include string openssh-server sudo +# Whether to upgrade packages after debootstrap. +# Allowed values: none, safe-upgrade, full-upgrade +d-i pkgsel/upgrade select full-upgrade +d-i pkgsel/update-policy select unattended-upgrades + +# Some versions of the installer can report back on what software you have +# installed, and what software you use. The default is not to report back, +# but sending reports helps the project determine what software is most +# popular and include it on CDs. +popularity-contest popularity-contest/participate boolean false + +### Boot loader installation +# Grub is the default boot loader (for x86). If you want lilo installed +# instead, uncomment this: +#d-i grub-installer/skip boolean true +# To also skip installing lilo, and install no bootloader, uncomment this +# too: +#d-i lilo-installer/skip boolean true + + +# This is fairly safe to set, it makes grub install automatically to the MBR +# if no other operating system is detected on the machine. +d-i grub-installer/only_debian boolean true + +# This one makes grub-installer install to the MBR if it also finds some other +# OS, which is less safe as it might not be able to boot that other OS. +d-i grub-installer/with_other_os boolean true + +# Due notably to potential USB sticks, the location of the MBR can not be +# determined safely in general, so this needs to be specified: +#d-i grub-installer/bootdev string /dev/sda +# To install to the first device (assuming it is not a USB stick): +d-i grub-installer/bootdev string default + +# Alternatively, if you want to install to a location other than the mbr, +# uncomment and edit these lines: +#d-i grub-installer/only_debian boolean false +#d-i grub-installer/with_other_os boolean false +#d-i grub-installer/bootdev string (hd0,1) +# To install grub to multiple disks: +#d-i grub-installer/bootdev string (hd0,1) (hd1,1) (hd2,1) + +# Optional password for grub, either in clear text +#d-i grub-installer/password password r00tme +#d-i grub-installer/password-again password r00tme +# or encrypted using an MD5 hash, see grub-md5-crypt(8). +#d-i grub-installer/password-crypted password [MD5 hash] + +# Use the following option to add additional boot parameters for the +# installed system (if supported by the bootloader installer). +# Note: options passed to the installer will be added automatically. +d-i debian-installer/add-kernel-opts string net.ifnames=0 + +### Finishing up the installation +# During installations from serial console, the regular virtual consoles +# (VT1-VT6) are normally disabled in /etc/inittab. Uncomment the next +# line to prevent this. +#d-i finish-install/keep-consoles boolean true + +# Avoid that last message about the install being complete. +d-i finish-install/reboot_in_progress note + +# This will prevent the installer from ejecting the CD during the reboot, +# which is useful in some situations. +#d-i cdrom-detect/eject boolean false + +# This is how to make the installer shutdown when finished, but not +# reboot into the installed system. +#d-i debian-installer/exit/halt boolean true +# This will power off the machine instead of just halting it. +#d-i debian-installer/exit/poweroff boolean true + +### Preseeding other packages +# Depending on what software you choose to install, or if things go wrong +# during the installation process, it's possible that other questions may +# be asked. You can preseed those too, of course. To get a list of every +# possible question that could be asked during an install, do an +# installation, and then run these commands: +# debconf-get-selections --installer > file +# debconf-get-selections >> file + + +#### Advanced options +### Running custom commands during the installation +# d-i preseeding is inherently not secure. Nothing in the installer checks +# for attempts at buffer overflows or other exploits of the values of a +# preconfiguration file like this one. Only use preconfiguration files from +# trusted locations! To drive that home, and because it's generally useful, +# here's a way to run any shell command you'd like inside the installer, +# automatically. + +# This first command is run as early as possible, just after +# preseeding is read. +#d-i preseed/early_command string anna-install some-udeb +# This command is run immediately before the partitioner starts. It may be +# useful to apply dynamic partitioner preseeding that depends on the state +# of the disks (which may not be visible when preseed/early_command runs). +#d-i partman/early_command \ +# string debconf-set partman-auto/disk "$(list-devices disk | head -n1)" +# This command is run just before the install finishes, but when there is +# still a usable /target directory. You can chroot to /target and use it +# directly, or use the apt-install and in-target commands to easily install +# packages and run commands in the target system. +#d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh + diff --git a/utils/packer/http/ubuntu-16.04/preseed.cfg b/utils/packer/http/ubuntu-16.04/preseed.cfg new file mode 100644 index 0000000..f4faefe --- /dev/null +++ b/utils/packer/http/ubuntu-16.04/preseed.cfg @@ -0,0 +1,493 @@ +#### Contents of the preconfiguration file (for xenial) +### Localization +# Preseeding only locale sets language, country and locale. +d-i debian-installer/locale string en_US + +# The values can also be preseeded individually for greater flexibility. +d-i debian-installer/language string en +d-i debian-installer/country string US +#d-i debian-installer/locale string en_GB.UTF-8 +# Optionally specify additional locales to be generated. +#d-i localechooser/supported-locales multiselect en_US.UTF-8, nl_NL.UTF-8 + +# Keyboard selection. +# Disable automatic (interactive) keymap detection. +d-i console-setup/ask_detect boolean false +d-i keyboard-configuration/xkb-keymap select us +# To select a variant of the selected layout: +#d-i keyboard-configuration/xkb-keymap select us(dvorak) +# d-i keyboard-configuration/toggle select No toggling +d-i keyboard-configuration/layoutcode string us + +### Network configuration +# Disable network configuration entirely. This is useful for cdrom +# installations on non-networked devices where the network questions, +# warning and long timeouts are a nuisance. +#d-i netcfg/enable boolean false + +# netcfg will choose an interface that has link if possible. This makes it +# skip displaying a list if there is more than one interface. +d-i netcfg/choose_interface select auto + +# To pick a particular interface instead: +#d-i netcfg/choose_interface select eth1 + +# To set a different link detection timeout (default is 3 seconds). +# Values are interpreted as seconds. +#d-i netcfg/link_wait_timeout string 10 + +# If you have a slow dhcp server and the installer times out waiting for +# it, this might be useful. +#d-i netcfg/dhcp_timeout string 60 +#d-i netcfg/dhcpv6_timeout string 60 + +# If you prefer to configure the network manually, uncomment this line and +# the static network configuration below. +#d-i netcfg/disable_autoconfig boolean true + +# If you want the preconfiguration file to work on systems both with and +# without a dhcp server, uncomment these lines and the static network +# configuration below. +#d-i netcfg/dhcp_failed note +#d-i netcfg/dhcp_options select Configure network manually + +# Static network configuration. +# +# IPv4 example +#d-i netcfg/get_ipaddress string 192.168.1.42 +#d-i netcfg/get_netmask string 255.255.255.0 +#d-i netcfg/get_gateway string 192.168.1.1 +#d-i netcfg/get_nameservers string 192.168.1.1 +#d-i netcfg/confirm_static boolean true +# +# IPv6 example +#d-i netcfg/get_ipaddress string fc00::2 +#d-i netcfg/get_netmask string ffff:ffff:ffff:ffff:: +#d-i netcfg/get_gateway string fc00::1 +#d-i netcfg/get_nameservers string fc00::1 +#d-i netcfg/confirm_static boolean true + +# Any hostname and domain names assigned from dhcp take precedence over +# values set here. However, setting the values still prevents the questions +# from being shown, even if values come from dhcp. +d-i netcfg/get_hostname string unassigned-hostname +d-i netcfg/get_domain string unassigned-domain + +# If you want to force a hostname, regardless of what either the DHCP +# server returns or what the reverse DNS entry for the IP is, uncomment +# and adjust the following line. +#d-i netcfg/hostname string somehost + +# Disable that annoying WEP key dialog. +d-i netcfg/wireless_wep string +# The wacky dhcp hostname that some ISPs use as a password of sorts. +#d-i netcfg/dhcp_hostname string radish + +# If non-free firmware is needed for the network or other hardware, you can +# configure the installer to always try to load it, without prompting. Or +# change to false to disable asking. +#d-i hw-detect/load_firmware boolean true + +### Network console +# Use the following settings if you wish to make use of the network-console +# component for remote installation over SSH. This only makes sense if you +# intend to perform the remainder of the installation manually. +#d-i anna/choose_modules string network-console +#d-i network-console/authorized_keys_url string http://10.0.0.1/openssh-key +#d-i network-console/password password r00tme +#d-i network-console/password-again password r00tme +# Use this instead if you prefer to use key-based authentication +#d-i network-console/authorized_keys_url http://host/authorized_keys + +### Mirror settings +# If you select ftp, the mirror/country string does not need to be set. +#d-i mirror/protocol string ftp +d-i mirror/country string manual +d-i mirror/http/hostname string archive.ubuntu.com +d-i mirror/http/directory string /ubuntu +d-i mirror/http/proxy string + +# Alternatively: by default, the installer uses CC.archive.ubuntu.com where +# CC is the ISO-3166-2 code for the selected country. You can preseed this +# so that it does so without asking. +#d-i mirror/http/mirror select CC.archive.ubuntu.com + +# Suite to install. +#d-i mirror/suite string xenial +# Suite to use for loading installer components (optional). +#d-i mirror/udeb/suite string xenial +# Components to use for loading installer components (optional). +#d-i mirror/udeb/components multiselect main, restricted + +### Account setup +# Skip creation of a root account (normal user account will be able to +# use sudo). The default is false; preseed this to true if you want to set +# a root password. +#d-i passwd/root-login boolean false +# Alternatively, to skip creation of a normal user account. +#d-i passwd/make-user boolean false + +# Root password, either in clear text +#d-i passwd/root-password password r00tme +#d-i passwd/root-password-again password r00tme +# or encrypted using a crypt(3) hash. +#d-i passwd/root-password-crypted password [crypt(3) hash] + +# To create a normal user account. +d-i passwd/user-fullname string vagrant +d-i passwd/username string vagrant +# Normal user's password, either in clear text +d-i passwd/user-password password vagrant +d-i passwd/user-password-again password vagrant +# or encrypted using a crypt(3) hash. +#d-i passwd/user-password-crypted password [crypt(3) hash] +# Create the first user with the specified UID instead of the default. +#d-i passwd/user-uid string 1010 +# The installer will warn about weak passwords. If you are sure you know +# what you're doing and want to override it, uncomment this. +d-i user-setup/allow-password-weak boolean true + +# The user account will be added to some standard initial groups. To +# override that, use this. +#d-i passwd/user-default-groups string audio cdrom video + +# Set to true if you want to encrypt the first user's home directory. +d-i user-setup/encrypt-home boolean false + +### Clock and time zone setup +# Controls whether or not the hardware clock is set to UTC. +d-i clock-setup/utc boolean true + +# You may set this to any valid setting for $TZ; see the contents of +# /usr/share/zoneinfo/ for valid values. +d-i time/zone string UTC + +# Controls whether to use NTP to set the clock during the install +d-i clock-setup/ntp boolean true +# NTP server to use. The default is almost always fine here. +#d-i clock-setup/ntp-server string ntp.example.com + +### Partitioning +## Partitioning example +# If the system has free space you can choose to only partition that space. +# This is only honoured if partman-auto/method (below) is not set. +# Alternatives: custom, some_device, some_device_crypto, some_device_lvm. +#d-i partman-auto/init_automatically_partition select biggest_free + +# Alternatively, you may specify a disk to partition. If the system has only +# one disk the installer will default to using that, but otherwise the device +# name must be given in traditional, non-devfs format (so e.g. /dev/sda +# and not e.g. /dev/discs/disc0/disc). +# For example, to use the first SCSI/SATA hard disk: +#d-i partman-auto/disk string /dev/sda +# In addition, you'll need to specify the method to use. +# The presently available methods are: +# - regular: use the usual partition types for your architecture +# - lvm: use LVM to partition the disk +# - crypto: use LVM within an encrypted partition +d-i partman-auto/method string regular + +# If one of the disks that are going to be automatically partitioned +# contains an old LVM configuration, the user will normally receive a +# warning. This can be preseeded away... +d-i partman-lvm/device_remove_lvm boolean true +# The same applies to pre-existing software RAID array: +d-i partman-md/device_remove_md boolean true +# And the same goes for the confirmation to write the lvm partitions. +d-i partman-lvm/confirm boolean true +d-i partman-lvm/confirm_nooverwrite boolean true + +# For LVM partitioning, you can select how much of the volume group to use +# for logical volumes. +#d-i partman-auto-lvm/guided_size string max +#d-i partman-auto-lvm/guided_size string 10GB +#d-i partman-auto-lvm/guided_size string 50% + +# You can choose one of the three predefined partitioning recipes: +# - atomic: all files in one partition +# - home: separate /home partition +# - multi: separate /home, /var, and /tmp partitions +d-i partman-auto/choose_recipe select atomic + +# Or provide a recipe of your own... +# If you have a way to get a recipe file into the d-i environment, you can +# just point at it. +#d-i partman-auto/expert_recipe_file string /hd-media/recipe + +# If not, you can put an entire recipe into the preconfiguration file in one +# (logical) line. This example creates a small /boot partition, suitable +# swap, and uses the rest of the space for the root partition: +#d-i partman-auto/expert_recipe string \ +# boot-root :: \ +# 40 50 100 ext3 \ +# $primary{ } $bootable{ } \ +# method{ format } format{ } \ +# use_filesystem{ } filesystem{ ext3 } \ +# mountpoint{ /boot } \ +# . \ +# 500 10000 1000000000 ext3 \ +# method{ format } format{ } \ +# use_filesystem{ } filesystem{ ext3 } \ +# mountpoint{ / } \ +# . \ +# 64 512 300% linux-swap \ +# method{ swap } format{ } \ +# . + +d-i partman-basicfilesystems/no_swap boolean false +d-i partman-auto/expert_recipe string + boot-root :: \ + 10240 1 -1 ext4 \ + $primary{ } $bootable{ } \ + method{ format } format{ } \ + use_filesystem{ } filesystem{ ext4 } \ + label{ root } mountpoint{ / } \ + +# If you just want to change the default filesystem from ext3 to something +# else, you can do that without providing a full recipe. +#d-i partman/default_filesystem string ext4 + +# The full recipe format is documented in the file partman-auto-recipe.txt +# included in the 'debian-installer' package or available from D-I source +# repository. This also documents how to specify settings such as file +# system labels, volume group names and which physical devices to include +# in a volume group. + +# This makes partman automatically partition without confirmation, provided +# that you told it what to do using one of the methods above. +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 + +## Partitioning using RAID +# The method should be set to "raid". +#d-i partman-auto/method string raid +# Specify the disks to be partitioned. They will all get the same layout, +# so this will only work if the disks are the same size. +#d-i partman-auto/disk string /dev/sda /dev/sdb + +# Next you need to specify the physical partitions that will be used. +#d-i partman-auto/expert_recipe string \ +# multiraid :: \ +# 1000 5000 4000 raid \ +# $primary{ } method{ raid } \ +# . \ +# 64 512 300% raid \ +# method{ raid } \ +# . \ +# 500 10000 1000000000 raid \ +# method{ raid } \ +# . + +# Last you need to specify how the previously defined partitions will be +# used in the RAID setup. Remember to use the correct partition numbers +# for logical partitions. RAID levels 0, 1, 5, 6 and 10 are supported; +# devices are separated using "#". +# Parameters are: +# \ +# + +#d-i partman-auto-raid/recipe string \ +# 1 2 0 ext3 / \ +# /dev/sda1#/dev/sdb1 \ +# . \ +# 1 2 0 swap - \ +# /dev/sda5#/dev/sdb5 \ +# . \ +# 0 2 0 ext3 /home \ +# /dev/sda6#/dev/sdb6 \ +# . + +# For additional information see the file partman-auto-raid-recipe.txt +# included in the 'debian-installer' package or available from D-I source +# repository. + +# This makes partman automatically partition without confirmation. +d-i partman-md/confirm boolean true +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 + +## Controlling how partitions are mounted +# The default is to mount by UUID, but you can also choose "traditional" to +# use traditional device names, or "label" to try filesystem labels before +# falling back to UUIDs. +#d-i partman/mount_style select uuid + +### Base system installation +# Configure a path to the preconfigured base filesystem. This can be used to +# specify a path for the installer to retrieve the filesystem image that will +# be deployed to disk and used as a base system for the installation. +#d-i live-installer/net-image string /install/filesystem.squashfs + +# Configure APT to not install recommended packages by default. Use of this +# option can result in an incomplete system and should only be used by very +# experienced users. +#d-i base-installer/install-recommends boolean false + +# The kernel image (meta) package to be installed; "none" can be used if no +# kernel is to be installed. +#d-i base-installer/kernel/image string linux-generic + +### Apt setup +# You can choose to install restricted and universe software, or to install +# software from the backports repository. +#d-i apt-setup/restricted boolean true +#d-i apt-setup/universe boolean true +#d-i apt-setup/backports boolean true +# Uncomment this if you don't want to use a network mirror. +#d-i apt-setup/use_mirror boolean false +# Select which update services to use; define the mirrors to be used. +# Values shown below are the normal defaults. +#d-i apt-setup/services-select multiselect security +#d-i apt-setup/security_host string security.ubuntu.com +#d-i apt-setup/security_path string /ubuntu + +# Additional repositories, local[0-9] available +#d-i apt-setup/local0/repository string \ +# http://local.server/ubuntu xenial main +#d-i apt-setup/local0/comment string local server +# Enable deb-src lines +#d-i apt-setup/local0/source boolean true +# URL to the public key of the local repository; you must provide a key or +# apt will complain about the unauthenticated repository and so the +# sources.list line will be left commented out +#d-i apt-setup/local0/key string http://local.server/key + +# By default the installer requires that repositories be authenticated +# using a known gpg key. This setting can be used to disable that +# authentication. Warning: Insecure, not recommended. +#d-i debian-installer/allow_unauthenticated boolean true + +# Uncomment this to add multiarch configuration for i386 +#d-i apt-setup/multiarch string i386 + + +### Package selection +#tasksel tasksel/first multiselect ubuntu-desktop +#tasksel tasksel/first multiselect lamp-server, print-server +#tasksel tasksel/first multiselect kubuntu-desktop +tasksel tasksel/first multiselect none + +# Individual additional packages to install +#d-i pkgsel/include string openssh-server build-essential +d-i pkgsel/include string openssh-server +# Whether to upgrade packages after debootstrap. +# Allowed values: none, safe-upgrade, full-upgrade +d-i pkgsel/upgrade select full-upgrade + +# Language pack selection +#d-i pkgsel/language-packs multiselect de, en, zh + +# Policy for applying updates. May be "none" (no automatic updates), +# "unattended-upgrades" (install security updates automatically), or +# "landscape" (manage system with Landscape). +d-i pkgsel/update-policy select unattended-upgrades + +# Some versions of the installer can report back on what software you have +# installed, and what software you use. The default is not to report back, +# but sending reports helps the project determine what software is most +# popular and include it on CDs. +#popularity-contest popularity-contest/participate boolean false + +# By default, the system's locate database will be updated after the +# installer has finished installing most packages. This may take a while, so +# if you don't want it, you can set this to "false" to turn it off. +#d-i pkgsel/updatedb boolean true + +### Boot loader installation +# Grub is the default boot loader (for x86). If you want lilo installed +# instead, uncomment this: +#d-i grub-installer/skip boolean true +# To also skip installing lilo, and install no bootloader, uncomment this +# too: +#d-i lilo-installer/skip boolean true + + +# This is fairly safe to set, it makes grub install automatically to the MBR +# if no other operating system is detected on the machine. +d-i grub-installer/only_debian boolean true + +# This one makes grub-installer install to the MBR if it also finds some other +# OS, which is less safe as it might not be able to boot that other OS. +d-i grub-installer/with_other_os boolean true + +# Due notably to potential USB sticks, the location of the MBR can not be +# determined safely in general, so this needs to be specified: +#d-i grub-installer/bootdev string /dev/sda +# To install to the first device (assuming it is not a USB stick): +#d-i grub-installer/bootdev string default + +# Alternatively, if you want to install to a location other than the mbr, +# uncomment and edit these lines: +#d-i grub-installer/only_debian boolean false +#d-i grub-installer/with_other_os boolean false +#d-i grub-installer/bootdev string (hd0,1) +# To install grub to multiple disks: +#d-i grub-installer/bootdev string (hd0,1) (hd1,1) (hd2,1) + +# Optional password for grub, either in clear text +#d-i grub-installer/password password r00tme +#d-i grub-installer/password-again password r00tme +# or encrypted using an MD5 hash, see grub-md5-crypt(8). +#d-i grub-installer/password-crypted password [MD5 hash] + +# Use the following option to add additional boot parameters for the +# installed system (if supported by the bootloader installer). +# Note: options passed to the installer will be added automatically. +#d-i debian-installer/add-kernel-opts string nousb +d-i debian-installer/add-kernel-opts string net.ifnames=0 + +### Finishing up the installation +# During installations from serial console, the regular virtual consoles +# (VT1-VT6) are normally disabled in /etc/inittab. Uncomment the next +# line to prevent this. +#d-i finish-install/keep-consoles boolean true + +# Avoid that last message about the install being complete. +d-i finish-install/reboot_in_progress note + +# This will prevent the installer from ejecting the CD during the reboot, +# which is useful in some situations. +#d-i cdrom-detect/eject boolean false + +# This is how to make the installer shutdown when finished, but not +# reboot into the installed system. +#d-i debian-installer/exit/halt boolean true +# This will power off the machine instead of just halting it. +#d-i debian-installer/exit/poweroff boolean true + +### Preseeding other packages +# Depending on what software you choose to install, or if things go wrong +# during the installation process, it's possible that other questions may +# be asked. You can preseed those too, of course. To get a list of every +# possible question that could be asked during an install, do an +# installation, and then run these commands: +# debconf-get-selections --installer > file +# debconf-get-selections >> file + + +#### Advanced options +### Running custom commands during the installation +# d-i preseeding is inherently not secure. Nothing in the installer checks +# for attempts at buffer overflows or other exploits of the values of a +# preconfiguration file like this one. Only use preconfiguration files from +# trusted locations! To drive that home, and because it's generally useful, +# here's a way to run any shell command you'd like inside the installer, +# automatically. + +# This first command is run as early as possible, just after +# preseeding is read. +#d-i preseed/early_command string anna-install some-udeb +# This command is run immediately before the partitioner starts. It may be +# useful to apply dynamic partitioner preseeding that depends on the state +# of the disks (which may not be visible when preseed/early_command runs). +#d-i partman/early_command \ +# string debconf-set partman-auto/disk "$(list-devices disk | head -n1)" +# This command is run just before the install finishes, but when there is +# still a usable /target directory. You can chroot to /target and use it +# directly, or use the apt-install and in-target commands to easily install +# packages and run commands in the target system. +#d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh diff --git a/utils/packer/scripts/debian/cleanup.sh b/utils/packer/scripts/debian/cleanup.sh new file mode 100644 index 0000000..bab4bd9 --- /dev/null +++ b/utils/packer/scripts/debian/cleanup.sh @@ -0,0 +1,41 @@ +#!/bin/bash -euxo + +echo "==> Installed packages before cleanup" +dpkg --get-selections | grep -v deinstall + +# Clean up the apt cache +apt-get -y autoremove --purge +#apt-get -y clean +apt-get -y autoclean + +echo "==> Cleaning up udev rules" +rm -rf /dev/.udev/ /lib/udev/rules.d/75-persistent-net-generator.rules + +echo "==> Cleaning up leftover dhcp leases" +if [ -d "/var/lib/dhcp" ]; then + rm /var/lib/dhcp/* +fi + +echo "==> Removing man pages" +rm -rf /usr/share/man/* +echo "==> Removing APT files" +find /var/lib/apt -type f | xargs rm -f +echo "==> Removing anything in /usr/src" +rm -rf /usr/src/* +echo "==> Removing any docs" +rm -rf /usr/share/doc/* +echo "==> Removing caches" +find /var/cache -type f -exec rm -rf {} \; +echo "==> Cleaning up log files" +find /var/log -type f -exec sh -c 'echo -n > {}' \; +echo "==> Cleaning up tmp" +rm -rf /tmp/* +echo "==> Clearing last login information" +> /var/log/lastlog +> /var/log/wtmp +> /var/log/btmp + +echo "==> Removing bash history" +unset HISTFILE +rm -f /root/.bash_history +rm -f /home/vagrant/.bash_history diff --git a/utils/packer/scripts/debian/console.sh b/utils/packer/scripts/debian/console.sh new file mode 100644 index 0000000..16909bf --- /dev/null +++ b/utils/packer/scripts/debian/console.sh @@ -0,0 +1,10 @@ +#!/bin/bash -eux + +echo "==> Configuring serial console" +cat >> /etc/default/grub < Installing packages" +apt-get -y --allow-unauthenticated install $PACKAGES + +# Upgrading pip +pip install --upgrade pip #Installer/CCP tools pip install git+https://git.openstack.org/openstack/fuel-ccp.git --upgrade diff --git a/utils/packer/scripts/debian/setup.sh b/utils/packer/scripts/debian/setup.sh new file mode 100644 index 0000000..b45a1bf --- /dev/null +++ b/utils/packer/scripts/debian/setup.sh @@ -0,0 +1,12 @@ +#!/bin/bash -eux + +echo "==> Setting up sudo" +sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers + +echo "==> Configuring logging" +touch /var/log/daemon.log +chmod 666 /var/log/daemon.log +echo "daemon.* /var/log/daemon.log" >> /etc/rsyslog.d/50-default.conf + +echo "==> Setting vim as a default editor" +update-alternatives --set editor /usr/bin/vim.basic diff --git a/utils/packer/scripts/debian/update.sh b/utils/packer/scripts/debian/update.sh new file mode 100644 index 0000000..57d7948 --- /dev/null +++ b/utils/packer/scripts/debian/update.sh @@ -0,0 +1,10 @@ +#!/bin/bash -eux + +if [[ $UPDATE =~ true || $UPDATE =~ 1 || $UPDATE =~ yes ]]; then + echo "==> Updating list of repositories" + # apt-get update does not actually perform updates, it just downloads and indexes the list of packages + apt-get -y update + + echo "==> Performing dist-upgrade (all packages and kernel)" + apt-get -y dist-upgrade --force-yes +fi diff --git a/utils/packer/scripts/minimize.sh b/utils/packer/scripts/minimize.sh new file mode 100644 index 0000000..1102b2a --- /dev/null +++ b/utils/packer/scripts/minimize.sh @@ -0,0 +1,9 @@ +#!/bin/bash -eux + +# Zero out the free space to save space in the final image +nice -n 19 ionice -c2 -n7 dd if=/dev/zero of=/EMPTY bs=1M +rm -f /EMPTY + +# Make sure we wait until all the data is written to disk, otherwise +# Packer might quite too early before the large files are deleted +sync diff --git a/utils/packer/scripts/sshd.sh b/utils/packer/scripts/sshd.sh new file mode 100644 index 0000000..c6e4f20 --- /dev/null +++ b/utils/packer/scripts/sshd.sh @@ -0,0 +1,3 @@ +#!/bin/bash -eux + +echo "UseDNS no" >> /etc/ssh/sshd_config diff --git a/utils/packer/scripts/vagrant.sh b/utils/packer/scripts/vagrant.sh new file mode 100644 index 0000000..871e225 --- /dev/null +++ b/utils/packer/scripts/vagrant.sh @@ -0,0 +1,71 @@ +#!/bin/bash -euxo + +date > /etc/vagrant_box_build_time + +SSH_USER=${SSH_USER:-vagrant} +SSH_USER_HOME=${SSH_USER_HOME:-/home/${SSH_USER}} +VAGRANT_INSECURE_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" + +VAGRANT_SECURE_KEY="-----BEGIN RSA PRIVATE KEY----- +MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI +w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP +kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2 +hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO +Td0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW +yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQIBIwKCAQEA4iqWPJXtzZA68mKd +ELs4jJsdyky+ewdZeNds5tjcnHU5zUYE25K+ffJED9qUWICcLZDc81TGWjHyAqD1 +Bw7XpgUwFgeUJwUlzQurAv+/ySnxiwuaGJfhFM1CaQHzfXphgVml+fZUvnJUTvzf +TK2Lg6EdbUE9TarUlBf/xPfuEhMSlIE5keb/Zz3/LUlRg8yDqz5w+QWVJ4utnKnK +iqwZN0mwpwU7YSyJhlT4YV1F3n4YjLswM5wJs2oqm0jssQu/BT0tyEXNDYBLEF4A +sClaWuSJ2kjq7KhrrYXzagqhnSei9ODYFShJu8UWVec3Ihb5ZXlzO6vdNQ1J9Xsf +4m+2ywKBgQD6qFxx/Rv9CNN96l/4rb14HKirC2o/orApiHmHDsURs5rUKDx0f9iP +cXN7S1uePXuJRK/5hsubaOCx3Owd2u9gD6Oq0CsMkE4CUSiJcYrMANtx54cGH7Rk +EjFZxK8xAv1ldELEyxrFqkbE4BKd8QOt414qjvTGyAK+OLD3M2QdCQKBgQDtx8pN +CAxR7yhHbIWT1AH66+XWN8bXq7l3RO/ukeaci98JfkbkxURZhtxV/HHuvUhnPLdX +3TwygPBYZFNo4pzVEhzWoTtnEtrFueKxyc3+LjZpuo+mBlQ6ORtfgkr9gBVphXZG +YEzkCD3lVdl8L4cw9BVpKrJCs1c5taGjDgdInQKBgHm/fVvv96bJxc9x1tffXAcj +3OVdUN0UgXNCSaf/3A/phbeBQe9xS+3mpc4r6qvx+iy69mNBeNZ0xOitIjpjBo2+ +dBEjSBwLk5q5tJqHmy/jKMJL4n9ROlx93XS+njxgibTvU6Fp9w+NOFD/HvxB3Tcz +6+jJF85D5BNAG3DBMKBjAoGBAOAxZvgsKN+JuENXsST7F89Tck2iTcQIT8g5rwWC +P9Vt74yboe2kDT531w8+egz7nAmRBKNM751U/95P9t88EDacDI/Z2OwnuFQHCPDF +llYOUI+SpLJ6/vURRbHSnnn8a/XG+nzedGH5JGqEJNQsz+xT2axM0/W/CRknmGaJ +kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH ++vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ +NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s= +-----END RSA PRIVATE KEY-----" + +# Packer passes boolean user variables through as '1', but this might change in +# the future, so also check for 'true'. +if [ "${INSTALL_VAGRANT_KEY}" = "true" ] || [ "${INSTALL_VAGRANT_KEY}" = "1" ]; then + # Create Vagrant user (if not already present) + if ! id -u ${SSH_USER} >/dev/null 2>&1; then + echo "==> Creating ${SSH_USER} user" + /usr/sbin/groupadd ${SSH_USER} + /usr/sbin/useradd ${SSH_USER} -g ${SSH_USER} -G sudo -d ${SSH_USER_HOME} --create-home + echo "${SSH_USER}:${SSH_USER}" | chpasswd + fi + + # Set up sudo + echo "==> Giving ${SSH_USER} sudo powers" + echo "${SSH_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant + + echo "==> Installing vagrant keys" + mkdir ${SSH_USER_HOME}/.ssh + chmod 700 ${SSH_USER_HOME}/.ssh + + pushd ${SSH_USER_HOME}/.ssh + + # https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub + echo "${VAGRANT_INSECURE_KEY}" > ${SSH_USER_HOME}/.ssh/authorized_keys + chmod 600 ${SSH_USER_HOME}/.ssh/authorized_keys + + echo "${VAGRANT_SECURE_KEY}" > ${SSH_USER_HOME}/.ssh/id_rsa + chmod 600 ${SSH_USER_HOME}/.ssh/id_rsa + chown -R ${SSH_USER}:${SSH_USER} ${SSH_USER_HOME}/.ssh + popd + + # add default user to necessary groups: + # workaround for Docker not being installed yet: + groupadd -f docker + usermod -aG docker vagrant +fi diff --git a/utils/packer/scripts/vmtool.sh b/utils/packer/scripts/vmtool.sh new file mode 100644 index 0000000..8f64f4c --- /dev/null +++ b/utils/packer/scripts/vmtool.sh @@ -0,0 +1,47 @@ +#!/bin/bash -eux + +if [[ $PACKER_BUILDER_TYPE =~ vmware ]]; then + echo "==> Installing VMware Tools" + # Assuming the following packages are installed + # apt-get install -y linux-headers-$(uname -r) build-essential perl + + cd /tmp + mkdir -p /mnt/cdrom + mount -o loop /home/vagrant/linux.iso /mnt/cdrom + tar zxf /mnt/cdrom/VMwareTools-*.tar.gz -C /tmp/ + + /tmp/vmware-tools-distrib/vmware-install.pl -d + + rm /home/vagrant/linux.iso + umount /mnt/cdrom + rmdir /mnt/cdrom + rm -rf /tmp/VMwareTools-* +fi + +if [[ $PACKER_BUILDER_TYPE =~ virtualbox ]]; then + echo "==> Installing VirtualBox guest additions" + # Assuming the following packages are installed + # apt-get install -y linux-headers-$(uname -r) build-essential perl + # apt-get install -y dkms + + VBOX_VERSION=$(cat /home/vagrant/.vbox_version) + mount -o loop /home/vagrant/VBoxGuestAdditions_$VBOX_VERSION.iso /mnt + sh /mnt/VBoxLinuxAdditions.run + umount /mnt + rm /home/vagrant/VBoxGuestAdditions_$VBOX_VERSION.iso + rm /home/vagrant/.vbox_version + + if [[ $VBOX_VERSION = "4.3.10" ]]; then + ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions + fi +fi + +if [[ $PACKER_BUILDER_TYPE =~ parallels ]]; then + echo "==> Installing Parallels tools" + + mount -o loop /home/vagrant/prl-tools-lin.iso /mnt + /mnt/install --install-unattended-with-deps + umount /mnt + rm -rf /home/vagrant/prl-tools-lin.iso + rm -f /home/vagrant/.prlctl_version +fi diff --git a/utils/packer/ubuntu.json b/utils/packer/ubuntu.json new file mode 100644 index 0000000..15bd718 --- /dev/null +++ b/utils/packer/ubuntu.json @@ -0,0 +1,168 @@ +{ + "_comment": "Build with `PACKER_LOG=1 UBUNTU_MAJOR_VERSION=16.04 UBUNTU_MINOR_VERSION=.1 UBUNTU_TYPE=server ARCH=amd64 HEADLESS=true packer build ubuntu.json`", + + "variables": { + "name": "ubuntu-{{ env `UBUNTU_MAJOR_VERSION` }}{{ env `UBUNTU_MINOR_VERSION` }}-{{ env `UBUNTU_TYPE` }}-{{ env `ARCH` }}", + "iso_name": "ubuntu-{{ env `UBUNTU_MAJOR_VERSION` }}{{ env `UBUNTU_MINOR_VERSION` }}-{{ env `UBUNTU_TYPE` }}-{{ env `ARCH` }}", + "ubuntu_type": "{{ env `UBUNTU_TYPE` }}", + "ubuntu_version": "{{ env `UBUNTU_MAJOR_VERSION` }}", + "ubuntu_mirror": "http://releases.ubuntu.com/", + "ssh_username": "vagrant", + "ssh_password": "vagrant", + "ssh_wait_timeout": "30m", + "preseed_file_name": "ubuntu-{{ env `UBUNTU_MAJOR_VERSION` }}/preseed.cfg", + "accelerator": "kvm", + "cpus": "1", + "memory": "1024", + "disk_size": "10240", + "headless": "{{ env `HEADLESS` }}", + "boot_wait": "10s", + "install_vagrant_key": "true", + "update": "true" + }, + + "builders": + [ + { + "type": "qemu", + "vm_name": "qemu-{{ user `name` }}", + "iso_checksum_type": "sha256", + "iso_checksum_url": "{{ user `ubuntu_mirror` }}{{ user `ubuntu_version` }}/SHA256SUMS", + "iso_url": "{{ user `ubuntu_mirror` }}{{ user `ubuntu_version` }}/{{ user `iso_name` }}.iso", + "shutdown_command": "echo '{{ user `ssh_password` }}' | sudo -S shutdown -P now", + "disk_size": "{{ user `disk_size` }}", + "headless": "{{ user `headless` }}", + "http_directory": "http", + "ssh_username": "{{ user `ssh_username` }}", + "ssh_password": "{{ user `ssh_password` }}", + "ssh_wait_timeout": "{{ user `ssh_wait_timeout` }}", + + "accelerator": "{{ user `accelerator` }}", + "qemuargs": [ + [ "-smp", "{{ user `cpus` }}" ], + [ "-m", "{{ user `memory` }}M" ] + ], + + "boot_wait": "{{ user `boot_wait` }}", + "boot_command": + [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "/install/vmlinuz ", + "initrd=/install/initrd.gz ", + "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{ user `preseed_file_name` }} ", + "auto=true ", + "net.ifnames=0 ", + "hostname=localhost ", + "" + ] + }, + { + "type": "virtualbox-iso", + "vm_name": "virtualbox-{{ user `name` }}", + "iso_checksum_type": "sha256", + "iso_checksum_url": "{{ user `ubuntu_mirror` }}{{ user `ubuntu_version` }}/SHA256SUMS", + "iso_url": "{{ user `ubuntu_mirror` }}{{ user `ubuntu_version` }}/{{ user `iso_name` }}.iso", + "shutdown_command": "echo '{{ user `ssh_password` }}' | sudo -S shutdown -P now", + "disk_size": "{{ user `disk_size` }}", + "headless": "{{ user `headless` }}", + "http_directory": "http", + "ssh_username": "{{ user `ssh_username` }}", + "ssh_password": "{{ user `ssh_password` }}", + "ssh_wait_timeout": "{{ user `ssh_wait_timeout` }}", + + "guest_os_type": "Ubuntu_64", + "guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso", + "virtualbox_version_file": ".vbox_version", + + "vboxmanage": [ + [ "modifyvm", "{{.Name}}", "--cpus", "{{ user `cpus` }}" ], + [ "modifyvm", "{{.Name}}", "--memory", "{{ user `memory` }}" ] + ], + + "boot_wait": "{{ user `boot_wait` }}", + "boot_command": + [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "/install/vmlinuz ", + "initrd=/install/initrd.gz ", + "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{ user `preseed_file_name` }} ", + "auto=true ", + "net.ifnames=0 ", + "hostname=localhost ", + "" + ] + } + ], + + "provisioners": [ + { + "type": "shell", + "environment_vars": [ + "INSTALL_VAGRANT_KEY={{ user `install_vagrant_key` }}", + "UPDATE={{ user `update` }}", + "DEBIAN_FRONTEND=noninteractive" + ], + "execute_command": "echo '{{ user `ssh_password` }}' | {{.Vars}} sudo -S -E bash -x '{{.Path}}'", + "scripts": [ + "scripts/debian/update.sh", + "scripts/debian/packages.sh", + "scripts/debian/console.sh", + "scripts/debian/setup.sh", + "scripts/vagrant.sh", + "scripts/sshd.sh", + "scripts/vmtool.sh" + ] + }, + { + "type": "shell", + "execute_command": "echo '{{ user `ssh_password` }}' | {{.Vars}} sudo -S -E bash -x '{{.Path}}'", + "scripts": [ + "scripts/debian/cleanup.sh", + "scripts/minimize.sh" + ] + } + ], + + "post-processors": [ + { + "type": "shell-local", + "only": [ "qemu" ], + "inline": [ + "qemu-img convert -c -f qcow2 -O qcow2 -o cluster_size=2M ./output-qemu/qemu-{{user `name`}} {{user `name`}}.qcow2" + ] + }, + { + "type": "vagrant", + "only": [ "qemu" ], + "compression_level": 9, + "vagrantfile_template": "Vagrantfile-qemu.template", + "output": "{{ user `name` }}-{{.Provider}}.box" + }, + { + "type": "vagrant", + "only": [ "virtualbox-iso" ], + "compression_level": 9, + "output": "{{ user `name` }}-{{.Provider}}.box" + } + ] +} diff --git a/utils/packer/ubuntu16.04/http/preseed.cfg b/utils/packer/ubuntu16.04/http/preseed.cfg deleted file mode 100644 index 8a05bb1..0000000 --- a/utils/packer/ubuntu16.04/http/preseed.cfg +++ /dev/null @@ -1,31 +0,0 @@ -choose-mirror-bin mirror/http/proxy string -d-i debian-installer/framebuffer boolean false -d-i debconf/frontend select noninteractive -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 netcfg/get_domain string unassigned-domain -d-i netcfg/get_hostname string unassigned-hostname -d-i partman-auto/method string regular -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 pkgsel/include string openssh-server -d-i pkgsel/install-language-support boolean false -d-i pkgsel/update-policy select none -d-i pkgsel/upgrade select none -d-i time/zone string CET - -# User Setup -d-i passwd/user-fullname string vagrant -d-i passwd/username string vagrant -d-i passwd/user-password password vagrant -d-i passwd/user-password-again password vagrant -d-i user-setup/allow-password-weak boolean true -d-i user-setup/encrypt-home boolean false - -tasksel tasksel/first multiselect standard, ubuntu-server diff --git a/utils/packer/ubuntu16.04/scripts/cleanup.sh b/utils/packer/ubuntu16.04/scripts/cleanup.sh deleted file mode 100644 index 91081e9..0000000 --- a/utils/packer/ubuntu16.04/scripts/cleanup.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -eux - -# see https://github.com/geerlingguy/packer-ubuntu-1604/issues/1 -echo 'GRUB_CMDLINE_LINUX="biosdevname=0 net.ifnames=0"' >> /etc/default/grub -grub-mkconfig -o /boot/grub/grub.cfg - -sed '/ens/d' -i /etc/network/interfaces - -echo 'auto eth0' >> /etc/network/interfaces -echo 'iface eth0 inet dhcp' >> /etc/network/interfaces - -apt-get -y autoremove --purge -find /var/cache -type f -exec rm -rf {} \; -find /var/lib/apt -type f | xargs rm -f - -rm -rf /dev/.udev/ -rm -f /lib/udev/rules.d/75-persistent-net-generator.rules -rm -f /etc/udev/rules.d/70-persistent-net.rules -mkdir -p /etc/udev/rules.d/70-persistent-net.rules - -if [ -d "/var/lib/dhcp" ]; then - rm -f /var/lib/dhcp/* -fi - -rm -rf /tmp/* - -unset HISTFILE -rm -f /root/.bash_history -rm -f /home/vagrant/.bash_history - -find /var/log -type f | while read f; do echo -ne '' > $f; done; - ->/var/log/lastlog ->/var/log/wtmp ->/var/log/btmp - -sync diff --git a/utils/packer/ubuntu16.04/scripts/packages.sh b/utils/packer/ubuntu16.04/scripts/packages.sh deleted file mode 100644 index 33b3860..0000000 --- a/utils/packer/ubuntu16.04/scripts/packages.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -eux -apt-get -y update -apt-get -y dist-upgrade - -PACKAGES=" -curl -ethtool -htop -isc-dhcp-client -nfs-common -vim -python-pip -git-review -python-tox -screen -tmux -python-dev -gcc -libssl-dev -libffi-dev -software-properties-common -ansible -" -#PACKAGES="${PACKAGES} docker-engine" -apt-get -y install $PACKAGES - -#Installer/CCP tools -pip install git+https://git.openstack.org/openstack/fuel-ccp.git --upgrade diff --git a/utils/packer/ubuntu16.04/scripts/setup.sh b/utils/packer/ubuntu16.04/scripts/setup.sh deleted file mode 100644 index 378525b..0000000 --- a/utils/packer/ubuntu16.04/scripts/setup.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh - -# configure serial console: -cat >> /etc/default/grub < /etc/sudoers.d/vagrant -sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers - -# Setup key-based authentication between VMs: -mkdir /home/vagrant/.ssh -cat > /home/vagrant/.ssh/id_rsa_vagrant.pub <> /home/vagrant/.ssh/authorized_keys -cat > /home/vagrant/.ssh/id_rsa_vagrant <> /etc/rsyslog.d/50-default.conf - -# add default user to necessary groups: -# workaround for Docker not being installed yet: -groupadd -f docker -usermod -aG docker vagrant - -# Set vim as a default editor -update-alternatives --set editor /usr/bin/vim.basic diff --git a/utils/packer/ubuntu16.04/ubuntu-16.04-server-amd64.json b/utils/packer/ubuntu16.04/ubuntu-16.04-server-amd64.json deleted file mode 100644 index a566311..0000000 --- a/utils/packer/ubuntu16.04/ubuntu-16.04-server-amd64.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "variables": { - "name": "ubuntu-1604-server", - "user": "vagrant", - "password": "vagrant", - "disk_size": "100000" - }, - - "builders": - [ - { - "name": "{{user `name`}}", - - "iso_url": "http://releases.ubuntu.com/16.04/ubuntu-16.04-server-amd64.iso", - "iso_checksum": "23e97cd5d4145d4105fbf29878534049", - "iso_checksum_type": "md5", - - "type": "qemu", - "accelerator": "kvm", - "disk_size": "{{ user `disk_size`}}", - "disk_cache": "unsafe", - "disk_discard": "unmap", - "format": "qcow2", - "headless": true, - - "http_directory": "http", - - "ssh_username": "{{user `user`}}", - "ssh_password": "{{user `password`}}", - "ssh_wait_timeout": "10m", - "shutdown_command": "echo '{{user `password`}}'|sudo -S shutdown -P now", - - "boot_wait": "10s", - "boot_command": [ - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "initrd=/install/initrd.gz ", - "auto=true ", - "url=http://{{.HTTPIP}}:{{.HTTPPort}}/preseed.cfg ", - "language=en ", - "country=CA ", - "locale=en_CA.UTF-8 ", - "hostname=ubuntu1604 ", - "domain=ubuntu1604 ", - "console-setup/ask_detect=false ", - "keyboard-configuration/layoutcode=us ", - "vga=788 noprompt quiet --" - ] - } - ], - - "provisioners": [ - { - "type": "shell", - "execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S bash '{{.Path}}'", - "scripts": [ - "scripts/packages.sh", - "scripts/setup.sh", - "scripts/cleanup.sh" - ] - } - ], - - "post-processors": [ - { - "type": "shell-local", - "inline": ["qemu-img convert -c -f qcow2 -O qcow2 -o cluster_size=2M ./output-{{user `name`}}/packer-{{user `name`}} ./output-{{user `name`}}/packer-{{user `name`}}.qcow2"] - } - ] -}