Skip to content
Snippets Groups Projects
Unverified Commit 9d9f04f9 authored by Christian Rebischke's avatar Christian Rebischke Committed by GitHub
Browse files

Merge pull request #66 from shibumi/shibumi/official-cloud-images

add support for cloud images
parents ec46f71b 4c03420f
No related branches found
No related tags found
No related merge requests found
{
"variables": {
"iso_url": "https://mirror.pkgbuild.com/iso/latest/archlinux-2019.10.01-x86_64.iso",
"iso_checksum_url": "https://mirror.pkgbuild.com/iso/latest/sha1sums.txt",
"iso_checksum_type": "sha1",
"disk_size": "20480",
"memory": "1024",
"cpus": "2",
"headless": "true",
"write_zeroes": "",
"boot_wait": "60s"
},
"builders": [
{
"name": "Arch-Linux-cloudimg-amd64-{{isotime \"2006-01-02\"}}.img",
"type": "qemu",
"output_directory": "release",
"boot_wait": "{{user `boot_wait`}}",
"http_directory": "http",
"disk_size": "{{user `disk_size`}}",
"iso_checksum_url": "{{user `iso_checksum_url`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_url": "{{user `iso_url`}}",
"ssh_username": "arch",
"ssh_password": "arch",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"shutdown_command": "sudo systemctl poweroff",
"headless": "{{user `headless`}}",
"qemuargs": [
[
"-m",
"{{user `memory`}}"
],
[
"-smp",
"{{user `cpus`}}"
]
],
"boot_command": [
"<enter><wait10><wait10><wait10><wait10><wait10><enter><enter>",
"curl -O 'http://{{.HTTPIP}}:{{.HTTPPort}}/install{,-cloud}.sh'<enter><wait>",
"bash install.sh < install-cloud.sh && systemctl reboot<enter>"
]
}
],
"provisioners": [
{
"type": "shell",
"scripts": [
"provision/postinstall.sh",
"provision/qemu.sh",
"provision/cloud-init.sh",
"provision/cleanup.sh"
],
"execute_command": "echo 'arch'|sudo -S sh '{{.Path}}'"
},
{
"type": "shell",
"scripts": [
"provision/write_zeroes.sh"
],
"execute_command": "if [ ! -z \"{{user `write_zeroes`}}\" ]; then echo 'arch'|sudo -S sh '{{.Path}}'; fi"
}
],
"post-processors": [
[
{
"type": "checksum",
"checksum_types": [
"sha256"
],
"output": "Arch-Linux-cloudimg-amd64-{{isotime \"2006-01-02\"}}.SHA256"
},
{
"type": "shell-local",
"inline": [
"mv release/packer-Arch-Linux-cloudimg-amd64-{{isotime \"2006-01-02\"}}.img release/Arch-Linux-cloudimg-amd64-{{isotime \"2006-01-02\"}}.img",
"sed -i 's/packer-//' Arch-Linux-cloudimg-amd64-{{isotime \"2006-01-02\"}}.SHA256",
"gpg --sign --detach-sign Arch-Linux-cloudimg-amd64-{{isotime \"2006-01-02\"}}.SHA256"
]
}
]
]
}
#!/bin/bash
set -e
set -x
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
sed -i -e 's/^#\(en_US.UTF-8\)/\1/' /etc/locale.gen
locale-gen
echo 'LANG=en_US.UTF-8' >/etc/locale.conf
# setting arch user credentials
echo -e 'arch\narch' | passwd
useradd -m -U arch
echo -e 'arch\narch' | passwd arch
# setting automatic authentication for any action requiring admin rights via Polkit
cat <<EOF >/etc/polkit-1/rules.d/49-nopasswd_global.rules
polkit.addRule(function(action, subject) {
if (subject.isInGroup("arch")) {
return polkit.Result.YES;
}
});
EOF
# setting sudo for arch user
cat <<EOF >/etc/sudoers.d/arch
Defaults:arch !requiretty
arch ALL=(ALL) NOPASSWD: ALL
EOF
chmod 440 /etc/sudoers.d/arch
# setup unpredictable kernel names
ln -s /dev/null /etc/systemd/network/99-default.link
# setup network
cat <<EOF >/etc/systemd/network/eth0.network
[Match]
Name=eth0
[Network]
DHCP=ipv4
EOF
# Setup pacman-init.service for clean pacman keyring initialization
cat <<EOF >/etc/systemd/system/pacman-init.service
[Unit]
Description=Initializes Pacman keyring
Wants=haveged.service
After=haveged.service
Before=sshd.service
ConditionFirstBoot=yes
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/pacman-key --init
ExecStart=/usr/bin/pacman-key --populate archlinux
[Install]
WantedBy=multi-user.target
EOF
# enabling important services
systemctl daemon-reload
systemctl enable sshd
systemctl enable haveged
systemctl enable systemd-networkd
systemctl enable systemd-resolved
systemctl enable pacman-init.service
if [ -b "/dev/sda" ]; then
grub-install /dev/sda
elif [ -b "/dev/vda" ]; then
grub-install /dev/vda
fi
sed -i -e 's/^GRUB_TIMEOUT=.*$/GRUB_TIMEOUT=1/' /etc/default/grub
grub-mkconfig -o /boot/grub/grub.cfg
#!/bin/bash
set -e
set -x
sudo pacman -S --noconfirm cloud-init
sudo systemctl enable cloud-init-local.service
sudo systemctl enable cloud-init.service
sudo systemctl enable cloud-config.service
sudo systemctl enable cloud-final.service
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment