---
- 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: verify boot mode
  stat: path=/sys/firmware/efi/efivars
  register: efivars
  tags: systemd-boot

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

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

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

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

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

Add boot mode verification to systemd-boot role
Add boot mode verification to systemd-boot role

The systemd-boot role will now verify the boot mode is uefi and skip
all remaining tasks if this is not true.
