diff --git a/roles/nvm/defaults/main.yml b/roles/nvm/defaults/main.yml new file mode 100644 index 0000000..e7c5d9b --- /dev/null +++ b/roles/nvm/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for nvm diff --git a/roles/nvm/files/temp b/roles/nvm/files/temp new file mode 100644 index 0000000..e69de29 diff --git a/roles/nvm/handlers/main.yml b/roles/nvm/handlers/main.yml new file mode 100644 index 0000000..a1ed161 --- /dev/null +++ b/roles/nvm/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for nvm diff --git a/roles/nvm/tasks/check_installed.yml b/roles/nvm/tasks/check_installed.yml new file mode 100644 index 0000000..34971a9 --- /dev/null +++ b/roles/nvm/tasks/check_installed.yml @@ -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 diff --git a/roles/nvm/tasks/cleanup.yml b/roles/nvm/tasks/cleanup.yml new file mode 100644 index 0000000..931ba78 --- /dev/null +++ b/roles/nvm/tasks/cleanup.yml @@ -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 diff --git a/roles/nvm/tasks/download.yml b/roles/nvm/tasks/download.yml new file mode 100644 index 0000000..ec8c827 --- /dev/null +++ b/roles/nvm/tasks/download.yml @@ -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 diff --git a/roles/nvm/tasks/get_version.yml b/roles/nvm/tasks/get_version.yml new file mode 100644 index 0000000..6aa1ccf --- /dev/null +++ b/roles/nvm/tasks/get_version.yml @@ -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 diff --git a/roles/nvm/tasks/install.yml b/roles/nvm/tasks/install.yml new file mode 100644 index 0000000..5e0c9e9 --- /dev/null +++ b/roles/nvm/tasks/install.yml @@ -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 diff --git a/roles/nvm/tasks/main.yml b/roles/nvm/tasks/main.yml new file mode 100644 index 0000000..f85affb --- /dev/null +++ b/roles/nvm/tasks/main.yml @@ -0,0 +1,9 @@ +--- +- import_tasks: check_installed.yml +- import_tasks: get_version.yml + +- import_tasks: download.yml + +- import_tasks: install.yml + +- import_tasks: cleanup.yml diff --git a/roles/nvm/templates/temp.j2 b/roles/nvm/templates/temp.j2 new file mode 100644 index 0000000..e69de29 diff --git a/roles/nvm/tests/inventory b/roles/nvm/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/nvm/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/nvm/tests/test.yml b/roles/nvm/tests/test.yml new file mode 100644 index 0000000..a57e3ac --- /dev/null +++ b/roles/nvm/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - nvm diff --git a/roles/nvm/vars/main.yml b/roles/nvm/vars/main.yml new file mode 100644 index 0000000..4bbfd66 --- /dev/null +++ b/roles/nvm/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for nvm diff --git a/site.yml b/site.yml index ef6ea14..1cde4a0 100644 --- a/site.yml +++ b/site.yml @@ -18,6 +18,7 @@ remote_user: ansible roles: - role: docker + - role: nvm # Clean up the system - hosts: datacenter