2023-08-13 07:20:47 +00:00
|
|
|
---
|
|
|
|
# https://www.jeffgeerling.com/blog/2022/aptkey-deprecated-debianubuntu-how-fix-ansible
|
2023-08-13 15:54:05 +00:00
|
|
|
- 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'
|
|
|
|
|
2023-08-13 15:54:05 +00:00
|
|
|
- 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
|
|
|
|
|
2023-08-13 15:54:05 +00:00
|
|
|
- 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
|
2023-08-13 15:54:05 +00:00
|
|
|
when: nodesource_repo.changed or yarn_repo.changed
|
2023-08-13 07:20:47 +00:00
|
|
|
|
2023-08-13 15:54:05 +00:00
|
|
|
- name: Install the nodejs and yarn packages
|
2023-08-13 07:20:47 +00:00
|
|
|
ansible.builtin.apt:
|
2023-08-13 15:54:05 +00:00
|
|
|
name:
|
|
|
|
- nodejs
|
|
|
|
- yarn
|
|
|
|
state: latest
|
2023-08-13 07:20:47 +00:00
|
|
|
|