55 lines
2.1 KiB
YAML
55 lines
2.1 KiB
YAML
|
---
|
||
|
- name: "Download and install APK static into the host system."
|
||
|
shell: "cd / && curl http://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/apk-tools-static-2.12.7-r3.apk | tar -xvzf - sbin/apk.static"
|
||
|
args:
|
||
|
creates: "/sbin/apk.static"
|
||
|
- name: "Perform installation in a mostly secure way. First install keys insecurely."
|
||
|
shell: "apk.static -X http://dl-cdn.alpinelinux.org/alpine/v3.15/main --root /mnt --arch x86_64 --initdb --allow-untrusted add alpine-keys"
|
||
|
args:
|
||
|
creates: "/mnt/etc/apk/keys"
|
||
|
- name: "Enable repositories."
|
||
|
template:
|
||
|
src: "templates/repositories.j2"
|
||
|
dest: "/mnt/etc/apk/repositories"
|
||
|
mode: "0600"
|
||
|
- name: "Install packages with signature verification. Update if already present."
|
||
|
shell: "apk.static --root /mnt --arch x86_64 add {{ item }}"
|
||
|
loop: "{{ packages }}"
|
||
|
- name: "Tell Alpine how to mount partitions after boot."
|
||
|
template:
|
||
|
src: "templates/fstab.j2"
|
||
|
dest: "/mnt/etc/fstab"
|
||
|
mode: "0755"
|
||
|
- name: "Load BTRFS module on boot"
|
||
|
shell: "grep -q btrfs /mnt/etc/modules || echo btrfs >> /mnt/etc/modules"
|
||
|
- name: "And which features to include into initramfs."
|
||
|
template:
|
||
|
src: "templates/mkinitfs.conf.j2"
|
||
|
dest: "/mnt/etc/mkinitfs/mkinitfs.conf"
|
||
|
mode: "0750"
|
||
|
- name: "Copy SSH host keys from the live system."
|
||
|
shell: "cp -a /etc/ssh/*_key* /mnt/etc/ssh/"
|
||
|
args:
|
||
|
creates: "/mnt/etc/ssh/ssh_host_ed25519_key"
|
||
|
- name: "Copy SSH authorized keys from the live system. First create the /root/.ssh directory."
|
||
|
file:
|
||
|
state: "directory"
|
||
|
path: "/mnt/root/.ssh"
|
||
|
owner: "root"
|
||
|
group: "root"
|
||
|
mode: "0700"
|
||
|
- name: "And then the authorized_keys file."
|
||
|
shell: "install -m 600 -o root -g root /root/.ssh/authorized_keys /mnt/root/.ssh/authorized_keys"
|
||
|
args:
|
||
|
creates: "/mnt/root/.ssh/authorized_keys"
|
||
|
- name: "Install network configuration."
|
||
|
template:
|
||
|
src: "templates/interfaces.j2"
|
||
|
dest: "/mnt/etc/network/interfaces"
|
||
|
- name: "And DNS resolvers."
|
||
|
template:
|
||
|
src: "templates/resolv.conf.j2"
|
||
|
dest: "/mnt/etc/resolv.conf"
|
||
|
- name: "Set hostname."
|
||
|
shell: "echo {{ inventory_hostname }} > /etc/hostname"
|