├── .gitignore ├── .travis.yml ├── README.md ├── defaults └── main.yml ├── meta └── main.yml ├── tasks ├── main.yml ├── rhel.yml └── ubuntu.yml └── tests ├── inventory └── test.yml /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### VisualStudioCode template 3 | .vscode 4 | 5 | ### JetBrains template 6 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 7 | .idea 8 | 9 | ## File-based project format: 10 | *.iws 11 | 12 | ## Plugin-specific files: 13 | 14 | # IntelliJ 15 | /out/ 16 | 17 | # mpeltonen/sbt-idea plugin 18 | .idea_modules/ 19 | 20 | # JIRA plugin 21 | atlassian-ide-plugin.xml 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: python 3 | python: "2.7" 4 | 5 | env: 6 | - distro: centos7 7 | init: /usr/lib/systemd/systemd 8 | run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" 9 | - distro: ubuntu1804 10 | init: /lib/systemd/systemd 11 | run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" 12 | - distro: ubuntu1604 13 | init: /lib/systemd/systemd 14 | run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" 15 | 16 | # We need sudo for some of the Docker commands. 17 | sudo: required 18 | 19 | # Tell Travis to start Docker when it brings up an environment. 20 | services: 21 | - docker 22 | 23 | before_install: 24 | # Pull container from Docker Hub. 25 | - 'docker pull geerlingguy/docker-${distro}-ansible:latest' 26 | 27 | install: 28 | # Create a random file to store the container ID. 29 | - container_id=$(mktemp) 30 | 31 | # Run container detached, with our role mounted inside. 32 | - 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"' 33 | 34 | script: 35 | # Basic role syntax check 36 | - > 37 | docker exec --tty "$(cat ${container_id})" env TERM=xterm 38 | ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml 39 | --syntax-check 40 | 41 | # Test role. 42 | - 'docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml' 43 | 44 | # Run the role/playbook again, checking to make sure it's idempotent. 45 | - idempotence=$(mktemp) 46 | - docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence} 47 | - > 48 | tail ${idempotence} 49 | | grep -q 'changed=0.*failed=0' 50 | && (echo 'Idempotence test: pass' && exit 0) 51 | || (echo 'Idempotence test: fail' && exit 1) 52 | 53 | # Ensure YARN is installed. 54 | - docker exec --tty "$(cat ${container_id})" env TERM=xterm which yarn 55 | 56 | notifications: 57 | webhooks: https://galaxy.ansible.com/api/v1/notifications/ 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Ansible Role: YARN Repository 2 | ========= 3 | 4 | [![Build Status](https://travis-ci.org/ocha/ansible-role-yarn.svg?branch=master)](https://travis-ci.org/ocha/ansible-role-yarn) 5 | [![Ansible Galaxy](https://img.shields.io/ansible/role/13308.svg)](https://galaxy.ansible.com/ocha/yarn/) 6 | 7 | Installs the [YARN Package Manager](https://yarnpkg.com) for Ubuntu/RHEL/CentOS. 8 | 9 | Requirements 10 | ------------ 11 | 12 | This role only runs on Ubuntu, RHEL and its derivatives. 13 | It requires EPEL repo on RHEL so it can install NodeJS. 14 | 15 | Role Variables 16 | -------------- 17 | 18 | Available variables are listed below, along with default values (see `defaults/main.yml`): 19 | 20 | yarn_debian_repo_url: "https://dl.yarnpkg.com/debian/ stable main" 21 | yarn_debian_repo_gpg_key_url: "https://dl.yarnpkg.com/debian/pubkey.gpg" 22 | yarn_rhel_repo_url: "https://dl.yarnpkg.com/rpm/" 23 | yarn_rhel_repo_gpg_key_url: "https://dl.yarnpkg.com/rpm/pubkey.gpg" 24 | 25 | Generally, these should not be changed, but if this role is out of date, or if you need a very specific version, these can be overridden. 26 | 27 | 28 | Dependencies 29 | ------------ 30 | 31 | None. 32 | 33 | Example Playbook 34 | ---------------- 35 | 36 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 37 | 38 | - hosts: servers 39 | roles: 40 | - ocha.yarn 41 | 42 | License 43 | ------- 44 | 45 | MIT / BSD 46 | 47 | Author Information 48 | ------------------ 49 | 50 | This role was created by [Iuri Gagnidze](https://www.github.com/ocha) 51 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | yarn_debian_repo_url: "https://dl.yarnpkg.com/debian/ stable main" 3 | yarn_debian_repo_gpg_key_url: "https://dl.yarnpkg.com/debian/pubkey.gpg" 4 | yarn_rhel_repo_url: "https://dl.yarnpkg.com/rpm/" 5 | yarn_rhel_repo_gpg_key_url: "https://dl.yarnpkg.com/rpm/pubkey.gpg" 6 | 7 | http_proxy: 8 | https_proxy: "{{ http_proxy }}" 9 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: Iuri Gagnidze 3 | description: Install YARN package manager for Ubuntu/RHEL 4 | license: license (BSD, MIT) 5 | 6 | min_ansible_version: 2.1 7 | 8 | platforms: 9 | - name: Ubuntu 10 | versions: 11 | - xenial 12 | - bionic 13 | - name: EL 14 | versions: 15 | - 7 16 | 17 | galaxy_tags: 18 | - packaging 19 | - yarn 20 | - nodejs 21 | - repository 22 | - repo 23 | 24 | dependencies: [] 25 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - include_tasks: rhel.yml 3 | when: ansible_distribution == 'CentOS' or ansible_os_family == 'RedHat' or ansible_distribution == 'Amazon' 4 | 5 | - include_tasks: ubuntu.yml 6 | when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' 7 | 8 | - name: Install YARN package manager 9 | package: name=yarn state=latest 10 | -------------------------------------------------------------------------------- /tasks/rhel.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install YARN YUM repo. 3 | yum_repository: 4 | name: yarn 5 | description: Yarn Repository 6 | baseurl: "{{ yarn_rhel_repo_url }}" 7 | enabled: yes 8 | gpgcheck: yes 9 | gpgkey: "{{ yarn_rhel_repo_gpg_key_url }}" 10 | state: present 11 | 12 | - name: Install NodeJS package for yarn dependency 13 | package: name=nodejs state=latest 14 | -------------------------------------------------------------------------------- /tasks/ubuntu.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Make sure HTTPS is supported by apt 3 | apt: 4 | name: apt-transport-https 5 | state: present 6 | update_cache: yes 7 | 8 | - name: Import YARN APT key 9 | apt_key: 10 | url: "{{ yarn_debian_repo_gpg_key_url }}" 11 | state: present 12 | when: (http_proxy is undefined) or (http_proxy is none) 13 | 14 | - name: Import YARN APT key (proxy) 15 | apt_key: 16 | url: "{{ yarn_debian_repo_gpg_key_url }}" 17 | state: present 18 | environment: 19 | http_proxy: "{{ http_proxy }}" 20 | https_proxy: "{{ https_proxy }}" 21 | when: not( (http_proxy is undefined) or (http_proxy is none) ) 22 | and (http_proxy | length > 0) 23 | 24 | - name: Install YARN APT repo 25 | apt_repository: 26 | repo: "deb {{ yarn_debian_repo_url }}" 27 | filename: "yarn" 28 | state: present 29 | update_cache: yes 30 | -------------------------------------------------------------------------------- /tests/inventory: -------------------------------------------------------------------------------- 1 | localhost -------------------------------------------------------------------------------- /tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - role_under_test 6 | --------------------------------------------------------------------------------