ansible-role-nodejs/tasks/Debian.yml

43 lines
1.4 KiB
YAML
Raw Normal View History

2023-08-13 07:20:47 +00:00
---
# https://www.jeffgeerling.com/blog/2022/aptkey-deprecated-debianubuntu-how-fix-ansible
- name: Add nodesource apt repository key.
ansible.builtin.get_url:
url: "{{ nodesource_repo_key_url }}"
dest: /usr/share/keyrings/nodesource-archive.asc
mode: '0644'
2023-08-13 07:20:47 +00:00
- name: Add yarn apt repository key.
ansible.builtin.get_url:
url: "{{ yarn_repo_key_url }}"
dest: /usr/share/keyrings/yarn-archive.asc
mode: '0644'
- name: Ensure the yarn repository is added with the relevant trusted GPG key
2023-08-13 07:20:47 +00:00
ansible.builtin.lineinfile:
path: /etc/apt/sources.list.d/yarn.list
regexp: dl.yarnpkg.com
line: deb [arch=amd64 signed-by=/usr/share/keyrings/yarn-archive.asc] https://dl.yarnpkg.com/debian/ stable main
create: true
register: yarn_repo
- name: Ensure the nodesource repository is added with the relevant trusted GPG key
ansible.builtin.lineinfile:
path: /etc/apt/sources.list.d/nodesource.list
regexp: deb.nodesource.com
line: "deb [arch=amd64 signed-by=/usr/share/keyrings/nodesource-archive.asc] https://deb.nodesource.com/{{ node_version }} {{ ansible_distribution_release }} main"
create: true
register: nodesource_repo
2023-08-13 07:20:47 +00:00
- name: Update the apt repository cache
ansible.builtin.apt:
update_cache: yes
when: nodesource_repo.changed or yarn_repo.changed
2023-08-13 07:20:47 +00:00
- name: Install the nodejs and yarn packages
2023-08-13 07:20:47 +00:00
ansible.builtin.apt:
name:
- nodejs
- yarn
state: latest
2023-08-13 07:20:47 +00:00