Skip to content

Commit

Permalink
substantially simplify the way symlinking back to global paths work
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorznowak committed Jun 14, 2021
1 parent 246885f commit c1729dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
34 changes: 14 additions & 20 deletions tasks/_symlink.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
---

# making sure the package's bin actually exists
- name: "Stats over {{ nvm_dir }}/versions/node/v{{ nvm_node_version }}/bin/{{ item.name }}"
stat:
path: "{{ nvm_dir }}/versions/node/v{{ nvm_node_version }}/bin/{{ item.name }}"
register: package_stats_1
when: item.name is defined
- name: Find all the binaries
find:
paths: "{{ nvm_dir }}/versions/node/v{{ nvm_node_version }}/bin"
patterns: '*'
follow: true
file_type: any
register: find_result

- name: Symlink global packages into PATH for specific environments (like cron's) to be able to access them.
file: src="{{ nvm_dir }}/versions/node/v{{ nvm_node_version }}/bin/{{ item.name }}"
dest="/usr/bin/{{ item.name }}" state=link mode="u+rwx,g+rx,o+rx"
when: item.name is defined and package_stats_1.stat.exists

- name: "Stats over {{ nvm_dir }}/versions/node/v{{ nvm_node_version }}/bin/{{ item }}"
stat:
path: "{{ nvm_dir }}/versions/node/v{{ nvm_node_version }}/bin/{{ item }}"
register: package_stats_2
when: item.name is not defined

- name: Symlink global packages into PATH for specific environments (like cron's) to be able to access them.
file: src="{{ nvm_dir }}/versions/node/v{{ nvm_node_version }}/bin/{{ item }}"
dest="/usr/bin/{{ item }}" state=link mode="u+rwx,g+rx,o+rx"
when: item.name is not defined and package_stats_2.stat.exists
file:
src: "{{ item.path }}"
dest: "/usr/bin/{{ item.path | basename }}"
state: link
mode: "u+rwx,g+rx,o+rx"
loop: "{{ find_result.files }}"
changed_when: true
1 change: 0 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,4 @@
### ---- Symlink version-agnostic and version-aware global libs
- name: Include symlinking routine
include: _symlink.yml
loop: "{{ nvm_install_globally }}"
### --------------- END ------------- ####

0 comments on commit c1729dd

Please sign in to comment.