summaryrefslogtreecommitdiffstats
path: root/roles/bootstrap/tasks
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2025-08-11 00:33:29 +0200
committerAhmed Abdelhalim <[email protected]>2025-08-11 00:33:29 +0200
commit3cc7bb4b415e758786ed04d3b506031cd9f1971b (patch)
tree2e60192ae61fca19022d9e1b3075edf75e06fe61 /roles/bootstrap/tasks
parentaeaa724705363ca104ab4770d844e396795af3ea (diff)
Add the bootstrap role to install archlinux w/testing
Diffstat (limited to 'roles/bootstrap/tasks')
-rw-r--r--roles/bootstrap/tasks/install-archlinux.yml57
-rw-r--r--roles/bootstrap/tasks/main.yml9
2 files changed, 66 insertions, 0 deletions
diff --git a/roles/bootstrap/tasks/install-archlinux.yml b/roles/bootstrap/tasks/install-archlinux.yml
new file mode 100644
index 0000000..057a639
--- /dev/null
+++ b/roles/bootstrap/tasks/install-archlinux.yml
@@ -0,0 +1,57 @@
+---
+- name: "Run pacstrap"
+ ansible.builtin.command:
+ cmd: "pacstrap -K {{ mnt_root_path }} base linux linux-firmware"
+ changed_when: true
+
+- name: "Generate fstab"
+ ansible.builtin.shell:
+ cmd: "genfstab -t PARTLABEL {{ mnt_root_path }} > {{ mnt_root_path }}/etc/fstab"
+ changed_when: true
+
+- name: "Run bootclt"
+ ansible.builtin.command:
+ cmd: "arch-chroot {{ mnt_root_path }} bootctl install"
+ changed_when: true
+
+- name: "Enable systemd-boot-update"
+ ansible.builtin.command:
+ cmd: "arch-chroot {{ mnt_root_path }} systemctl enable systemd-boot-update"
+ changed_when: false
+
+- name: "Template systemd-boot files"
+ ansible.builtin.template:
+ src: "{{ item.src }}"
+ dest: "{{ item.dest }}"
+ mode: "0644"
+ with_items:
+ - src: "loader.conf.j2"
+ dest: "{{ mnt_boot_path }}/loader/loader.conf"
+ - src: "archlinux.conf.j2"
+ dest: "{{ mnt_boot_path }}/loader/entries/archlinux.conf"
+
+- name: "Configure hostname in chroot"
+ ansible.builtin.copy:
+ dest: "{{ mnt_root_path }}/etc/hostname"
+ mode: "0644"
+ content: "{{ hostname }}"
+
+- name: "Configure pacman in chroot"
+ ansible.builtin.copy:
+ src: "/etc/pacman.conf"
+ dest: "{{ mnt_root_path }}/etc/pacman.conf"
+ remote_src: true
+ force: false
+ mode: "0644"
+
+- name: "Ensure pacman is updated in chroot"
+ ansible.builtin.shell: |
+ arch-chroot {{ mnt_root_path }} pacman-key --init
+ arch-chroot {{ mnt_root_path }} pacman-key --populate
+ arch-chroot {{ mnt_root_path }} pacman -Syyu --noconfirm
+ changed_when: true
+
+- name: "Ensure ansible dependencies are installed in chroot"
+ ansible.builtin.command:
+ cmd: "arch-chroot {{ mnt_root_path }} pacman -S --noconfirm python3"
+ changed_when: true
diff --git a/roles/bootstrap/tasks/main.yml b/roles/bootstrap/tasks/main.yml
new file mode 100644
index 0000000..fbc3de5
--- /dev/null
+++ b/roles/bootstrap/tasks/main.yml
@@ -0,0 +1,9 @@
+---
+- name: "Set root,boot partition paths"
+ ansible.builtin.set_fact:
+ mnt_boot_path: "{{ partition_boot.mount_path }}"
+ mnt_root_path: "{{ partition_root.mount_path }}"
+
+- name: "Install archlinux"
+ ansible.builtin.include_tasks: "install-archlinux.yml"
+ when: ansible_os_family == "Archlinux"