---
- name: install required firmware
  pacman:
    name: "{{ systemd_boot.packages }}"
    update_cache: true
  when: "'GenuineIntel' in ansible_processor"
  tags: systemd-boot

- name: setup systemd-boot esp
  copy:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
  with_items: "{{ systemd_boot.files }}"
  tags: systemd-boot

- name: setup systemd-boot menu
  template:
    src: loader.conf.j2
    dest: /boot/loader/loader.conf
  tags: systemd-boot

- name: register root device
  shell: 'cat /etc/fstab | egrep "\s/\s" | cut -d" " -f1'
  register: root_uuid
  changed_when: false
  tags: systemd-boot

- name: setup systemd-boot entries
  template:
    src: "entries/arch.conf.j2"
    dest: "/boot/loader/entries/arch.conf"
  tags: systemd-boot

---
- name: install required firmware
  pacman:
    name: "{{ systemd_boot.packages }}"
    update_cache: true
  when: "'GenuineIntel' in ansible_processor"
  tags: systemd-boot

- name: check boot entries
  command: bootctl status
  register: boot_entries
  changed_when: false
  tags: systemd-boot

- name: create systemd-boot efi entry
  command: bootctl --path=/boot install
  register: result
  failed_when: result.rc >= 2
  when: boot_entries.stdout.find('Linux Boot Manager') == -1
  tags: systemd-boot

- name: setup systemd-boot menu
  template:
    src: loader.conf.j2
    dest: /boot/loader/loader.conf
  tags: systemd-boot

- name: register root device
  shell: 'cat /etc/fstab | egrep "\s/\s" | cut -d" " -f1'
  register: root_uuid
  changed_when: false
  tags: systemd-boot

- name: setup systemd-boot entries
  template:
    src: "entries/arch.conf.j2"
    dest: "/boot/loader/entries/arch.conf"
  tags: systemd-boot

Handle efi boot variable entries in systemd-boot
Handle efi boot variable entries in systemd-boot

The systemd-boot role will now add an entry to the EFI boot variables
and add it to the top of the boot order. This was not added until now
because it was believed that without proper conditionals an infinate
amount of entries would be added, filling the NVRAM. It would appear
this is not the case.
