ansible-playbooks/roles/archlinux/tasks/yay.yml

51 lines
1.3 KiB
YAML

---
- 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
- name: Create yay sources dir
ansible.builtin.file:
path: "{{ yay_src_path }}"
state: directory
owner: "{{ ansible_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