organizing for go pkg installs
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
checksum: "{{ go.sum }}"
|
||||
decompress: false
|
||||
mode: '0644'
|
||||
register: get_url_go
|
||||
|
||||
- name: Ensure go install dir exists
|
||||
become: "{{ sys_pkg_become }}"
|
||||
@@ -25,16 +26,19 @@
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Extract go package
|
||||
become: "{{ sys_pkg_become }}"
|
||||
ansible.builtin.unarchive:
|
||||
dest: "{{ paths.archive }}/go"
|
||||
src: "{{ d_go_dl_tmp.path }}/{{ go_archive }}"
|
||||
remote_src: true
|
||||
when: ansible_system == 'Linux'
|
||||
- name: Extract go package
|
||||
become: "{{ sys_pkg_become }}"
|
||||
when:
|
||||
- ansible_system == 'Linux'
|
||||
ansible.builtin.unarchive:
|
||||
dest: "{{ paths.archive }}/go"
|
||||
src: "{{ d_go_dl_tmp.path }}/{{ go_archive }}"
|
||||
remote_src: true
|
||||
|
||||
- name: Install go macOS use pkg file
|
||||
ansible.builtin.command:
|
||||
cmd: "installer -pkg {{ d_go_dl_tmp.path }}/{{ go_archive }} -target /"
|
||||
when: ansible_system == 'Darwin'
|
||||
become: true
|
||||
- name: Install go macOS use pkg file
|
||||
become: true
|
||||
when:
|
||||
- ansible_system == 'Darwin'
|
||||
ansible.builtin.command:
|
||||
creates: "{{ go.inst_path }}"
|
||||
cmd: "installer -pkg {{ d_go_dl_tmp.path }}/{{ go_archive }} -target /"
|
||||
0
tasks/cargo.yml
Normal file
0
tasks/cargo.yml
Normal file
@@ -4,4 +4,5 @@
|
||||
ansible.builtin.set_fact:
|
||||
air:
|
||||
ver: "{{ pkgconfig.air.version }}"
|
||||
pkg: "{{ pkgconfig.air.git_repo }}@{{ pkgconfig.air.version }}"
|
||||
pkg: "{{ pkgconfig.air.mod_path }}@{{ pkgconfig.air.version }}"
|
||||
bin: "{{ pkgconfig.air.bin }}"
|
||||
|
||||
9
tasks/go.yml
Normal file
9
tasks/go.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: Install go packages
|
||||
become: "{{ archive_become }}"
|
||||
ansible.builtin.command:
|
||||
creates: "{{ paths.bin }}/{{ pkg.bin }}"
|
||||
cmd:
|
||||
- go
|
||||
- install
|
||||
- "{{ pkg.pkg }}"
|
||||
0
tasks/homebrew.yml
Normal file
0
tasks/homebrew.yml
Normal file
133
tasks/main.yml
133
tasks/main.yml
@@ -1,26 +1,63 @@
|
||||
# vim: set filetype=yaml.ansible :
|
||||
---
|
||||
# create all the facts used throughout the role, but shouldn't be touched
|
||||
# by the user
|
||||
- name: Set facts based on use_local == true
|
||||
when:
|
||||
- use_local
|
||||
ansible.builtin.set_fact:
|
||||
paths: "{{ local_paths }}"
|
||||
archive_become: false
|
||||
path_prefix: "{{ lookup(ansible.builtin.env, 'HOME') }}/.local"
|
||||
flatpak_method: user
|
||||
|
||||
- name: Set facts based on use_local == false
|
||||
when:
|
||||
- not use_local
|
||||
ansible.builtin.set_fact:
|
||||
paths: "{{ sys_paths }}"
|
||||
archive_become: true
|
||||
path_prefix: "{{ defaults.path.prefix }}"
|
||||
flatpak_method: system
|
||||
|
||||
- name: Set macOS specific facts
|
||||
when:
|
||||
- ansible_system == 'Darwin'
|
||||
block:
|
||||
- name: Set homebrew bin path
|
||||
ansible.builtin.set_fact:
|
||||
homebrew_bin: "/opt/homebrew/bin"
|
||||
- name: Set other macOS facts
|
||||
ansible.builtin.set_fact:
|
||||
dobecome: "{{ not use_local }}"
|
||||
pipx_exec: "{{ homebrew_bin }}/pipx"
|
||||
sys_pkg_become: false
|
||||
|
||||
- name: Set Linux specific facts
|
||||
when:
|
||||
- ansible_system == 'Linux'
|
||||
block:
|
||||
- name: Set Linux facts
|
||||
ansible.builtin.set_fact:
|
||||
dobecome: "{{ not use_local }}"
|
||||
sys_pkg_become: true
|
||||
|
||||
- name: Set paths
|
||||
ansible.builtin.set_fact:
|
||||
paths:
|
||||
appimage: "{{ appimage_path | default(path_prefix ~ defaults.path.suffix.appimage) }}"
|
||||
archive: "{{ archive_path | default(path_prefix ~ defaults.path.suffix.archive) }}"
|
||||
bin: "{{ bin_path | default(path_prefix ~ defaults.path.suffix.bin) }}"
|
||||
cargo: "{{ cargo_path | default(path_prefix ~ defaults.path.suffix.cargo) }}"
|
||||
go: "{{ goroot | default(path_prefix ~ defaults.path.suffix.go) }}"
|
||||
pipx: "{{ pipx_path | default(path_prefix ~ defaults.path.suffix.pipx) }}"
|
||||
|
||||
- name: Set installation facts
|
||||
ansible.builtin.set_fact:
|
||||
bin_dir: "{{ paths.install }}/bin"
|
||||
state_dir: "{{ paths.install }}/state"
|
||||
# repositories
|
||||
brew_taps: [] # homebrew taps
|
||||
flatpak_remotes: # flatpak remotes, includes flathub by default
|
||||
- name: flathub
|
||||
url: https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
# install lists
|
||||
app_images: [] # app_images to install
|
||||
archive_pkgs: [] # packages installed via prebuilt archive
|
||||
cargo_pkgs: [] # rust packages from cargo
|
||||
cask_pkgs: [] # homebrew casks
|
||||
flatpaks: [] # flatpaks
|
||||
@@ -30,39 +67,16 @@
|
||||
src_pkgs: [] # packages built from source
|
||||
sys_pkgs: [] # system package manager packages
|
||||
tap_pkgs: [] # homebrew tap packages
|
||||
brew_taps: [] # homebrew taps
|
||||
flatpak_remotes: # flatpak remotes, includes flathub by default
|
||||
- name: flathub
|
||||
url: https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
|
||||
- name: Set macOS specific facts
|
||||
when:
|
||||
- ansible_system == 'Darwin'
|
||||
block:
|
||||
- name: Set pipx executable
|
||||
ansible.builtin.set_fact:
|
||||
pipx_exec: /opt/homebrew/bin/pipx
|
||||
- name: Set sys_pkg_become to false for homebrew
|
||||
ansible.builtin.set_fact:
|
||||
sys_pkg_become: false
|
||||
|
||||
- name: Set Linux specific facts
|
||||
when:
|
||||
- ansible_system == 'Linux'
|
||||
block:
|
||||
- name: Set Linux facts
|
||||
ansible.builtin.set_fact:
|
||||
sys_pkg_become: true
|
||||
|
||||
- name: Ensure required paths exist
|
||||
become: "{{ not use_local }}"
|
||||
loop: "{{ paths + [bin_dir, state_dir] }}"
|
||||
become: "{{ dobecome }}"
|
||||
loop: "{{ paths | dict2items }}"
|
||||
loop_control:
|
||||
loop_var: path
|
||||
ansible.builtin.file:
|
||||
state: directory
|
||||
mode: '0755'
|
||||
path: "{{ path }}"
|
||||
path: "{{ path.value }}"
|
||||
|
||||
- name: Read default package configuration
|
||||
ansible.builtin.include_vars:
|
||||
@@ -144,12 +158,10 @@
|
||||
- name: Install flatpaks on Linux Systems
|
||||
when:
|
||||
- ansible_system == 'Linux'
|
||||
- flatpaks|length > 0
|
||||
block:
|
||||
- name: Add flatpak repos
|
||||
when:
|
||||
- flatpak_remotes|length > 0
|
||||
- flatpaks|length > 0
|
||||
become: "{{ not use_local }}"
|
||||
loop: "{{ flatpak_remotes | unique }}"
|
||||
loop_control:
|
||||
@@ -166,61 +178,62 @@
|
||||
loop: "{{ flatpaks | unique }}"
|
||||
loop_control:
|
||||
loop_var: flatpak
|
||||
when:
|
||||
- flatpaks|length > 0
|
||||
community.general.flatpak:
|
||||
state: latest
|
||||
method: "{{ flatpak_method }}"
|
||||
name: "{{ flatpak.name }}"
|
||||
remote: "{{ flatpak.remote | default('flathub') }}"
|
||||
|
||||
- name: Ensure prefix/bin exists
|
||||
ansible.builtin.file:
|
||||
state: directory
|
||||
path: "{{ paths.install }}/bin"
|
||||
owner: root
|
||||
mode: '0755'
|
||||
become: true
|
||||
- name: Install archive_pkgs
|
||||
when:
|
||||
- archive_pkgs|length > 0
|
||||
loop: "{{ archive_pkgs }}"
|
||||
loop_control:
|
||||
loop_var: pkg
|
||||
ansible.builtin.include_tasks:
|
||||
file: "archive/{{ pkg }}.yml"
|
||||
|
||||
- name: Install src_pkgs
|
||||
ansible.builtin.include_tasks:
|
||||
file: "src/{{ src_pkg }}.yml"
|
||||
when:
|
||||
- src_pkgs|length > 0
|
||||
loop: "{{ src_pkgs | unique }}"
|
||||
loop_control:
|
||||
loop_var: src_pkg
|
||||
when: src_pkgs|length > 0
|
||||
loop_var: pkg
|
||||
ansible.builtin.include_tasks:
|
||||
file: "src/{{ pkg }}.yml"
|
||||
|
||||
- name: Install cargo packages at specific version
|
||||
- name: Install cargo packages
|
||||
when:
|
||||
- cargo_pkgs|length > 0
|
||||
become: "{{ not use_local }}"
|
||||
loop: "{{ cargo_pkgs | unique }}"
|
||||
loop_control:
|
||||
loop_var: cargo_pkg
|
||||
loop_var: pkg
|
||||
community.general.cargo:
|
||||
name: "{{ cargo_pkg.cargo.pkg }}"
|
||||
version: "{{ cargo_pkg.ver }}"
|
||||
name: "{{ pkg.cargo.pkg }}"
|
||||
version: "{{ pkg.ver }}"
|
||||
path: "{{ paths.cargo }}"
|
||||
locked: "{{ cargo_pkg.cargo.locked }}"
|
||||
locked: "{{ pkg.cargo.locked }}"
|
||||
|
||||
- name: Install local go packages
|
||||
- name: Install go packages
|
||||
when:
|
||||
- go_pkgs|length > 0
|
||||
loop: "{{ go_pkgs | unique }}"
|
||||
loop_control:
|
||||
loop_var: go_pkg
|
||||
loop_var: pkg
|
||||
environment:
|
||||
GOROOT: "{{ paths.install }}/go"
|
||||
PATH: "{{ paths.install }}/go/bin:$PATH"
|
||||
ansible.builtin.command:
|
||||
cmd: "go install {{ go_pkg }}"
|
||||
# TODO: figure out how to check if the go_pkg is already installed
|
||||
GOBIN: "{{ paths.bin }}"
|
||||
PATH: "{{ paths.go }}/bin:$PATH"
|
||||
ansible.builtin.include_tasks:
|
||||
file: go.yml
|
||||
|
||||
- name: Install local npm packages
|
||||
when:
|
||||
- npm_pkgs|length > 0
|
||||
become: "{{ archive_become }}"
|
||||
loop: "{{ npm_pkgs | unique }}"
|
||||
loop_control:
|
||||
loop_var: npm_pkg
|
||||
when: npm_pkgs|length > 0
|
||||
community.general.npm:
|
||||
global: true
|
||||
name: "{{ npm_pkg }}"
|
||||
|
||||
0
tasks/pipx.yml
Normal file
0
tasks/pipx.yml
Normal file
@@ -4,4 +4,4 @@
|
||||
notify:
|
||||
- Depend go
|
||||
ansible.builtin.set_fact:
|
||||
go_pkgs: "{{ go_pkgs + [air.pkg] }}"
|
||||
go_pkgs: "{{ go_pkgs + [air] }}"
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# vim: set filetype=yaml.ansible :
|
||||
---
|
||||
- name: Append to pkgs
|
||||
- name: Install from archive
|
||||
when:
|
||||
- prefer_archive
|
||||
ansible.builtin.set_fact:
|
||||
src_pkgs: "{{ src_pkgs + ['go'] }}"
|
||||
archive_pkgs: "{{ archive_pkgs + ['go'] }}"
|
||||
|
||||
- name: Append to pkgs
|
||||
when:
|
||||
- not prefer_archive
|
||||
ansible.builtin.set_fact:
|
||||
sys_pkgs: "{{ src_pkgs + ['go'] }}"
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
# vim: set filetype=yaml.ansible :
|
||||
---
|
||||
- ansible.builtin.set_fact:
|
||||
nodejs: true
|
||||
|
||||
- name: append to pkgs
|
||||
- name: Append to pkgs
|
||||
ansible.builtin.set_fact:
|
||||
syspkgs: "{{ syspkgs + pkgconfig.nodejs.pkgs[ansible_system] }}"
|
||||
|
||||
0
tasks/system.yml
Normal file
0
tasks/system.yml
Normal file
Reference in New Issue
Block a user