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

Added support for 5.x and some refactoring. #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ Install the playbook via Ansible Galaxy:
$ ansible-galaxy install nodesource.node
```

Or using the `requirements.yml`

```yaml
# install the role from galaxy
- src: nodesource.node
```

Which is imported as follows.

```
ansible-galaxy install -r requirements.yml
```

Then configure it as follows:

```yaml
Expand All @@ -25,6 +38,7 @@ Then configure it as follows:

## Role Variables

- `nodejs_version`: Supports 0.10 or 0.12 or 4.x or 5.x
- `nodejs_nodesource_pin_priority`: Pin-Priority of the NodeSource repository (default: `500`).

## Testing
Expand Down
4 changes: 2 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Pin-Priority of NodeSource repository
nodejs_nodesource_pin_priority: 500

# 0.10 or 0.12 or 4.x
nodejs_version: "4.2"
# 0.10 or 0.12 or 4.x or 5.x
nodejs_version: "5.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps set this to 5.x for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here is you can currently install a specific release, and it is then translated to the 5.x or 4.x required to build the repo path.

We could just get people to enter 0.10, 0.12 or 4.x or 5.x ect.

Actually seems like a better move.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scratch that, we require 5.x for the repo name, and a numeric value 5.0 for the apt task install.

10 changes: 9 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
register: apt_https_transport

- name: Install HTTPS transport for APT
apt:
apt:
pkg: apt-transport-https
state: installed
when: not apt_https_transport.stat.exists
Expand All @@ -16,6 +16,14 @@
url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
state: present

- name: Check if nodejs_version is 4.x or higher
set_fact: debian_repo_version="4.x"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there is a way to make this more dynamic for versions 4.x and up. But this solution works for now, just need to stay on top of this role for every new major release.

when: "{{ nodejs_version | version_compare('4.0', '>=') }}"

- name: Check if nodejs_version is 5.x or higher
set_fact: debian_repo_version="5.x"
when: "{{ nodejs_version | version_compare('5.0', '>=') }}"

- name: Add NodeSource deb repository
apt_repository:
repo: 'deb https://deb.nodesource.com/node_{{ debian_repo_version }} {{ ansible_distribution_release }} main'
Expand Down
2 changes: 1 addition & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
# vars file for nodejs
debian_repo_version: "{{ nodejs_version if '4' not in nodejs_version else '4.x' }}"
debian_repo_version: "{{ nodejs_version }}"