ansible-roles/nodejs/tasks/main.yml

64 lines
1.5 KiB
YAML
Raw Normal View History

---
2023-03-19 11:44:53 +01:00
- name: APT https transport is enabled (Debian <10)
ansible.builtin.apt:
name: apt-transport-https
state: present
tags:
- system
- packages
- nodejs
2023-03-19 11:44:53 +01:00
when: ansible_distribution_major_version is version('10', '<')
- name: NodeJS GPG key is installed
2023-03-19 11:44:53 +01:00
ansible.builtin.copy:
src: nodesource.asc
dest: "{{ apt_keyring_dir }}/nodesource.asc"
2021-05-26 13:47:34 +02:00
mode: "0644"
owner: root
group: root
tags:
- system
- packages
- nodejs
2023-03-19 11:44:53 +01:00
- name: Add NodeJS repository (Debian <12)
ansible.builtin.apt_repository:
repo: "deb [signed-by={{ apt_keyring_dir }}/nodesource.asc] https://deb.nodesource.com/{{ nodejs_apt_version }} {{ ansible_distribution_release }} main"
filename: nodesource
update_cache: yes
state: present
tags:
- system
- packages
- nodejs
2023-03-19 11:44:53 +01:00
when: ansible_distribution_major_version is version('12', '<')
2023-03-19 11:44:53 +01:00
- name: Add NodeJS repository (Debian >=12)
ansible.builtin.template:
src: nodesource.sources.j2
dest: /etc/apt/sources.list.d/nodesource.sources
state: present
register: nodesource_sources
tags:
- system
- packages
- nodejs
2023-03-19 11:44:53 +01:00
when: ansible_distribution_major_version is version('12', '>=')
- name: Update APT cache
ansible.builtin.apt:
update_cache: yes
when: nodesource_sources is changed
2018-04-06 09:19:36 +02:00
- name: NodeJS is installed
2023-03-19 11:44:53 +01:00
ansible.builtin.apt:
name: nodejs
state: present
tags:
- packages
- nodejs
2023-03-19 11:44:53 +01:00
- ansible.builtin.import_tasks: yarn.yml
when: nodejs_install_yarn | bool