ansible-workstation/roles/base/tasks/archinstall/install_os.yaml
2024-11-22 10:45:41 -06:00

81 lines
2.3 KiB
YAML

---
- name: archinstall | install os | check for presence of previously pacstrapped /mnt
ansible.builtin.stat:
path: /mnt/usr/lib
register: existing_pacstrap
- ansible.builtin.debug:
var: existing_pacstrap
- name: archinstall | install os | pacstrap
ansible.builtin.command: "pacstrap /mnt {{ packages | join(' ') }}"
vars:
packages:
- ansible
- base
- base-devel
- efibootmgr
- git
- git
- iwd
- linux-firmware
- linux-lts
- linux-lts-headers
- openssh
- zsh
when: not existing_pacstrap.stat.exists
- name: archinstall | install os | copy pacman mirrorlist
ansible.builtin.copy:
remote_src: true
src: /etc/pacman.d/mirrorlist
dest: /mnt/etc/pacman.d/mirrorlist
- name: archinstall | install os | propagate root authorized keys
ansible.builtin.copy:
remote_src: true
src: /root/.ssh/authorized_keys
dest: /mnt/root/.ssh/authorized_keys
- name: archinstall | install os | passwordless sudo for group wheel
ansible.builtin.copy:
content: "%wheel ALL=(ALL) NOPASSWD: ALL"
dest: /mnt/etc/sudoers.d/wheel-group-nopasswd
- name: archinstall | install os | set timezone
ansible.builtin.file:
src: /usr/share/zoneinfo/US/Central
dest: /mnt/etc/localtime
state: link
- name: archinstall | install os | enable en_US locales
ansible.builtin.command: sed -i 's/^#en_US/en_US/' /mnt/etc/locale.gen
- name: archinstall | install os | generate locales
ansible.builtin.command: arch-chroot /mnt locale-gen
- name: archinstall | install os | generate template for arch-chroot installation
ansible.builtin.template:
src: arch_chroot_install.sh
dest: /mnt/arch_chroot_install.sh
mode: "0755"
- name: archinstall | install os | set hostname
ansible.builtin.copy:
dest: /mnt/etc/hostname
content: |
{{ inventory_hostname }}
- name: archinstall | install os | run installation script in arch-chroot
ansible.builtin.command: arch-chroot /mnt /arch_chroot_install.sh
register: chroot
- name: archinstall | install os | arch-chroot install output
ansible.builtin.debug:
msg: "{{ chroot.stdout_lines }}"
- name: archinstall | install os | remove arch-chroot installation script
ansible.builtin.file:
path: /mnt/arch_chroot_install.sh
state: absent
# TODO
# - name: archinstall | install os | create fstab