@@ -13,13 +13,28 @@
|
||||
mode: "0755"
|
||||
become: false
|
||||
|
||||
- name: Scan utils folder and create symlinks in ~/.local/bin
|
||||
- name: Scan utils folder for files
|
||||
ansible.builtin.find:
|
||||
paths: "{{ dotfiles_path }}/config/ansible/tasks/global/utils"
|
||||
file_type: file
|
||||
register: utils_files
|
||||
become: false
|
||||
|
||||
- name: Scan utils folder for Go projects (directories with go.mod)
|
||||
ansible.builtin.find:
|
||||
paths: "{{ dotfiles_path }}/config/ansible/tasks/global/utils"
|
||||
file_type: directory
|
||||
recurse: true
|
||||
register: utils_dirs
|
||||
become: false
|
||||
|
||||
- name: Filter directories that contain go.mod files
|
||||
ansible.builtin.stat:
|
||||
path: "{{ item.path }}/go.mod"
|
||||
loop: "{{ utils_dirs.files }}"
|
||||
register: go_mod_check
|
||||
become: false
|
||||
|
||||
- name: Create symlinks for utils scripts
|
||||
ansible.builtin.file:
|
||||
src: "{{ item.path }}"
|
||||
@@ -29,11 +44,19 @@
|
||||
when: not item.path.endswith('.go')
|
||||
become: false
|
||||
|
||||
- name: Compile Go files and place binaries in ~/.local/bin
|
||||
- name: Compile standalone Go files and place binaries in ~/.local/bin
|
||||
ansible.builtin.command:
|
||||
cmd: go build -o "{{ ansible_env.HOME }}/.local/bin/{{ item.path | basename | regex_replace('\.go$', '') }}" "{{ item.path }}"
|
||||
loop: "{{ utils_files.files }}"
|
||||
when: item.path.endswith('.go')
|
||||
become: false
|
||||
|
||||
- name: Compile Go projects and place binaries in ~/.local/bin
|
||||
ansible.builtin.command:
|
||||
cmd: go build -o "{{ ansible_env.HOME }}/.local/bin/{{ item.item.path | basename }}" .
|
||||
chdir: "{{ item.item.path }}"
|
||||
loop: "{{ go_mod_check.results }}"
|
||||
when: item.stat.exists
|
||||
become: false
|
||||
tags:
|
||||
- utils
|
||||
|
Reference in New Issue
Block a user