Workout the nvm install role
Signed-off-by: Noah Knegt <git@noahknegt.com>
This commit is contained in:
13
roles/nvm/tasks/check_installed.yml
Normal file
13
roles/nvm/tasks/check_installed.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
# ===================================================================================================
|
||||
# ? ABOUT
|
||||
# @author : Noah Knegt
|
||||
# @email : personal@noahknegt.com
|
||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
||||
# @createdOn : 06-04-2023
|
||||
# @description : This will check if nvm is installed as the latest version.
|
||||
# ===================================================================================================
|
||||
|
||||
---
|
||||
- name: Check nvm version
|
||||
shell: nvm --version
|
||||
register: nvm_version
|
22
roles/nvm/tasks/cleanup.yml
Normal file
22
roles/nvm/tasks/cleanup.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
# ===================================================================================================
|
||||
# ? ABOUT
|
||||
# @author : Noah Knegt
|
||||
# @email : personal@noahknegt.com
|
||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
||||
# @createdOn : 06-04-2023
|
||||
# @description : This will cleanup the system.
|
||||
# ===================================================================================================
|
||||
|
||||
---
|
||||
- name: Cleanup
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- /tmp/nvm-install.sh
|
||||
- /tmp/nvm-install.log
|
||||
- /tmp/nvm-install.out
|
||||
- /tmp/nvm-install.err
|
||||
- /tmp/nvm-install.debug
|
||||
- /tmp/nvm-install.info
|
||||
- /tmp/nvm-install.warn
|
16
roles/nvm/tasks/download.yml
Normal file
16
roles/nvm/tasks/download.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
# ===================================================================================================
|
||||
# ? ABOUT
|
||||
# @author : Noah Knegt
|
||||
# @email : personal@noahknegt.com
|
||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
||||
# @createdOn : 06-04-2023
|
||||
# @description : This will download the nvm install script.
|
||||
# ===================================================================================================
|
||||
|
||||
---
|
||||
- name: Download nvm
|
||||
get_url:
|
||||
url: https://raw.githubusercontent.com/nvm-sh/nvm/{{ nvm_latest_version.stdout }}/install.sh
|
||||
dest: /tmp/nvm-install.sh
|
||||
mode: 0755
|
||||
when: nvm_version.stdout != nvm_latest_version.stdout
|
13
roles/nvm/tasks/get_version.yml
Normal file
13
roles/nvm/tasks/get_version.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
# ===================================================================================================
|
||||
# ? ABOUT
|
||||
# @author : Noah Knegt
|
||||
# @email : personal@noahknegt.com
|
||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
||||
# @createdOn : 06-04-2023
|
||||
# @description : This will get the latest version of nvm.
|
||||
# ===================================================================================================
|
||||
|
||||
---
|
||||
- name: Get the latest nvm version
|
||||
shell: curl -s https://api.github.com/repos/nvm-sh/nvm/releases/latest | grep tag_name | cut -d '"' -f 4
|
||||
register: nvm_latest_version
|
15
roles/nvm/tasks/install.yml
Normal file
15
roles/nvm/tasks/install.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
# ===================================================================================================
|
||||
# ? ABOUT
|
||||
# @author : Noah Knegt
|
||||
# @email : personal@noahknegt.com
|
||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
||||
# @createdOn : 06-04-2023
|
||||
# @description : This will install nvm as the latest version.
|
||||
# ===================================================================================================
|
||||
|
||||
---
|
||||
- name: Install nvm
|
||||
shell: /tmp/nvm-install.sh
|
||||
args:
|
||||
creates: /home/noahk/.nvm
|
||||
when: nvm_version.stdout != nvm_latest_version.stdout
|
@@ -1,2 +1,9 @@
|
||||
---
|
||||
# tasks file for nvm
|
||||
- import_tasks: check_installed.yml
|
||||
- import_tasks: get_version.yml
|
||||
|
||||
- import_tasks: download.yml
|
||||
|
||||
- import_tasks: install.yml
|
||||
|
||||
- import_tasks: cleanup.yml
|
||||
|
Reference in New Issue
Block a user