Files
willlaptop/ansible/roles/packages/tasks/main.yml
William Valentin 7bd5974ac4 Add initial Ansible configuration and package management setup
- Create .gitignore to exclude .vscode directory
    - Add ansible.cfg for Ansible configuration
    - Define inventory for new machine
    - Create playbook.yml for orchestrating tasks
    - Set up common role with default variables, handlers, and tasks
    - Implement package management tasks for installing packages from various sources
    - Include appimage and flatpak package lists
2025-10-24 11:45:10 -07:00

75 lines
2.1 KiB
YAML

---
- name: Ensure yay is installed
block:
- name: Check if yay is already installed
command: which yay
register: yay_check
ignore_errors: yes
tags: [ 'packages', 'yay' ]
- name: Install dependencies for building yay
pacman:
name:
- git
- base-devel
state: present
when: yay_check.rc != 0
tags: [ 'packages', 'yay' ]
- name: Clone yay repository
git:
repo: https://aur.archlinux.org/yay.git
dest: /tmp/yay
clone: yes
update: no
when: yay_check.rc != 0
tags: [ 'packages', 'yay' ]
- name: Build and install yay
command: makepkg -si --noconfirm
args:
chdir: /tmp/yay
when: yay_check.rc != 0
tags: [ 'packages', 'yay' ]
- name: Remove yay build directory
file:
path: /tmp/yay
state: absent
when: yay_check.rc != 0
tags: [ 'packages', 'yay' ]
- name: Install packages from {{ packages_pkglist_file }}
community.general.pacman:
name: "{{ item }}"
state: present
with_lines:
- cat "{{ packages_pkglist_file }}"
tags: [ 'packages', 'pacman' ]
- name: Install AUR packages from {{ packages_aur_pkglist_file }}
command: "yay -S --noconfirm {{ item }}"
with_lines:
- cat "{{ packages_aur_pkglist_file }}"
tags: [ 'packages', 'aur' ]
- name: Install Flatpak packages from {{ packages_flatpak_pkglist_file }}
community.general.flatpak:
name: "{{ item }}"
state: present
with_lines:
- cat "{{ packages_flatpak_pkglist_file }}"
tags: [ 'packages', 'flatpak' ]
- name: Ensure ~/Applications directory exists
ansible.builtin.file:
path: "{{ lookup('env', 'HOME') }}/Applications"
state: directory
mode: "0755"
tags: [ 'packages', 'appimage' ]
- name: Download AppImages from URLs in {{ packages_appimage_pkglist_file }} to ~/Applications
ansible.builtin.get_url:
url: "{{ item }}"
dest: "{{ lookup('env', 'HOME') }}/Applications/{{ item | basename }}"
mode: "0755"
with_lines:
- cat "{{ packages_appimage_pkglist_file }}"
when: item != ""
tags: [ 'packages', 'appimage' ]