Files
ansible_role_package/tasks/main.yml
2026-02-11 10:50:48 -07:00

239 lines
5.7 KiB
YAML

# vim: set filetype=yaml.ansible :
---
- name: Show indev warning
ansible.builtin.debug:
msg: "This software is in development. Use at your own risk"
- name: Set installation facts
ansible.builtin.include_tasks:
file: facts.yml
- name: Create cache directory
register: d_cache
ansible.builtin.file:
path: "{{ store_path }}"
mode: '0755'
owner: "{{ ansible_facts['user_id'] }}"
group: "{{ ansible_facts['user_gid'] }}"
state: directory
- name: Ensure required paths exists
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
loop:
- "{{ install_prefix }}"
- "{{ path_appimage }}"
- "{{ path_archive }}"
- "{{ path_bin }}"
- "{{ path_cargo }}"
- "{{ path_git }}"
- "{{ path_pipx }}"
loop_control:
loop_var: path
ansible.builtin.file:
state: directory
mode: '0755'
owner: "{{ install_prefix_owner }}"
group: "{{ install_prefix_group }}"
path: "{{ path }}"
- name: Read package configuration
ansible.builtin.include_vars:
file: pkglist.yml
- name: Add needed packages for Fedora
when:
- ansible_facts["distribution"] == 'Fedora'
ansible.builtin.set_fact:
pkg_sys: "{{ packages_extra + ['python3-paramiko'] }}"
- name: Add needed MacOS packages
when:
- ansible_facts["distribution"] == 'MacOSX'
ansible.builtin.set_fact:
pkg_sys: "{{ packages_extra + ['gnu-tar', 'virtualenv'] }}"
- name: Add needed Alpine packages
when:
- ansible_os_family == 'Alpine'
ansible.builtin.set_fact:
pkg_sys: "{{ packages_extra + ['tar', 'unzip'] }}"
- name: Append extra packages to system install list
ansible.builtin.set_fact:
pkg_sys: "{{ pkg_sys + packages_extra }}"
- name: Generate package installation lists
loop: "{{ packages | unique }}"
loop_control:
loop_var: pkg
ansible.builtin.include_tasks:
file: "pkgs/{{ pkg }}.yml"
- name: Install go if required
when:
- pkg_go|length > 0
ansible.builtin.include_tasks:
file: pkgs/go.yml
- name: Install rust and cargo if required
when:
- pkg_cargo|length > 0 or
pkg_cargo_build|length > 0
ansible.builtin.include_tasks:
file: pkgs/rust.yml
- name: Ensure pipx is installed
when:
- pkg_pipx|length > 0
block:
- name: Queue pipx install
ansible.builtin.include_tasks:
file: pkgs/pipx.yml
- name: Ensure pipx path exists
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
ansible.builtin.file:
state: directory
mode: '0755'
path: "{{ path_pipx }}"
- name: Ensure nodejs and npm are installed
when:
- pkg_npm|length > 0
ansible.builtin.include_tasks:
file: pkgs/nodejs.yml
- name: Ensure flatpak is installed
when:
- pkg_flatpak is defined
- pkg_flatpak|length > 0
ansible.builtin.include_tasks:
file: pkgs/flatpak.yml
- name: Ensure appimage path exists
when:
- pkg_appimage is defined
- pkg_appimage|length > 0
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
ansible.builtin.file:
state: directory
mode: '0755'
path: "{{ path_appimage }}"
- name: Ensure archive path exists
when:
- pkg_archive|length > 0
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
ansible.builtin.file:
state: directory
mode: '0755'
path: "{{ path_archive }}"
- name: Depend zig
when:
- pkg_zig|length > 0
ansible.builtin.include_tasks:
file: pkgs/zig.yml
- name: Install pkg_sys list using system package manager
when:
- pkg_sys|length > 0
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
ansible.builtin.package:
name: "{{ pkg_sys | unique }}"
state: present
- name: Install pkg_archive
when:
- pkg_archive|length > 0
loop: "{{ pkg_archive }}"
loop_control:
loop_var: archive
ansible.builtin.include_tasks:
file: helpers/archive.yml
- name: Linux specific tasks
when:
- ansible_facts["system"] == 'Linux'
ansible.builtin.include_tasks:
file: linux.yml
- name: MacOS specific tasks
when:
- ansible_facts["distribution"] == 'MacOSX'
ansible.builtin.include_tasks:
file: macos.yml
- name: Install cargo packages
when:
- pkg_cargo|length > 0
block:
- name: Ensure cargo path exists
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
ansible.builtin.file:
state: directory
mode: '0755'
path: "{{ path_cargo }}"
- name: Install cargo packages
loop: "{{ pkg_cargo | unique }}"
loop_control:
loop_var: cargo
ansible.builtin.include_tasks:
file: helpers/cargo.yml
- name: Build and install rust apps
when:
- pkg_cargo_build|length > 0
block:
- name: Run cargo build and install
loop: "{{ cargo_pkg_build }}"
loop_control:
loop_var: cargo_build
ansible.builtin.include_tasks:
file: helpers/cargo_build.yml
- name: Install go packages
when:
- pkg_go|length > 0
block:
- name: Install go pkgs
loop: "{{ pkg_go }}"
loop_control:
loop_var: pkg
ansible.builtin.include_tasks:
file: helpers/go_install.yml
- name: Install local npm packages
when:
- pkg_npm|length > 0
loop: "{{ pkg_npm | unique }}"
loop_control:
loop_var: pkg
ansible.builtin.include_tasks:
file: npm.yml
- name: Install python pipx packages for user
when:
- pkg_pipx|length > 0
loop: "{{ pkg_pipx | unique }}"
loop_control:
loop_var: pkg
ansible.builtin.include_tasks:
file: pipx.yml
- name: Build and install source packages
when:
- pkg_src|length > 0
loop: "{{ pkg_src | unique }}"
loop_control:
loop_var: pkg
ansible.builtin.include_tasks:
file: "src/{{ pkg }}.yml"