--- - name: "Ensure base-devel is installed" become: true ansible.builtin.package: name: "base-devel" state: "present" - name: "Check if yay exists" ansible.builtin.stat: path: "/usr/bin/yay" register: yay_binary - name: "Install yay" when: not yay_binary.stat.exists block: - name: "Clone yay-bin" ansible.builtin.git: repo: "https://aur.archlinux.org/yay-bin.git" dest: "/tmp/yay-bin" clone: true update: false single_branch: true version: "master" - name: "Build yay-bin" ansible.builtin.command: cmd: "makepkg --syncdeps --noconfirm" chdir: "/tmp/yay-bin" args: creates: "/tmp/yay-bin/yay-bin-*.pkg.tar.zst" - name: "Install yay bin" become: true ansible.builtin.shell: cmd: "pacman -U --noconfirm /tmp/yay-bin/yay-bin-*.pkg.tar.zst" args: creates: "/usr/bin/yay" - name: "Configure yay aur_builder passwordless" # yay builder is the user that is allowed to execute yay wihtout password # to be able to use yay automation or archlinux # Ref: https://github.com/kewlfft/ansible-aur?tab=readme-ov-file#usage block: - name: "Create the 'aur_builder' user" become: true ansible.builtin.user: name: "aur_builder" create_home: true group: wheel - name: "Allow 'username' to become 'aur_builder' user without a password" become: true ansible.builtin.lineinfile: path: "/etc/sudoers.d/10-aur_builder-become" line: "{{ username }} ALL=(aur_builder) NOPASSWD: ALL" create: true mode: "0644" validate: "visudo -cf %s" - name: "Allow the 'aur_builder' user to run 'sudo pacman' without a password" become: true ansible.builtin.lineinfile: path: "/etc/sudoers.d/11-aur_builder-pacman" line: "aur_builder ALL=(ALL) NOPASSWD: /usr/bin/pacman" create: true mode: "0644" validate: "visudo -cf %s"