From c1729dd0e71cbdb6ba9b954538395758a8ec3975 Mon Sep 17 00:00:00 2001 From: Grzegorz Nowak Date: Mon, 14 Jun 2021 12:53:47 +0200 Subject: [PATCH] substantially simplify the way symlinking back to global paths work --- tasks/_symlink.yml | 34 ++++++++++++++-------------------- tasks/main.yml | 1 - 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/tasks/_symlink.yml b/tasks/_symlink.yml index 581f713..240045f 100644 --- a/tasks/_symlink.yml +++ b/tasks/_symlink.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index a4f49a8..8b2d5f9 100755 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -98,5 +98,4 @@ ### ---- Symlink version-agnostic and version-aware global libs - name: Include symlinking routine include: _symlink.yml - loop: "{{ nvm_install_globally }}" ### --------------- END ------------- ####