--- - name: Look for legacy apt keyring stat: path: /etc/apt/trusted.gpg register: _trusted_gpg_keyring tags: - system - packages - nodejs - yarn - name: Yarn embedded GPG key is absent apt_key: id: "86E50310" keyring: /etc/apt/trusted.gpg state: absent when: _trusted_gpg_keyring.stat.exists tags: - system - packages - nodejs - yarn - name: Yarn GPG key is installed copy: src: yarn.asc dest: "{{ apt_keyring_dir }}/yarn.asc" mode: "0644" owner: root group: root tags: - system - packages - nodejs - yarn - name: Yarn sources list is available apt_repository: repo: "deb [signed-by={{ apt_keyring_dir }}/yarn.asc] https://dl.yarnpkg.com/debian/ stable main" filename: yarn update_cache: yes state: present tags: - system - packages - nodejs - yarn - name: Unsigned Yarn sources list is not available apt_repository: repo: "deb https://dl.yarnpkg.com/debian/ stable main" filename: yarn update_cache: yes state: absent tags: - system - packages - nodejs - yarn - name: Yarn is installed apt: name: yarn state: present tags: - packages - nodejs - yarn