--- - hosts: all vars: install_drive: /dev/sda boot_partition_suffix: 1 timezone: Europe/Berlin user_name: mediabox tasks: - name: Abort if the host is not booted from the Arch install media fail: msg: "This host is not booted from the Arch install media!" when: ansible_nodename != 'archiso' - name: Synchronize clock via NTP command: timedatectl set-ntp true - name: Repartition install drive block: - name: Wipe install drive and all its partitions command: find /dev -wholename "{{ install_drive }}*" -exec wipefs --force --all {} \; - name: Create boot partition parted: device: '{{ install_drive }}' label: gpt number: 1 part_end: 512MB name: boot flags: [boot, esp] state: present - name: Create root partition parted: device: '{{ install_drive }}' label: gpt number: 2 part_start: 512MB name: root flags: [] state: present - name: Create filesystems block: - name: Create FAT32 filesystem in boot partition filesystem: dev: '{{ install_drive }}1' fstype: vfat opts: -F32 force: yes - name: Create ext4 filesystem in root volume filesystem: dev: '{{ install_drive }}2' fstype: ext4 force: yes - name: Get UUID for boot filesystem command: blkid -s UUID -o value '{{ install_drive }}1' register: boot_uuid changed_when: false - name: Get UUID for root filesystem command: blkid -s UUID -o value '{{ install_drive }}2' register: root_uuid changed_when: false - name: Mount filesystems block: - name: Mount root filesystem mount: path: /mnt src: UUID={{ root_uuid.stdout }} fstype: ext4 state: mounted - name: Create mountpoint for boot volume file: path: /mnt/boot state: directory - name: Mount boot filesystem mount: path: /mnt/boot src: UUID={{ boot_uuid.stdout }} fstype: vfat state: mounted - name: Run pacstrap command: pacstrap /mnt base base-devel efibootmgr grub linux linux-firmware openssh python reflector sudo networkmanager kodi lzo polkit vim - name: Generate fstab command: genfstab -U /mnt >> /mnt/etc/fstab - name: Set local timezone command: arch-chroot /mnt ln -sf /usr/share/zoneinfo/{{ timezone }} /etc/localtime - name: Generate adjtime file command: arch-chroot /mnt hwclock --systohc - name: Setup locales block: - name: Configure locale.gen lineinfile: dest: /mnt/etc/locale.gen regexp: '{{ item.regex }}' line: '{{ item.line }}' loop: - {regex: en_US\.UTF-8 UTF-8, line: en_US.UTF-8 UTF-8} - {regex: en_US ISO-8859-1, line: en_US ISO-8859-1} - name: Create locale.conf copy: content: "LANG=en_US.UTF-8" dest: /mnt/etc/locale.conf - name: Generate locales command: arch-chroot /mnt locale-gen - name: Set hostname copy: content: '{{ hostname }}' dest: /mnt/etc/hostname - name: Set up initramfs command: arch-chroot /mnt mkinitcpio -p linux - name: Set up grub block: - name: Install grub command: arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB - name: Create grub config command: arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg - name: Setup user account block: - name: Create user account command: arch-chroot /mnt useradd --create-home --user-group --groups wheel,input {{ user_name }} --password {{ user_password }} - name: Give passwordless sudo access to wheel group copy: content: '%wheel ALL=(ALL) NOPASSWD: ALL' dest: /mnt/etc/sudoers.d/wheel validate: /usr/sbin/visudo --check --file=%s - name: Change root pw command: arch-chroot /mnt echo "root:{{user_password}}" | chpasswd - name: Enable NetworkManager command: arch-chroot /mnt systemctl enable NetworkManager - name: Enable SSH server command: arch-chroot /mnt systemctl enable sshd - name: Insert Kodi service block: - name: Create systemd service file copy: src: "{{playbook_dir}}/kodi.service" dest: /mnt/etc/systemd/system/kodi.service - name: Enable kodi service command: arch-chroot /mnt systemctl enable kodi.service