From 348e38f37a4ad56e7389a99f42c8769395d175d9 Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Thu, 22 Mar 2018 18:19:51 +0530 Subject: [PATCH] changed node version install from 6 to 8 - broken down the node install into multiple parts based on OS - change the default node version to be installed from 6 to 8 --- .../roles/nodejs/tasks/debian_family.yml | 23 ++++++++++ playbooks/roles/nodejs/tasks/main.yml | 44 +++---------------- .../roles/nodejs/tasks/redhat_family.yml | 18 ++++++++ 3 files changed, 48 insertions(+), 37 deletions(-) create mode 100644 playbooks/roles/nodejs/tasks/debian_family.yml create mode 100644 playbooks/roles/nodejs/tasks/redhat_family.yml diff --git a/playbooks/roles/nodejs/tasks/debian_family.yml b/playbooks/roles/nodejs/tasks/debian_family.yml new file mode 100644 index 00000000..cef47710 --- /dev/null +++ b/playbooks/roles/nodejs/tasks/debian_family.yml @@ -0,0 +1,23 @@ +--- +- name: Add apt key for node repo + apt_key: + url: https://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0x1655A0AB68576280 + id: "68576280" + state: present + when: ansible_os_family == 'Debian' + +- name: Add repo + apt_repository: + repo: "deb [arch=amd64,i386] https://deb.nodesource.com/node_8.x {{ ansible_distribution_release }} main" + state: present + register: node_repo + when: ansible_os_family == 'Debian' + +- name: Install nodejs 8.x + apt: + name: nodejs + state: present + update_cache: yes + force: yes + when: ansible_os_family == 'Debian' +... \ No newline at end of file diff --git a/playbooks/roles/nodejs/tasks/main.yml b/playbooks/roles/nodejs/tasks/main.yml index e521c27d..85379727 100644 --- a/playbooks/roles/nodejs/tasks/main.yml +++ b/playbooks/roles/nodejs/tasks/main.yml @@ -1,44 +1,14 @@ --- -- name: Import Node source RPM key - rpm_key: - key: https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL - state: present - when: ansible_os_family == 'RedHat' +# Install's prerequisites, like fonts, image libraries, vim, screen, python-dev and gcc -- name: Add Node Repo for RedHat - yum: - name: 'https://rpm.nodesource.com/pub_6.x/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version }}-1.noarch.rpm' - state: present - update_cache: yes - when: ansible_os_family == 'RedHat' +- include_tasks: debian_family.yml + when: ansible_os_family == 'Debian' -- name: Install node v6 - yum: name=nodejs state=present - when: ansible_os_family == 'RedHat' - -- name: Add apt key for node repo - apt_key: - url: https://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0x1655A0AB68576280 - id: "68576280" - state: present - when: ansible_os_family == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Add repo - apt_repository: - repo: "deb [arch=amd64,i386] https://deb.nodesource.com/node_6.x {{ ansible_distribution_release }} main" - state: present - register: node_repo - when: ansible_os_family == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Install nodejs 6.x - apt: - name: nodejs - state: present - update_cache: yes - force: yes - when: ansible_os_family == 'Debian' or ansible_distribution == 'Ubuntu' +- include_tasks: redhat_family.yml + when: ansible_os_family == "RedHat" - name: Install yarn command: npm install -g yarn become: yes - become_user: root \ No newline at end of file + become_user: root +... \ No newline at end of file diff --git a/playbooks/roles/nodejs/tasks/redhat_family.yml b/playbooks/roles/nodejs/tasks/redhat_family.yml new file mode 100644 index 00000000..15af3846 --- /dev/null +++ b/playbooks/roles/nodejs/tasks/redhat_family.yml @@ -0,0 +1,18 @@ +--- +- name: Import Node source RPM key + rpm_key: + key: https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL + state: present + when: ansible_os_family == 'RedHat' + +- name: Add Node Repo for RedHat + yum: + name: 'https://rpm.nodesource.com/pub_8.x/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version }}-1.noarch.rpm' + state: present + update_cache: yes + when: ansible_os_family == 'RedHat' + +- name: Install node v8 + yum: name=nodejs state=present + when: ansible_os_family == 'RedHat' +... \ No newline at end of file