Add nvm setup
This commit is contained in:
parent
fe9f6788c3
commit
8254bfee9f
4 changed files with 41 additions and 0 deletions
35
tasks/nvm.yml
Normal file
35
tasks/nvm.yml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
- name: create nvm install directory
|
||||
file:
|
||||
path: '{{ nvm.install_dir }}'
|
||||
state: directory
|
||||
|
||||
- name: register the current nvm version
|
||||
shell: 'source {{ nvm.install_dir }}/nvm.sh && nvm --version'
|
||||
register: nvm_stats
|
||||
ignore_errors: true
|
||||
|
||||
- name: parse the current nvm version
|
||||
set_fact:
|
||||
nvm_installed_version: nvm_stats.stdout
|
||||
when: nvm_stats.rc == 0
|
||||
|
||||
- name: download nvm {{ nvm.version }}
|
||||
get_url:
|
||||
url: 'https://raw.githubusercontent.com/nvm-sh/nvm/{{ nvm.version }}/install.sh'
|
||||
dest: '/tmp/nvm-{{ nvm.version }}-install.sh'
|
||||
when: nvm_stats.rc > 0 or nvm_installed_version != nvm.version
|
||||
register: nvm_download
|
||||
|
||||
- name: install nvm {{ nvm.version }}
|
||||
ansible.builtin.command: 'bash /tmp/nvm-{{ nvm.version }}-install.sh'
|
||||
environment:
|
||||
PROFILE: /dev/null
|
||||
NVM_DIR: '{{ nvm.install_dir }}'
|
||||
args:
|
||||
creates: '{{ nvm.install_dir }}/nvm.sh'
|
||||
|
||||
- name: ensure nvm gets loaded
|
||||
lineinfile:
|
||||
path: '{{ ansible_env.HOME }}/.bashrc.override'
|
||||
line: >
|
||||
[ -s "{{ nvm.install_dir }}/nvm.sh" ] && \. "{{ nvm.install_dir }}/nvm.sh" # This loads nvm
|
||||
Loading…
Add table
Add a link
Reference in a new issue