# vim: set filetype=yaml.ansible : --- # create all the facts used throughout the role, but shouldn't be touched # by the user - name: Create temporary directory for downloads register: d_tempdir ansible.builtin.file: path: /tmp/ansible_role_package state: directory mode: '0777' - name: Set installation facts ansible.builtin.include_tasks: file: facts.yml - name: Dump paths when: - debug ansible.builtin.debug: msg: "{{ path | dict2items }}" - name: Dump vars when: - debug ansible.builtin.debug: var: ext_become - name: Dump use_local when: - debug ansible.builtin.debug: var: use_local - name: Dump packages when: - debug ansible.builtin.debug: var: packages - name: Ensure directory exists {{ path.prefix }} become: "{{ ext_become }}" ansible.builtin.file: state: directory mode: '0755' path: "{{ path.prefix }}" - name: Ensure directory exists {{ path.bin }} become: "{{ ext_become }}" ansible.builtin.file: state: directory mode: '0755' path: "{{ path.bin }}" - name: Read default package configuration ansible.builtin.include_vars: dir: pkgs extensions: - yml name: pkgconfig - name: Generate package installation lists loop: "{{ packages | unique }}" loop_control: loop_var: pkg ansible.builtin.include_tasks: file: addpkg.yml - name: List wanted packages when: - debug block: - name: List appimages when: - ansible_system == 'Linux' - pkg_appimage|length > 0 ansible.builtin.copy: content: "{{ pkg_appimage | to_nice_json }}" dest: "{{ d_tempdir.path }}/pkg_appimage.yml" mode: '0644' - name: List archives when: - pkg_archive|length > 0 ansible.builtin.copy: content: "{{ pkg_archive | to_nice_json }}" dest: "{{ d_tempdir.path }}/pkg_archive.yml" mode: '0644' - name: List cargo when: - pkg_cargo|length > 0 ansible.builtin.copy: content: "{{ pkg_cargo | to_nice_json }}" dest: "{{ d_tempdir.path }}/pkg_cargo.yml" mode: '0644' - name: List casks when: - ansible_system == 'Darwin' - pkg_cask|length > 0 ansible.builtin.copy: content: "{{ pkg_cask | to_nice_json }}" dest: "{{ d_tempdir.path }}/pkg_cask.yml" mode: '0644' - name: List flatpak remotes when: - ansible_system == 'Linux' - flatpak_remote|length > 0 ansible.builtin.copy: content: "{{ flatpak_remote | to_nice_json }}" dest: "{{ d_tempdir.path }}/flatpak_remote.yml" mode: '0644' - name: List flatpaks when: - ansible_system == 'Linux' - pkg_flatpak|length > 0 ansible.builtin.copy: content: "{{ pkg_flatpak | to_nice_json }}" dest: "{{ d_tempdir.path }}/pkg_flatpak.yml" mode: '0644' - name: List go when: - pkg_go|length > 0 ansible.builtin.copy: content: "{{ pkg_go | to_nice_json }}" dest: "{{ d_tempdir.path }}/pkg_go.yml" mode: '0644' - name: List npm when: - pkg_npm|length > 0 ansible.builtin.copy: content: "{{ pkg_npm | to_nice_json }}" dest: "{{ d_tempdir.path }}/pkg_npm.yml" mode: '0644' - name: List pipx when: - pkg_pipx|length > 0 ansible.builtin.copy: content: "{{ pkg_pipx | to_nice_json }}" dest: "{{ d_tempdir.path }}/pkg_pipx.yml" mode: '0644' - name: List source when: - pkg_src|length > 0 ansible.builtin.copy: content: "{{ pkg_src | to_nice_json }}" dest: "{{ d_tempdir.path }}/pkg_src.yml" mode: '0644' - name: List system when: - pkg_sys|length > 0 ansible.builtin.copy: content: "{{ pkg_sys | to_nice_json }}" dest: "{{ d_tempdir.path }}/pkg_sys.yml" mode: '0644' - name: List homebrew taps when: - ansible_system == 'Darwin' - brewtap|length > 0 ansible.builtin.copy: content: "{{ brewtap | to_nice_json }}" dest: "{{ d_tempdir.path }}/brewtap.yml" mode: '0644' - name: List taps when: - ansible_system == 'Darwin' - pkg_tap|length > 0 ansible.builtin.copy: content: "{{ pkg_tap | to_nice_json }}" dest: "{{ d_tempdir.path }}/pkg_tap.yml" mode: '0644' - name: List snaps when: - ansible_system == 'Linux' - pkg_snap|length > 0 ansible.builtin.copy: content: "{{ pkg_snap | to_nice_json }}" dest: "{{ d_tempdir.path }}/pkg_snap.yml" mode: '0644' - name: Flush handlers to ensure dependencies are installed ansible.builtin.meta: flush_handlers - name: Add needed packages for Fedora when: - ansible_distribution == 'Fedora' ansible.builtin.set_fact: pkg_sys: "{{ pkg_sys + ['python3-paramiko'] }}" - name: Add needed MacOS packages when: - ansible_distribution == 'MacOSX' ansible.builtin.set_fact: pkg_sys: "{{ pkg_sys + ['gnu-tar', 'virtualenv'] }}" - name: Add needed Alpine packages when: - ansible_os_family == 'Alpine' ansible.builtin.set_fact: pkg_sys: "{{ pkg_sys + ['tar', 'unzip'] }}" - name: Install sys_pkgs list using system package manager become: "{{ sys_pkg_become }}" ansible.builtin.package: name: "{{ pkg_sys | unique }}" state: present - name: Linux specific tasks when: - ansible_system == 'Linux' ansible.builtin.include_tasks: file: linux.yml - name: MacOS specific tasks when: - ansible_distribution == 'MacOSX' ansible.builtin.include_tasks: file: macos.yml - name: Install pkg_archive when: - pkg_archive|length > 0 loop: "{{ pkg_archive }}" loop_control: loop_var: pkg ansible.builtin.include_tasks: file: "archive/{{ pkg }}.yml" - name: Install cargo packages when: - pkg_cargo|length > 0 loop: "{{ pkg_cargo | unique }}" loop_control: loop_var: pkg ansible.builtin.include_tasks: file: cargo.yml - name: Install go packages when: - pkg_go|length > 0 loop: "{{ pkg_go | unique }}" loop_control: loop_var: pkg ansible.builtin.include_tasks: file: go.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" - name: Cleanup {{ d_tempdir.path }} when: - not debug ansible.builtin.file: state: absent path: "{{ d_tempdir.path }}"