add packer to build arch image on hetzner
This commit is contained in:
parent
2da18e9c12
commit
527d2f2345
6
packer/.gitignore
vendored
Normal file
6
packer/.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
*-manifest.json
|
||||||
|
*.pem
|
||||||
|
*.sig
|
||||||
|
*.asc
|
||||||
|
secret*
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
variable "extra-packages" {
|
variable "extra-packages" {
|
||||||
type = list(string)
|
type = list(string)
|
||||||
default = []
|
default = ["python","sudo","inetutils","zsh"]
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "hcloud-servertype" {
|
variable "hcloud-servertype" {
|
||||||
|
@ -34,7 +34,7 @@ set -euo pipefail
|
|||||||
echo 'Server = ${ARCH_MIRROR}/\$repo/os/\$arch' > /etc/pacman.d/mirrorlist
|
echo 'Server = ${ARCH_MIRROR}/\$repo/os/\$arch' > /etc/pacman.d/mirrorlist
|
||||||
pacman-key --init
|
pacman-key --init
|
||||||
pacman-key --populate archlinux
|
pacman-key --populate archlinux
|
||||||
pacstrap /mnt base linux grub nano btrfs-progs openssh curl jq python-yaml $EXTRA_PACKAGES
|
pacstrap /mnt base linux grub nano btrfs-progs openssh curl jq python-yaml systemd-resolvconf $EXTRA_PACKAGES
|
||||||
|
|
||||||
# fstab
|
# fstab
|
||||||
genfstab -U /mnt > /mnt/etc/fstab
|
genfstab -U /mnt > /mnt/etc/fstab
|
||||||
@ -53,7 +53,9 @@ hwclock --systohc
|
|||||||
# locale
|
# locale
|
||||||
echo 'KEYMAP=${KEYMAP}' > /etc/vconsole.conf
|
echo 'KEYMAP=${KEYMAP}' > /etc/vconsole.conf
|
||||||
echo '${LOCALE} UTF-8' > /etc/locale.gen
|
echo '${LOCALE} UTF-8' > /etc/locale.gen
|
||||||
echo 'LANG=${LOCALE}' > /etc/locale.conf
|
if [ "$LOCALE" != "en_US.UTF-8" ]; then
|
||||||
|
echo 'en_US.UTF-8 UTF8' >> /etc/locale.gen
|
||||||
|
fi
|
||||||
locale-gen
|
locale-gen
|
||||||
|
|
||||||
# network
|
# network
|
||||||
@ -79,10 +81,15 @@ done
|
|||||||
# misc
|
# misc
|
||||||
systemctl set-default multi-user.target
|
systemctl set-default multi-user.target
|
||||||
usermod -L root
|
usermod -L root
|
||||||
|
useradd -m -s /bin/bash ansible
|
||||||
|
mkdir /home/ansible/.ssh
|
||||||
|
echo 'ansible ALL = (ALL) NOPASSWD:ALL' > /etc/sudoers.d/ansible
|
||||||
|
|
||||||
echo 'archlinux' > /etc/hostname
|
echo 'archlinux' > /etc/hostname
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
ln -sf ../run/systemd/resolve/stub-resolv.conf /mnt/etc/resolv.conf
|
||||||
# clean up
|
# clean up
|
||||||
rm /mnt/root/.bash_history
|
rm /mnt/root/.bash_history
|
||||||
rm -r /mnt/var/cache/*
|
rm -r /mnt/var/cache/*
|
||||||
|
@ -8,7 +8,7 @@ ConditionPathExists=!/root/.ssh/authorized_keys
|
|||||||
Type=oneshot
|
Type=oneshot
|
||||||
DynamicUser=yes
|
DynamicUser=yes
|
||||||
ExecStart=/usr/bin/jq -r '.ssh_keys|join("\n")' /etc/hcloud-metadata.json
|
ExecStart=/usr/bin/jq -r '.ssh_keys|join("\n")' /etc/hcloud-metadata.json
|
||||||
StandardOutput=truncate:/root/.ssh/authorized_keys
|
StandardOutput=truncate:/home/ansible/.ssh/authorized_keys
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
Loading…
Reference in New Issue
Block a user