commit 6269782412d4126e07d58e7680e43d52870b566e Author: Brian Lee Date: Sun Aug 13 00:20:47 2023 -0700 Initialize repository for Yarn role. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4baac1e --- /dev/null +++ b/LICENSE @@ -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. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..abebd3d --- /dev/null +++ b/README.md @@ -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 +``` \ No newline at end of file diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..6099501 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,2 @@ +--- +dependencies: [] \ No newline at end of file diff --git a/tasks/Debian.yml b/tasks/Debian.yml new file mode 100644 index 0000000..2af7473 --- /dev/null +++ b/tasks/Debian.yml @@ -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 + diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..d909ab5 --- /dev/null +++ b/tasks/main.yml @@ -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' diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..9412980 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,2 @@ +--- +yarn_repo_key_url: https://dl.yarnpkg.com/debian/pubkey.gpg \ No newline at end of file