infra/roles/stable/nodejs/tasks/setup.yml

41 lines
1 KiB
YAML
Raw Permalink Normal View History

2020-09-28 01:44:06 +02:00
---
- name: Ensure dependencies are present.
2021-01-04 18:56:58 +01:00
become: yes
2020-09-28 01:44:06 +02:00
apt:
name:
- apt-transport-https
- gnupg2
- build-essential
state: present
- name: Add Nodesource apt key.
2021-01-04 18:56:58 +01:00
become: yes
2020-09-28 01:44:06 +02:00
apt_key:
url: https://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0x1655A0AB68576280
id: "68576280"
state: present
- name: Add NodeSource repositories for Node.js.
2021-01-04 18:56:58 +01:00
become: yes
2020-09-28 01:44:06 +02:00
apt_repository:
repo: "{{ item }}"
state: present
with_items:
- "deb https://deb.nodesource.com/node_{{ nodejs_version }} {{ ansible_distribution_release }} main"
- "deb-src https://deb.nodesource.com/node_{{ nodejs_version }} {{ ansible_distribution_release }} main"
register: node_repo
- name: Update apt cache if repo was added.
2021-01-04 18:56:58 +01:00
become: yes
apt:
update_cache: true
cache_valid_time: 43200 # 12 hours
2020-09-28 01:44:06 +02:00
when: node_repo.changed
tags: ['skip_ansible_lint']
- name: Ensure Node.js and npm are installed.
2021-01-04 18:56:58 +01:00
become: yes
2020-09-28 01:44:06 +02:00
apt:
name: "nodejs={{ nodejs_version|regex_replace('x', '') }}*"
state: present