Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for switching between nodejs versions (upgrade/downgrade) #222

Merged
merged 6 commits into from
Jan 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions roles/StackStorm.nodejs/tasks/nodejs_yum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,31 @@
until: _task is succeeded
tags: nodejs

- name: Add nodesource repo
- name: Remove nodesource repo rpm
# rpm conflicts with yum_repository added file below
become: yes
yum:
name: "http://rpm.nodesource.com/pub_{{ nodejs_major_version }}.x/el/{{ ansible_facts.distribution_major_version }}/{{ ansible_facts.architecture }}/nodesource-release-el{{ ansible_facts.distribution_major_version }}-1.noarch.rpm"
name: "nodesource-release-el{{ ansible_facts.distribution_major_version }}-1.noarch"
state: absent
register: nodesource_repo_rm
tags: nodejs

- name: Add nodesource repo file
become: yes
# This is based on the nodesource repo rpm (both 4.x and 10.x for EL6/7/8),
# but that rpm is not versioned even though it hard-codes the major node.js version.
# So, installing the repo directly (vs via the rpm) simplifies major node.js upgrades.
# see - http://rpm.nodesource.com/pub_10.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm
yum_repository:
file: "nodesource-el{{ ansible_facts.distribution_major_version }}"
name: nodesource
description: "Node.js Packages for Enterprise Linux {{ ansible_facts.distribution_major_version }} - $basearch"
baseurl: https://rpm.nodesource.com/pub_{{ nodejs_major_version }}.x/el/{{ ansible_facts.distribution_major_version }}/$basearch
failovermethod: priority
gpgcheck: yes
gpgkey: file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
state: present
register: nodesource_repo_add
tags: nodejs

- name: Install nodejs
Expand All @@ -25,6 +45,7 @@
# TODO: Allow yum downgrade since Ansible 2.4
# https://github.com/ansible/ansible/pull/21516
# allow_downgrade: yes
update_cache: "{{ nodesource_repo_rm is changed or nodesource_repo_add is changed }}"
register: _task
retries: 5
delay: 3
Expand Down