Newer
Older
- name: Set up the Nodesource RPM directory
ansible.builtin.set_fact:
rhel_distribution_major_version: "{{ ansible_distribution_major_version }}"
when: ansible_distribution_major_version | int >= 8
key: https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL
state: present
- name: Disable nodesource repository installed by rpm package
name: nodesource-release
state: absent
become: true
- name: Add Node.js repository file
ansible.builtin.template:
src: nodesource.repo.j2
dest: "/etc/yum.repos.d/nodesource-{{ nodejs_version }}.repo"
owner: root
group: root
mode: '0644'
notify: Clean yum metadata
- name: Ensure Node.js AppStream module is disabled (CentOS 8+)
ansible.builtin.command: yum module disable -y nodejs # noqa: command-instead-of-module
register: module_disable
changed_when: "'Nothing to do.' not in module_disable.stdout"
when: ansible_distribution_major_version | int >= 8
- name: Ensure Node.js and npm are installed
ansible.builtin.yum:
name: "nodejs-{{ nodejs_version | regex_replace('x', '') }}*"
enablerepo: "nodesource-{{ nodejs_version }}"
allow_downgrade: true
become: true
- name: Install yarn
community.general.npm:
name: yarn
global: yes
become: true