--- # https://www.jeffgeerling.com/blog/2022/aptkey-deprecated-debianubuntu-how-fix-ansible - name: Add nodesource apt repository key. ansible.builtin.get_url: url: "{{ nodesource_repo_key_url }}" dest: /usr/share/keyrings/nodesource-archive.asc mode: '0644' - name: Add yarn apt repository key. ansible.builtin.get_url: url: "{{ yarn_repo_key_url }}" dest: /usr/share/keyrings/yarn-archive.asc mode: '0644' - name: Ensure the yarn repository is added with the relevant trusted GPG key 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 - 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 - name: Update the apt repository cache ansible.builtin.apt: update_cache: yes when: nodesource_repo.changed or yarn_repo.changed - name: Install the nodejs and yarn packages ansible.builtin.apt: name: - nodejs - yarn state: latest