forked from ISTI-ansible-roles/ansible-roles
Role that installs node.js with npm and optionally yarn
This commit is contained in:
parent
5398dfe38d
commit
f3d6128ff8
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
node_js_repo_version: 8
|
||||
node_js_repo_name: 'node_{{ node_js_repo_version }}.x'
|
||||
node_js_repo_key: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
|
||||
node_js_repo_urls:
|
||||
- 'deb https://deb.nodesource.com/{{ node_js_repo_name }} {{ ansible_distribution_release }} main'
|
||||
- 'deb-src https://deb.nodesource.com/{{ node_js_repo_name }} {{ ansible_distribution_release }} main'
|
||||
|
||||
node_js_pkgs:
|
||||
- nodejs
|
||||
- npm
|
||||
|
||||
node_js_pkg_state: present
|
||||
|
||||
node_js_yarn_install: False
|
||||
node_js_yarn_repo_key: https://dl.yarnpkg.com/debian/pubkey.gpg
|
||||
node_js_yarn_repo_urls:
|
||||
- 'deb https://dl.yarnpkg.com/debian/ stable main'
|
||||
|
||||
node_js_yarn_pkgs:
|
||||
- yarn
|
|
@ -0,0 +1,44 @@
|
|||
- block:
|
||||
- name: Install the Node.js repository key
|
||||
apt_key: url={{ node_js_repo_key }} state=present
|
||||
|
||||
- name: Install the Node.js repository configuration
|
||||
apt_repository: repo={{ item }} state=present update_cache=True
|
||||
with_items: '{{ node_js_repo_urls }}'
|
||||
|
||||
- name: Install the Node.js packages
|
||||
apt: pkg={{ item }} state={{ node_js_pkg_state }} update_cache=True cache_valid_time=1800
|
||||
with_items: '{{ node_js_pkgs }}'
|
||||
|
||||
tags: [ 'nodejs', 'node_js' ]
|
||||
|
||||
- block:
|
||||
- name: Install the Node.js yarn repository key
|
||||
apt_key: url={{ node_js_yarn_repo_key }} state=present
|
||||
|
||||
- name: Install the Node.js yarn repository configuration
|
||||
apt_repository: repo={{ item }} state=present update_cache=True
|
||||
with_items: '{{ node_js_yarn_repo_urls }}'
|
||||
|
||||
- name: Install the Node.js yarn packages
|
||||
apt: pkg={{ item }} state={{ node_js_pkg_state }} update_cache=True cache_valid_time=1800
|
||||
with_items: '{{ node_js_yarn_pkgs }}'
|
||||
|
||||
when: node_js_yarn_install
|
||||
tags: [ 'nodejs', 'node_js', 'yarn', 'node_js_yarn' ]
|
||||
|
||||
- block:
|
||||
- name: Remove the Node.js yarn repository key
|
||||
apt_key: url={{ node_js_yarn_repo_key }} state=absent
|
||||
|
||||
- name: Install the Node.js yarn repository configuration
|
||||
apt_repository: repo={{ item }} state=absent update_cache=True
|
||||
with_items: '{{ node_js_yarn_repo_urls }}'
|
||||
|
||||
- name: Install the Node.js yarn packages
|
||||
apt: pkg={{ item }} state=absent update_cache=True cache_valid_time=1800
|
||||
with_items: '{{ node_js_yarn_pkgs }}'
|
||||
|
||||
when: not node_js_yarn_install
|
||||
tags: [ 'nodejs', 'node_js', 'yarn', 'node_js_yarn' ]
|
||||
|
Loading…
Reference in New Issue