--- - name: Check if yay is already installed ansible.builtin.stat: path: /usr/bin/yay register: yay - name: Install yay when: not yay.stat.exists block: - name: Install build dependencies ansible.builtin.package: name: - base-devel - git state: present - name: Disable sudo password prompt (makepkg sudoers hack) ansible.builtin.lineinfile: dest: /etc/sudoers state: present regexp: "^#?%wheel" line: "%wheel ALL=(ALL) NOPASSWD: ALL" validate: /usr/sbin/visudo -cf %s - ansible.builtin.command: cmd: whoami no_log: true become: false register: main_user - ansible.builtin.set_fact: main_user: "{{ main_user.stdout }}" no_log: true - name: Create yay sources dir ansible.builtin.file: path: "{{ yay_src_path }}" state: directory owner: "{{ main_user }}" - name: Clone git sources become: false ansible.builtin.git: repo: "{{ yay_git_repo }}" dest: "{{ yay_src_path }}" # note: this only works because SUDOERS password prompt is disabled - name: Build and install become: false ansible.builtin.command: chdir: "{{ yay_src_path }}" cmd: "makepkg -si -f --noconfirm" - name: Restore sudo with password prompt ansible.builtin.lineinfile: dest: /etc/sudoers state: present regexp: "^#?%wheel" line: "%wheel ALL=(ALL:ALL) ALL" validate: /usr/sbin/visudo -cf %s