ensure-yarn: refactor to use ensure-package-repositories

This patch refactors ensure-yarn to use the new generic role
to allow it to be cross-platform in the future.

Change-Id: I32bb40f5afb26d0d906f332c1c8440859367d97a
This commit is contained in:
Mohammed Naser 2020-04-04 15:56:40 -04:00 committed by Andreas Jaeger
parent 7ea6d11981
commit 7cb1c6b16b
5 changed files with 34 additions and 26 deletions

View File

@ -1,14 +0,0 @@
- name: Add yarnpkg repository key
apt_key:
url: https://dl.yarnpkg.com/debian/pubkey.gpg
become: yes
- name: Add yarnpkg apt source repository
apt_repository:
repo: "deb https://dl.yarnpkg.com/debian/ stable main"
state: present
update_cache: yes
become: yes
- name: Install yarn
include: yarn.yaml

View File

@ -1,8 +0,0 @@
- name: Add yarnpkg repo file
get_url:
url: https://dl.yarnpkg.com/rpm/yarn.repo
dest: /etc/yum.repos.d/yarn.repo
become: yes
- name: Install yarn
include: yarn.yaml

View File

@ -1,3 +1,26 @@
- name: Gather variables for each operating system
include_vars: "{{ zj_item }}"
with_first_found:
- skip: true
files:
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yaml"
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yaml"
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yaml"
- "{{ ansible_distribution | lower }}.yaml"
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yaml"
- "{{ ansible_os_family | lower }}.yaml"
loop_control:
loop_var: zj_item
tags:
- always
- name: Add all repositories
include_role:
name: ensure-package-repositories
vars:
repositories_keys: "{{ _yarn_keys | default([]) }}"
repositories_list: "{{ _yarn_repos | default([]) }}"
- name: Check for yarn.lock file - name: Check for yarn.lock file
stat: stat:
path: "{{ yarn_lock_file_path }}" path: "{{ yarn_lock_file_path }}"
@ -7,9 +30,6 @@
register: yarn_lock register: yarn_lock
- name: Install yarn if needed - name: Install yarn if needed
include: "{{ item }}" include: yarn.yaml
with_first_found:
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
when: when:
- yarn_lock.stat.exists - yarn_lock.stat.exists

View File

@ -0,0 +1,4 @@
_yarn_keys:
- url: https://dl.yarnpkg.com/debian/pubkey.gpg
_yarn_repos:
- repo: deb https://dl.yarnpkg.com/debian/ stable main

View File

@ -0,0 +1,6 @@
_yarn_repos:
- name: yarn
description: Yarn Repository
baseurl: https://dl.yarnpkg.com/rpm/
gpgcheck: yes
gpgkey: https://dl.yarnpkg.com/rpm/pubkey.gpg