Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
setup-RedHat.yml 1.4 KiB
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

- name: Import Nodesource RPM key
  ansible.builtin.rpm_key:
    key: https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL
    state: present
  become: true
- name: Disable nodesource repository installed by rpm package
  ansible.builtin.yum:
    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
  become: true
- 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
  become: true
- name: Ensure Node.js and npm are installed
  ansible.builtin.yum:
    name: "nodejs-{{ nodejs_version | regex_replace('x', '') }}*"
    state: present
    enablerepo: "nodesource-{{ nodejs_version }}"
    allow_downgrade: true
  become: true

- name: Install yarn
  community.general.npm:
    name: yarn
    global: yes
  become: true