Initialize repository for Yarn role.

This commit is contained in:
Brian Lee 2023-08-13 00:20:47 -07:00
commit 6269782412
7 changed files with 81 additions and 0 deletions

0
.gitignore vendored Normal file
View File

17
LICENSE Normal file
View File

@ -0,0 +1,17 @@
MIT No Attribution License
Copyright (c) 2023 Brian Lee
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

24
README.md Normal file
View File

@ -0,0 +1,24 @@
# Ansible Role: yarn
Install yarn packages from the official yarn repositories.
Tested on:
* Ubuntu 22.04
## Requirements
None.
## Role Variables
See the role [vars](vars/main.yml)
## Example Playbook
```yaml
- hosts: yarn
roles:
- role: bleetube.yarn
become: true
```

2
meta/main.yml Normal file
View File

@ -0,0 +1,2 @@
---
dependencies: []

26
tasks/Debian.yml Normal file
View File

@ -0,0 +1,26 @@
---
# https://www.jeffgeerling.com/blog/2022/aptkey-deprecated-debianubuntu-how-fix-ansible
- 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 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: Update the apt repository cache
ansible.builtin.apt:
update_cache: yes
when: yarn_repo.changed
- name: Install the yarn package
ansible.builtin.apt:
name: yarn
state: present

10
tasks/main.yml Normal file
View File

@ -0,0 +1,10 @@
---
- name: Install yarn (Debian)
import_tasks: Debian.yml
when: ansible_os_family == 'Debian'
- name: Install yarn (non-Debian)
ansible.builtin.package:
name: yarn
state: present
when: ansible_os_family != 'Debian'

2
vars/main.yml Normal file
View File

@ -0,0 +1,2 @@
---
yarn_repo_key_url: https://dl.yarnpkg.com/debian/pubkey.gpg