- name: List kernel module dirs
  ansible.builtin.find:
    paths: "/usr/lib/modules"
    file_type: directory
  register: found_kernels
  listen: installed-booster

- name: Find kernels
  ansible.builtin.set_fact:
    kernel_list: "{{ found_kernels['files'] | map(attribute='path') | map('regex_replace', '^.*/(.*)$', '\\1') | list }}"
  listen: installed-booster

- name: Create booster initramfs
  ansible.builtin.command:
    argv:
      - booster
      - --verbose
      - build
      - --kernel-version={{ item }}
      - "{{ fname }}-{{ item }}.img"
    creates: "{{ fname }}-{{ item }}.img"
  loop: "{{ kernel_list }}"
  listen: installed-booster

- name: Regenerate locales
  ansible.builtin.command:
    argv:
      - xbps-reconfigure
      - --force
      - libc-locales
  listen: glibc-locales-changed