Commit 03c48629 authored by Rafael Monnerat's avatar Rafael Monnerat

packer: Initial Configuration

  Include Debian 7 and 8
  Include ansible playbook to automate the build
  Include Ubuntu 15.04 and Ubuntu 14.04
  Include configuration for CentOS 6.7 and 7.2
parent a660fbca
......@@ -15,3 +15,6 @@ slapprepare/slapprepare.egg-info
build/
dist
playbook/install
packer/log
packer/output-*
packer/packer_cache
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
tasks:
- file: path=log state=directory mode=0755
- shell: PATH=$PATH:/opt/packer/ packer build debian7.json >> log/debian7.log
args:
creates: output-debian7
- shell: PATH=$PATH:/opt/packer/ packer build debian8.json >> log/debian8.log
args:
creates: output-debian8
- shell: PATH=$PATH:/opt/packer/ packer build ubuntu-14.04-server-amd64.json >> log/ubuntu-14.04-server-amd64.log
args:
creates: output-ubuntu-14-04-server
- shell: PATH=$PATH:/opt/packer/ packer build ubuntu-15.04-server-amd64.json >> log/ubuntu-15.04-server-amd64.log
args:
creates: output-ubuntu-15-04-server
- shell: PATH=$PATH:/opt/packer/ packer build centos-6.7.json >> log/centos-6.7.log
args:
creates: output-centos67
- shell: PATH=$PATH:/opt/packer/ packer build centos-7.2.json >> log/centos-7.2.log
args:
creates: output-centos72
{
"variables": {
"user": "slapos",
"password": "slapos",
"disk_size": "100000",
"domain": ""
},
"builders":
[
{
"name": "centos67",
"type": "qemu",
"format": "qcow2",
"accelerator": "kvm",
"disk_size": "{{ user `disk_size`}}",
"iso_url": "http://mirrors.kernel.org/centos/6.7/isos/x86_64/CentOS-6.7-x86_64-minimal.iso",
"iso_checksum": "9d3fec5897be6b3fed4d3dda80b8fa7bb62c616bbfd4bdcd27295ca9b764f498",
"iso_checksum_type": "sha256",
"http_directory": "http",
"ssh_username": "{{user `user`}}",
"ssh_password": "{{user `password`}}",
"ssh_wait_timeout": "1800s",
"shutdown_command": "sudo poweroff",
"headless": false,
"boot_wait": "2s",
"boot_command": [
"<esc>",
"<wait>",
"linux ks=http://{{.HTTPIP}}:{{.HTTPPort}}/centos67-anaconda-ks.cfg",
"<enter>"
]
}
],
"provisioners": [
{
"type": "shell",
"execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"scripts": [
"scripts/update-centos.sh",
"scripts/packages-centos.sh",
"scripts/cleanup-centos.sh"
]
}
]
}
{
"variables": {
"user": "slapos",
"password": "slapos",
"disk_size": "100000",
"domain": ""
},
"builders":
[
{
"name": "centos72",
"type": "qemu",
"format": "qcow2",
"accelerator": "kvm",
"disk_size": "{{ user `disk_size`}}",
"iso_url": "http://mirrors.kernel.org/centos/7.2.1511/isos/x86_64/CentOS-7-x86_64-NetInstall-1511.iso",
"iso_checksum": "9ed9ffb5d89ab8cca834afce354daa70a21dcb410f58287d6316259ff89758f5",
"iso_checksum_type": "sha256",
"http_directory": "http",
"ssh_username": "{{user `user`}}",
"ssh_password": "{{user `password`}}",
"ssh_wait_timeout": "1800s",
"shutdown_command": "sudo poweroff",
"headless": false,
"boot_wait": "2s",
"boot_command": [
"<esc>",
"<wait>",
"linux ks=http://{{.HTTPIP}}:{{.HTTPPort}}/centos72-anaconda-ks.cfg biosdevname=0 net.ifnames=0",
"<enter>"
]
}
],
"provisioners": [
{
"type": "shell",
"execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"scripts": [
"scripts/update-centos.sh",
"scripts/packages-centos.sh",
"scripts/cleanup-centos.sh"
]
}
]
}
{
"variables": {
"user": "slapos",
"password": "slapos",
"disk_size": "100000",
"domain": ""
},
"builders":
[
{
"name": "debian7",
"type": "qemu",
"format": "qcow2",
"accelerator": "kvm",
"disk_size": "{{ user `disk_size`}}",
"iso_url": "http://cdimage.debian.org/mirror/cdimage/archive/7.9.0/amd64/iso-cd/debian-7.9.0-amd64-netinst.iso",
"iso_checksum": "774d1fc8c5364e63b22242c33a89c1a3",
"iso_checksum_type": "md5",
"http_directory": "http",
"ssh_username": "{{user `user`}}",
"ssh_password": "{{user `password`}}",
"ssh_wait_timeout": "1800s",
"shutdown_command": "echo '{{user `password`}}'|sudo -S shutdown -h now",
"headless": false,
"boot_wait": "2s",
"boot_command": [
"<esc><wait><wait>",
"install auto ",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed-debian7.cfg ",
"debian-installer=en_US locale=en_US keymap=us ",
"netcfg/get_hostname={{ .Name }} ",
"netcfg/get_domain={{ user `domain`}} ",
"fb=false debconf/frontend=noninteractive ",
"passwd/user-fullname={{user `user`}} ",
"passwd/user-password={{user `password`}} ",
"passwd/user-password-again={{user `password`}} ",
"passwd/username={{user `user`}} ",
"<enter>"
]
}
],
"provisioners": [
{
"type": "shell",
"execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"scripts": [
"scripts/update.sh",
"scripts/packages.sh",
"scripts/cleanup.sh"
]
}
]
}
{
"variables": {
"user": "slapos",
"password": "slapos",
"disk_size": "100000",
"domain": ""
},
"builders":
[
{
"name": "debian8",
"type": "qemu",
"format": "qcow2",
"accelerator": "kvm",
"disk_size": "{{ user `disk_size`}}",
"iso_url": "http://cdimage.debian.org/debian-cd/8.3.0/amd64/iso-cd/debian-8.3.0-amd64-netinst.iso",
"iso_checksum": "a9b490b4215d1e72e876b031dafa7184",
"iso_checksum_type": "md5",
"http_directory": "http",
"ssh_username": "{{user `user`}}",
"ssh_password": "{{user `password`}}",
"ssh_wait_timeout": "1800s",
"shutdown_command": "echo '{{user `password`}}'|sudo -S shutdown -h now",
"headless": false,
"boot_wait": "2s",
"boot_command": [
"<esc><wait><wait>",
"install auto ",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed-debian8.cfg ",
"debian-installer=en_US locale=en_US keymap=us ",
"netcfg/get_hostname={{ .Name }} ",
"netcfg/get_domain={{ user `domain`}} ",
"fb=false debconf/frontend=noninteractive ",
"passwd/user-fullname={{user `user`}} ",
"passwd/user-password={{user `password`}} ",
"passwd/user-password-again={{user `password`}} ",
"passwd/username={{user `user`}} ",
"<enter>"
]
}
],
"provisioners": [
{
"type": "shell",
"execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"scripts": [
"scripts/update.sh",
"scripts/packages.sh",
"scripts/cleanup.sh"
]
}
]
}
install
text
reboot
cdrom
lang en_US.UTF-8
keyboard us
timezone --utc Etc/UTC
rootpw --plaintext slapos
user --name=slapos --groups=slapos --password=slapos --plaintext
zerombr
clearpart --all
autopart
bootloader --timeout=1
%packages --nobase
@core
-b43-openfwwf
-device-mapper-multipath
-efibootmgr
-iscsi-initiator-utils
-lvm2
-mdadm
%end
%post --erroronfail
yum -y update
cat <<EOF > /etc/sudoers.d/slapos
Defaults:slapos !requiretty
slapos ALL=(ALL) NOPASSWD: ALL
EOF
chmod 440 /etc/sudoers.d/slapos
rm /etc/udev/rules.d/70-persistent-net.rules
ln -s /dev/null /etc/udev/rules.d/75-persistent-net-generator.rules
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <<EOF
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
TYPE="Ethernet"
EOF
%end
install
text
reboot
url --mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
lang en_US.UTF-8
keyboard us
timezone --utc Etc/UTC
rootpw --plaintext slapos
user --name=slapos --groups=slapos --password=slapos --plaintext
zerombr
clearpart --all --initlabel
autopart --type=plain
bootloader --timeout=1
%packages
@core
which
# mandatory packages in the @core group
-btrfs-progs
-iprutils
-kexec-tools
-plymouth
# default packages in the @core group
-*-firmware
-dracut-config-rescue
-kernel-tools
-libsysfs
-microcode_ctl
-NetworkManager*
-postfix
-rdma
%end
%post --erroronfail
yum -y update
cat <<EOF > /etc/sudoers.d/slapos
Defaults:slapos !requiretty
slapos ALL=(ALL) NOPASSWD: ALL
EOF
chmod 440 /etc/sudoers.d/slapos
ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <<EOF
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
TYPE="Ethernet"
EOF
%end
d-i clock-setup/ntp boolean true
d-i clock-setup/utc 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 mirror/country string manual
d-i mirror/http/directory string /debian
d-i mirror/http/hostname string http.us.debian.org
d-i mirror/http/proxy string
d-i netcfg/choose_interface select auto
d-i netcfg/wireless_wep string
d-i partman-auto/choose_recipe select atomic
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 partman/default_filesystem string ext4
d-i passwd/root-login boolean false
d-i pkgsel/include string openssh-server
d-i pkgsel/upgrade select full-upgrade
d-i time/zone string CET
popularity-contest popularity-contest/participate boolean false
tasksel tasksel/first multiselect standard
d-i clock-setup/ntp boolean true
d-i clock-setup/utc 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
d-i grub-installer/choose_bootdev select /dev/vda
d-i mirror/country string manual
d-i mirror/http/directory string /debian
d-i mirror/http/hostname string http.us.debian.org
d-i mirror/http/proxy string
d-i netcfg/choose_interface select auto
d-i netcfg/wireless_wep string
d-i partman-auto/choose_recipe select atomic
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 partman/default_filesystem string ext4
d-i passwd/root-login boolean false
d-i pkgsel/include string openssh-server
d-i pkgsel/upgrade select full-upgrade
d-i time/zone string CET
popularity-contest popularity-contest/participate boolean false
tasksel tasksel/first multiselect standard
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 unattended-upgrades
d-i pkgsel/upgrade select none
d-i time/zone string CET
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false
tasksel tasksel/first multiselect standard, ubuntu-server
#!/bin/bash -eux
CLEANUP_PAUSE=${CLEANUP_PAUSE:-0}
echo "==> Pausing for ${CLEANUP_PAUSE} seconds..."
sleep ${CLEANUP_PAUSE}
# Make sure Udev doesn't block our network
# http://6.ptmc.org/?p=164
echo "cleaning up udev rules"
rm -rf /dev/.udev/
rm /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 "==> Cleaning up tmp"
rm -rf /tmp/*
# Cleanup apt cache
apt-get -y autoremove --purge
apt-get -y clean
apt-get -y autoclean
echo "==> Installed packages"
dpkg --get-selections | grep -v deinstall
# Remove Bash history
unset HISTFILE
rm -f /root/.bash_history
# Clean up log files
find /var/log -type f | while read f; do echo -ne '' > $f; done;
#!/bin/sh
# Disable udev persistent net rules
rm /etc/udev/rules.d/70-persistent-net.rules
mkdir /etc/udev/rules.d/70-persistent-net.rules
rm /lib/udev/rules.d/75-persistent-net-generator.rules
rm -rf /dev/.udev/ /var/lib/dhcp3/*
echo "pre-up sleep 2" >> /etc/network/interfaces
# Disable DNS reverse lookup
echo "UseDNS no" >> /etc/ssh/sshd_config
PACKAGES="
curl
wget
"
apt-get -y install $PACKAGES
PACKAGES="
wget
curl
sudo
"
aptitude -y install --without-recommends $PACKAGES
# Update the box
apt-get -y update
apt-get -y upgrade
# Update the box
aptitude -y update
aptitude -y full-upgrade
{
"variables": {
"user": "slapos",
"password": "slapos",
"disk_size": "100000"
},
"builders":
[
{
"name": "ubuntu-14-04-server",
"type": "qemu",
"format": "qcow2",
"accelerator": "kvm",
"disk_size": "{{ user `disk_size`}}",
"iso_url": "http://releases.ubuntu.com/14.04/ubuntu-14.04.4-server-amd64.iso",
"iso_checksum": "2ac1f3e0de626e54d05065d6f549fa3a",
"iso_checksum_type": "md5",
"http_directory": "http",
"ssh_username": "{{user `user`}}",
"ssh_password": "{{user `password`}}",
"ssh_wait_timeout": "1800s",
"shutdown_command": "echo '{{user `password`}}'|sudo -S shutdown -P now",
"boot_wait": "2s",
"boot_command": [
"<esc><esc><enter><wait>",
"/install/vmlinuz url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed-ubuntu.cfg ",
"debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
"hostname={{ .Name }} ",
"keyboard-configuration/modelcode=SKIP ",
"keyboard-configuration/layout=USA ",
"keyboard-configuration/variant=USA ",
"passwd/user-fullname={{user `user`}} ",
"passwd/user-password-again={{user `password`}} ",
"passwd/user-password={{user `password`}} ",
"passwd/username={{user `user`}} ",
"initrd=/install/initrd.gz -- <enter>"
]
}
],
"provisioners": [
{
"type": "shell",
"execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"scripts": [
"scripts/update-ubuntu.sh",
"scripts/packages-ubuntu.sh",
"scripts/network-ubuntu.sh"
]
}
]
}
{
"variables": {
"user": "slapos",
"password": "slapos",
"disk_size": "100000"
},
"builders":
[
{
"name": "ubuntu-15-04-server",
"type": "qemu",
"format": "qcow2",
"accelerator": "kvm",
"disk_size": "{{ user `disk_size`}}",
"iso_url": "http://releases.ubuntu.com/15.04/ubuntu-15.04-server-amd64.iso",
"iso_checksum": "487f4a81f22f8597503db3d51a1b502e",
"iso_checksum_type": "md5",
"http_directory": "http",
"ssh_username": "{{user `user`}}",
"ssh_password": "{{user `password`}}",
"ssh_wait_timeout": "1800s",
"shutdown_command": "echo '{{user `password`}}'|sudo -S shutdown -P now",
"boot_wait": "2s",
"boot_command": [
"<esc><esc><enter><wait>",
"/install/vmlinuz url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed-ubuntu.cfg ",
"debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
"hostname={{ .Name }} ",
"keyboard-configuration/modelcode=SKIP ",
"keyboard-configuration/layout=USA ",
"keyboard-configuration/variant=USA ",
"passwd/user-fullname={{user `user`}} ",
"passwd/user-password-again={{user `password`}} ",
"passwd/user-password={{user `password`}} ",
"passwd/username={{user `user`}} ",
"initrd=/install/initrd.gz -- <enter>"
]
}
],
"provisioners": [
{
"type": "shell",
"execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"scripts": [
"scripts/update-ubuntu.sh",
"scripts/packages-ubuntu.sh",
"scripts/network-ubuntu.sh"
]
}
]
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment