- name: Ensure the system can use the HTTPS transport for APT stat: path: /usr/lib/apt/methods/https register: apt_https_transport - name: Install HTTPS transport for APT apt: pkg: apt-transport-https state: installed when: not apt_https_transport.stat.exists - name: Import the NodeSource GPG key into apt apt_key: url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key state: present - name: Add NodeSource deb repository apt_repository: repo: 'deb https://deb.nodesource.com/node_{{ nodejs_version }} {{ ansible_distribution_release }} main' state: present - name: Add NodeSource deb-src repository apt_repository: repo: 'deb-src https://deb.nodesource.com/node_{{ nodejs_version }} {{ ansible_distribution_release }} main' state: present - name: Install Node.js apt: pkg: nodejs state: installed update_cache: yes - name: Update npm command: bash -lc "npm install -g npm"