ansible-roles/nodejs/tasks/main.yml
Mathieu Trossevin 7c632352a0
Replace the include module with include_tasks or import_tasks
The behaviour of the `include` module is badly defined (it try to choose
between statically importing the tasks and dynamically including them)
and can cause problems depending on any number of constraints (mostly if
it choose the wrong behaviour).

Replace it with the `import_tasks` (always statically import tasks) unless
the `include` is in a loop in which case we replace it with
`include_tasks` (always dynamically include tasks).
2023-01-03 14:43:42 +01:00

77 lines
1.6 KiB
YAML

---
- name: APT https transport is enabled
apt:
name: apt-transport-https
state: present
tags:
- system
- packages
- nodejs
- name: Look for legacy apt keyring
stat:
path: /etc/apt/trusted.gpg
register: _trusted_gpg_keyring
tags:
- system
- packages
- nodejs
- name: NodeJS embedded GPG key is absent
apt_key:
id: "68576280"
keyring: /etc/apt/trusted.gpg
state: absent
when: _trusted_gpg_keyring.stat.exists
tags:
- system
- packages
- nodejs
- name: NodeJS GPG key is installed
copy:
src: nodesource.asc
dest: "{{ apt_keyring_dir }}/nodesource.asc"
mode: "0644"
owner: root
group: root
tags:
- system
- packages
- nodejs
- name: NodeJS sources list ({{ nodejs_apt_version }}) is available
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
- name: Unsigned NodeJS sources list ({{ nodejs_apt_version }}) is not available
apt_repository:
repo: "deb https://deb.nodesource.com/{{ nodejs_apt_version }} {{ ansible_distribution_release }} main"
filename: nodesource
update_cache: yes
state: absent
tags:
- system
- packages
- nodejs
- name: NodeJS is installed
apt:
name: nodejs
state: present
update_cache: yes
tags:
- packages
- nodejs
- import_tasks: yarn.yml
when: nodejs_install_yarn | bool