---
- name: Add nodejs repo
  ansible.builtin.copy:
    dest: "/etc/dnf/modules.d/nodejs.module"
    content: |
      [nodejs]
      name=nodejs
      stream={{ nodejs_version }}
      profiles=
      state=enabled
    mode: 0644
    owner: root

- name: Add yarn repo
  ansible.builtin.copy:
    dest: "/etc/yum.repos.d/yarn.repo"
    content: |
      [yarn]
      name=Yarn Repository
      baseurl=https://dl.yarnpkg.com/rpm/
      enabled=1
      gpgcheck=1
      gpgkey=https://dl.yarnpkg.com/rpm/pubkey.gpg
    mode: 0644
    owner: root

- name: Import yarn GPG signature
  ansible.builtin.rpm_key:
    key: https://dl.yarnpkg.com/rpm/pubkey.gpg
  environment:
    https_proxy: "{{ https_proxy }}"

- name: Install packages
  ansible.builtin.dnf:
    update_cache: true
    state: present
    name:
      - "@ruby:2.6"
      - bison
      - bzip2
      - curl
      - gcc-c++
      - git
      - libcurl-devel
      - libffi-devel
      - libpq
      - libpq-devel
      - libtool
      - libyaml
      - make
      - nodejs
      - openssl-devel
      - patch
      - readline
      - readline-devel
      - redhat-rpm-config
      - ruby-devel
      - yarn
      - zlib
      - zlib-devel

- name: Execute gem command
  ansible.builtin.command:
    gem install bundler
  environment:
    https_proxy: "{{ https_proxy }}"
  changed_when: false
  check_mode: false
  become: true
  become_user: zextras-ci
