diff --git a/tasks/addpkg.yml b/tasks/addpkg.yml index 1b1ee5b..27b4f2d 100644 --- a/tasks/addpkg.yml +++ b/tasks/addpkg.yml @@ -3,9 +3,23 @@ - name: "Check if task exists for {{ pkg }}" ansible.builtin.stat: path: "{{ role_path }}/tasks/pkgs/{{ pkg }}.yml" - register: cpkg_exists + register: stat_pkg + +- name: "Check if specialized configuration exists for {{ pkg }}" + when: + - stat_pkg.exists + ansible.builtin.stat: + path: "{{ role_path }}/tasks/config/{{ pkg }}.yml" + register: stat_config + +- name: "Load specialized configuration if it exists for {{ pkg }}" + when: + - stat_config.exists + ansible.builtin.include_tasks: + file: "config/{{ pkg }}.yml" - name: "Add include task for {{ pkg }}" - when: cpkg_exists.exists + when: + - stat_pkg.exists ansible.builtin.include_tasks: file: "pkgs/{{ pkg }}.yml" diff --git a/tasks/appimage/bitwarden.yml b/tasks/appimage/bitwarden.yml index 36cc24e..a2b8b5d 100644 --- a/tasks/appimage/bitwarden.yml +++ b/tasks/appimage/bitwarden.yml @@ -10,7 +10,7 @@ ansible.builtin.file: state: directory mode: '0755' - path: "{{ bw_instdir }}" + path: "{{ apimage_pfx }}/bitwarden" owner: "{{ bw_owner }}" group: "{{ bw_group }}" @@ -19,13 +19,13 @@ mode: '0755' decompress: false backup: true - url: bw_appimg.url - dest: "{{ bw_instdir }}/{{ bw_appimg.name }}" + url: "{{ bw.appimg.url }}" + dest: "{{ appimage_pfx }}/{{ bw.appimg.name }}" owner: "{{ bw_owner }}" group: "{{ bw_group }}" - name: Link bitwarden appimage ansible.builtin.file: state: link - src: "{{ bw_instdir }}/{{ bw_appimg.name }}" - path: "{{ bw_instpfx }}/bin/bitwarden" + src: "{{ appimage_pfx }}/{{ bw.appimg.name }}" + path: "{{ bw.bindir }}/bitwarden" diff --git a/tasks/appimage/neovim.yml b/tasks/appimage/neovim.yml new file mode 100644 index 0000000..4b6b623 --- /dev/null +++ b/tasks/appimage/neovim.yml @@ -0,0 +1,29 @@ +# vim: set filetype=yaml.ansible : +--- +- name: Install neovim appimage + become: true + block: + - name: Create install dir + ansible.builin.file: + state: directory + mode: "0755" + path: "{{ nvim.instdir }}" + owner: "{{ pkgconfig_neovim.owner }}" + group: "{{ pkgconfig_neovim.group }}" + + - name: Get neovim appimage + ansible.builtin.get_url: + mode: "0755" + decompress: false + backup: true + url: "{{ pkgconfig_neovim.appimage_url_pfx }}/{{ pkgconfig_neovim.version }}/nvim.appimage" + checksum: "sha256:{{ pkgconfig_neovim.appimage_url_pfx }}/{{ pkgconfig_neovim.version }}/nvim.appimage.sha256sum" + dest: "{{ pkgconfig_neovim.install_dir }}/nvim.appimage.{{ pkgconfig_neovim.version }}" + owner: "{{ pkgconfig_neovim.owner }}" + group: "{{ pkgconfig_neovim.group }}" + + - name: Link neovim appimage + ansible.builtin.file: + state: link + src: "{{ pkgconfig_neovim.install_dir }}/nvim.appimage.{{ pkgconfig_neovim.version }}" + path: "{{ pkgconfig_neovim.install_prefix }}/bin/nvim" diff --git a/tasks/build/neovim.yml b/tasks/build/neovim.yml deleted file mode 100644 index 2886bb7..0000000 --- a/tasks/build/neovim.yml +++ /dev/null @@ -1,55 +0,0 @@ -# vim: set filetype=yaml.ansible : ---- -- name: build neovim from source - block: - - name: create temp path - ansible.builtin.tempfile: - state: directory - prefix: nvim. - register: d_nvim_tmp - - - name: clone neovim git repository - ansible.builtin.git: - depth: 1 - dest: "{{ d_nvim_tmp.path }}/neovim" - repo: "{{ pkgconfig_neovim.git_repo }}" - version: "{{ pkgconfig_neovim.version }}" - - - name: build and install neovim - ansible.builtin.make: - chdir: "{{ d_nvim_tmp.path }}/neovim" - params: - CMAKE_BUILD_TYPE: "{{ pkgconfig_neovim.build_type }}" - CMAKE_INSTALL_PREFIX: "{{ pkgconfig_neovim.install_prefix }}" - target: install - become: "{{ pkgconfig_neovim.dobecome }}" - become_user: "{% if pkgconfig_neovim.dobecome %}{{ pkgconfig_neovim.owner }}{% else %}~{% endif %}" - when: not pkgconfig_neovim.use_appimage - -- name: install neovim appimage - block: - - ansible.builin.file: - state: directory - mode: "0755" - path: "{{ pkgconfig_neovim.install_dir }}" - owner: "{{ pkgconfig_neovim.owner }}" - group: "{{ pkgconfig_neovim.group }}" - - - ansible.builtin.get_url: - mode: "0755" - decompress: false - backup: true - url: "{{ pkgconfig_neovim.appimage_url_pfx }}/{{ pkgconfig_neovim.version }}/nvim.appimage" - checksum: "sha256:{{ pkgconfig_neovim.appimage_url_pfx }}/{{ pkgconfig_neovim.version }}/nvim.appimage.sha256sum" - dest: "{{ pkgconfig_neovim.install_dir }}/nvim.appimage.{{ pkgconfig_neovim.version }}" - owner: "{{ pkgconfig_neovim.owner }}" - group: "{{ pkgconfig_neovim.group }}" - - - ansible.builtin.file: - state: link - src: "{{ pkgconfig_neovim.install_dir }}/nvim.appimage.{{ pkgconfig_neovim.version }}" - path: "{{ pkgconfig_neovim.install_prefix }}/bin/nvim" - when: - - pkgconfig_neovim.use_appimage - become: "{{ pkgconfig_neovim.dobecome }}" - become_user: "{% if pkgconfig_neovim.dobecome %}{{ pkgconfig_neovim.owner }}{% else %}~{% endif %}" diff --git a/vars/alacritty.yml b/tasks/config/alacritty.yml similarity index 100% rename from vars/alacritty.yml rename to tasks/config/alacritty.yml diff --git a/vars/bitwarden.yml b/tasks/config/bitwarden.yml similarity index 80% rename from vars/bitwarden.yml rename to tasks/config/bitwarden.yml index 8de3209..fc69046 100644 --- a/vars/bitwarden.yml +++ b/tasks/config/bitwarden.yml @@ -1,7 +1,6 @@ # vim: set filetype=yaml.ansible : --- install_prefix: "{{ default_install_prefix }}" -install_dir: /opt/appimage/bitwarden install_method: flatpak dobecome: true owner: root diff --git a/vars/carapace.yml b/tasks/config/carapace.yml similarity index 100% rename from vars/carapace.yml rename to tasks/config/carapace.yml diff --git a/vars/ghostty.yml b/tasks/config/ghostty.yml similarity index 100% rename from vars/ghostty.yml rename to tasks/config/ghostty.yml diff --git a/vars/go.yml b/tasks/config/go.yml similarity index 100% rename from vars/go.yml rename to tasks/config/go.yml diff --git a/vars/libreoffice.yml b/tasks/config/libreoffice.yml similarity index 100% rename from vars/libreoffice.yml rename to tasks/config/libreoffice.yml diff --git a/vars/lua-language-server.yml b/tasks/config/lua-language-server.yml similarity index 100% rename from vars/lua-language-server.yml rename to tasks/config/lua-language-server.yml diff --git a/vars/neovide.yml b/tasks/config/neovide.yml similarity index 100% rename from vars/neovide.yml rename to tasks/config/neovide.yml diff --git a/vars/neovim.yml b/tasks/config/neovim.yml similarity index 83% rename from vars/neovim.yml rename to tasks/config/neovim.yml index 7b9cfd6..4e11e56 100644 --- a/vars/neovim.yml +++ b/tasks/config/neovim.yml @@ -3,8 +3,7 @@ version: v0.10.3 install_prefix: "{{ default_install_prefix }}" install_dir: /opt/nvim -use_appimage: true -use_syspkg: true +install_method: appimage build_type: Release dobecome: true owner: root diff --git a/vars/nerdfonts.yml b/tasks/config/nerdfonts.yml similarity index 100% rename from vars/nerdfonts.yml rename to tasks/config/nerdfonts.yml diff --git a/vars/nushell.yml b/tasks/config/nushell.yml similarity index 100% rename from vars/nushell.yml rename to tasks/config/nushell.yml diff --git a/vars/rust.yml b/tasks/config/rust.yml similarity index 100% rename from vars/rust.yml rename to tasks/config/rust.yml diff --git a/vars/zig.yml b/tasks/config/zig.yml similarity index 100% rename from vars/zig.yml rename to tasks/config/zig.yml diff --git a/vars/zls.yml b/tasks/config/zls.yml similarity index 100% rename from vars/zls.yml rename to tasks/config/zls.yml diff --git a/tasks/main.yml b/tasks/main.yml index 8e41c8a..a298f1e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,24 @@ # vim: set filetype=yaml.ansible : --- +- name: Set installation facts + ansible.builtin.set_fact: + paths: "{% if use_local %}{{ localpaths }}{% else %}{{ syspaths }}{% endif %}" + appimages: [] # appimages to install + cargopkgs: [] # rust packages from cargo + cargoversioned: [] # versioned rust packages from cargo + caskpkgs: [] # homebrew casks + flatpkgs: [] # flatpaks + gopkgs: [] # go applications + npmpkgs: [] # npm commands + pipxpkgs: [] # pipx packages + srcpkgs: [] # packages built from source + syspkgs: [] # system package manager packages + tappkgs: [] # homebrew tap packages + brewtaps: [] # homebrew taps + fpremotes: # flatpak remotes + - name: flathub + url: https://dl.flathub.org/repo/flathub.flatpakrepo + - name: Determine OS and set facts for it block: - name: Set macOS facts @@ -125,7 +144,7 @@ - name: Install srcpkgs ansible.builtin.include_tasks: - file: "build/{{ srcpkg }}.yml" + file: "src/{{ srcpkg }}.yml" loop: "{{ srcpkgs | unique }}" loop_control: loop_var: srcpkg diff --git a/tasks/pkgs/bitwarden.yml b/tasks/pkgs/bitwarden.yml index fea2689..ee91dd8 100644 --- a/tasks/pkgs/bitwarden.yml +++ b/tasks/pkgs/bitwarden.yml @@ -12,14 +12,14 @@ - name: Set bitwarden facts ansible.builtin.set_fact: bw: - appimg: pkgconfig_bitwarden.appimage - become: pkgconfig_bitwarden.dobecome - flatpak: pkgconfig_bitwarden.flatpak - group: pkgconfig_bitwarden.group - instdir: pkgconfig_bitwarden.install_dir - instmtd: pkgconfig_bitwarden.install_method - instpfx: pkgconfig_bitwarden.install_prefix - owner: pkgconfig_bitwarden.owner + appimg: "{{ pkgconfig_bitwarden.appimage }}" + become: "{{ pkgconfig_bitwarden.dobecome }}" + flatpak: "{{ pkgconfig_bitwarden.flatpak }}" + group: "{{ pkgconfig_bitwarden.group }}" + instdir: "{{ pkgconfig_bitwarden.install_dir }}" + instmtd: "{{ pkgconfig_bitwarden.install_method }}" + bindir: "{{ pkgconfig_bitwarden.install_prefix }}/bin" + owner: "{{ pkgconfig_bitwarden.owner }}" - name: Append to flatpkgs when: diff --git a/tasks/pkgs/hashicorp_repo.yml b/tasks/pkgs/hashicorp_repo.yml index 4309599..35534d6 100644 --- a/tasks/pkgs/hashicorp_repo.yml +++ b/tasks/pkgs/hashicorp_repo.yml @@ -1,12 +1,14 @@ # vim: set filetype=yaml.ansible : --- -- ansible.builtin.set_fact: +- name: Set hashicorp flag + ansible.builtin.set_fact: hashicorp: true - name: RedHat repository - when: ansible_os_family == 'RedHat' + when: + - ansible_os_family == 'RedHat' block: - - name: enable hashicorp repo for fedora >=41 + - name: Enable hashicorp repo for fedora >=41 become: true when: - ansible_distribution == 'Fedora' @@ -15,7 +17,7 @@ creates: /etc/yum.repos.d/hashicorp.repo cmd: "dnf config-manager addrepo --from-repofile={{ pkgconfig.hashicorp.Linux.Fedora.repo }}" - - name: enable hashicorp repo for fedora <41 + - name: Enable hashicorp repo for fedora <41 become: true when: - ansible_distribution == 'Fedora' @@ -24,7 +26,7 @@ creates: /etc/yum.repos.d/hashicorp.repo cmd: "dnf config-manager --add-repo {{ pkgconfig.hashicorp.Linux.Fedora.repo }}" - - name: enable hashicorp repo for RHEL like distribution + - name: Enable hashicorp repo for RHEL like distribution become: true when: - ansible_distribution != 'Fedora' @@ -33,21 +35,25 @@ cmd: "dnf config-manager --add-repo {{ pkgconfig.hashicorp.Linux.RedHat.repo }}" - name: Debian based repository - when: ansible_os_family == 'Debian' + when: + - ansible_os_family == 'Debian' block: - - ansible.builtin.tempfile: + - name: Create temporary directory + ansible.builtin.tempfile: state: directory prefix: hashicorp. register: d_hashicorp_tmp - - name: get hashicorp archive gpg key + - name: Get hashicorp archive gpg key ansible.builtin.get_url: dest: "{{ d_hashicorp_tmp.path }}/gpg" url: https://apt.releases.hashicorp.com/gpg + mode: '0644' - - name: install hashicorp archive gpg key + - name: Install hashicorp archive gpg key become: true ansible.builtin.command: + creates: /usr/share/keyrings/hashicorp-archive-keyring.gpg cmd: - gpg - --dearmor @@ -55,13 +61,17 @@ - /usr/share/keyrings/hashicorp-archive-keyring.gpg - "{{ d_hashicorp_tmp.path }}/gpg" - - name: enable hasicorp repo for debian + - name: Enable hasicorp repo for debian ansible.builtin.apt_repository: repo: "{{ pkgconfig.hashicorp.Linux.Debian.repo }}" state: present update_cache: false -- name: enable hashicorp homebrew tap - when: ansible_os_family == 'Darwin' - ansible.builtin.set_fact: - brewtaps: "{{ brewtaps + ['hashicorp/tap'] }}" +- name: MacOS specific configuration + when: + - ansible_distribution == 'MacOSX' + block: + - name: Enable hashicorp homebrew tap + when: ansible_os_family == 'Darwin' + ansible.builtin.set_fact: + brewtaps: "{{ brewtaps + ['hashicorp/tap'] }}" diff --git a/tasks/pkgs/neovim.yml b/tasks/pkgs/neovim.yml index d5553f0..737dd68 100644 --- a/tasks/pkgs/neovim.yml +++ b/tasks/pkgs/neovim.yml @@ -1,17 +1,50 @@ # vim: set filetype=yaml.ansible : --- -- ansible.builtin.include_vars: +- name: Load neovim config + ansible.builtin.include_vars: file: neovim.yml name: _neovim -- ansible.builtin.set_fact: + +- name: Combine neovim default and user config + ansible.builtin.set_fact: pkgconfig_neovim: "{{ _neovim | ansible.builtin.combine(pkgconfig.neovim) }}" -- name: append neovim to srcpkgs +- name: Set neovim facts ansible.builtin.set_fact: - srcpkgs: "{{ srcpkgs + ['neovim'] }}" - when: not pkgconfig_neovim.use_syspkg + nvim: + appimg: "{{ pkgconfig_neovim.appimage }}" + become: "{{ pkgconfig_neovim.dobecome }}" + bldtype: "{{ pkgconfig_neovim.build_type }}" + group: "{{ pkgconfig_neovim.group }}" + instdir: "{{ pkgconfig_neovim.install_dir }}" + instmtd: "{{ pkgconfig_neovim.install_method }}" + instpfx: "{{ pkgconfig_neovim.install_prefix }}" + owner: "{{ pkgconfig_neovim.owner }}" + ver: "{{ pkgconfig_neovim.version }}" -- name: append neovim to syspkgs +- name: Linux specific install + when: + - ansible_system == 'Linux' + block: + # install system package when on an up to date distro + - name: Append to syspkgs + when: + - (ansible_distribution == 'Fedora') or + (ansible_distribution == 'Ubuntu') + + - name: Append to appimages + when: + - nvim.instmtd == 'appimage' + ansible.builtin.set_fact: + appimages: "{{ appimages + ['neovim'] }}" +- name: Append neovim to syspkgs + when: + - ansible_os_family == 'Darwin' ansible.builtin.set_fact: syspkgs: "{{ syspkgs + ['neovim'] }}" - when: pkgconfig_neovim.use_syspkg + +- name: Append neovim to srcpkgs + when: + - nvim.instmtd == 'source' + ansible.builtin.set_fact: + srcpkgs: "{{ srcpkgs + ['neovim'] }}" diff --git a/tasks/build/alacritty.yml b/tasks/src/alacritty.yml similarity index 100% rename from tasks/build/alacritty.yml rename to tasks/src/alacritty.yml diff --git a/tasks/build/ghostty.yml b/tasks/src/ghostty.yml similarity index 100% rename from tasks/build/ghostty.yml rename to tasks/src/ghostty.yml diff --git a/tasks/build/go.yml b/tasks/src/go.yml similarity index 100% rename from tasks/build/go.yml rename to tasks/src/go.yml diff --git a/tasks/build/lua-language-server.yml b/tasks/src/lua-language-server.yml similarity index 100% rename from tasks/build/lua-language-server.yml rename to tasks/src/lua-language-server.yml diff --git a/tasks/build/neovide.yml b/tasks/src/neovide.yml similarity index 100% rename from tasks/build/neovide.yml rename to tasks/src/neovide.yml diff --git a/tasks/src/neovim.yml b/tasks/src/neovim.yml new file mode 100644 index 0000000..3dc44e9 --- /dev/null +++ b/tasks/src/neovim.yml @@ -0,0 +1,25 @@ +# vim: set filetype=yaml.ansible : +--- +- name: Create temp path + ansible.builtin.tempfile: + state: directory + prefix: nvim. + register: d_nvim_tmp + +- name: Clone neovim git repository + ansible.builtin.git: + depth: 1 + dest: "{{ d_nvim_tmp.path }}/neovim" + repo: "{{ pkgconfig_neovim.git_repo }}" + version: "{{ pkgconfig_neovim.version }}" + +- name: Build and install neovim + ansible.builtin.make: + chdir: "{{ d_nvim_tmp.path }}/neovim" + params: + CMAKE_BUILD_TYPE: "{{ pkgconfig_neovim.build_type }}" + CMAKE_INSTALL_PREFIX: "{{ pkgconfig_neovim.install_prefix }}" + target: install + become: "{{ pkgconfig_neovim.dobecome }}" + become_user: "{% if pkgconfig_neovim.dobecome %}{{ pkgconfig_neovim.owner }}{% else %}~{% endif %}" + when: not pkgconfig_neovim.use_appimage diff --git a/tasks/build/nerdfonts.yml b/tasks/src/nerdfonts.yml similarity index 100% rename from tasks/build/nerdfonts.yml rename to tasks/src/nerdfonts.yml diff --git a/tasks/build/nushell.yml b/tasks/src/nushell.yml similarity index 100% rename from tasks/build/nushell.yml rename to tasks/src/nushell.yml diff --git a/tasks/build/zig.yml b/tasks/src/zig.yml similarity index 100% rename from tasks/build/zig.yml rename to tasks/src/zig.yml diff --git a/tasks/build/zls.yml b/tasks/src/zls.yml similarity index 100% rename from tasks/build/zls.yml rename to tasks/src/zls.yml diff --git a/vars/main.yml b/vars/main.yml index 1f3ac18..90b4ce3 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,30 +1,20 @@ # vim: set filetype=yaml.ansible : # variables used in ansible_role_package --- -default_install_prefix: /usr/local +localpaths: # all localpaths are prefixed with the users $HOME directory + instrall: .local + appimage: .local/appimage + archive: .local/archive + cache: .cache + +syspaths: # if installing at a system level (default) + install: /usr/local # executables get linked to {{ default_install_prefix }}/bin + appimage: /opt/appimage # appimages are installed to {{ apimage_install_prefix }}// + archive: /opt/archive # pre-compiled archives are extracted to {{ archive_install_prefix }}/ + cache: /opt/archive/.cache # download archives here + packages: [] # list of packages to install -# Package install lists -appimages: [] # appimages to install -cargopkgs: [] # rust packages from cargo -cargoversioned: [] # versioned rust packages from cargo -caskpkgs: [] # homebrew casks -flatpkgs: [] # flatpaks -gopkgs: [] # go applications -npmpkgs: [] # npm commands -pipxpkgs: [] # pipx packages -srcpkgs: [] # packages built from source -syspkgs: [] # system package manager packages -tappkgs: [] # homebrew tap packages - -# Package source lists -brewtaps: [] # homebrew taps -fpremotes: # flatpak remotes - - name: flathub - url: https://dl.flathub.org/repo/flathub.flatpakrepo - -# Static package configuration -# this shouldn't be changed by the user pkgconfig: alacritty: build_deps: