Issue #36: Add option to install npm/composer/pip/gem packages

This commit is contained in:
Oskar Schöldström 2017-06-02 10:58:06 -05:00
parent ddb070f2d4
commit c211d1fdf7
3 changed files with 42 additions and 0 deletions

View file

@ -75,5 +75,13 @@ mas_password: ""
osx_script: "~/.osx --no-restart"
# Install packages from other package managers.
# Note: You are responsible for making sure the required package managers are
# installed, eg. through homebrew.
composer_packages: []
gem_packages: []
npm_packages: []
pip_packages: []
# Glob pattern to ansible task files to run after all other tasks are finished.
post_provision_tasks: []

View file

@ -33,6 +33,9 @@
when: configure_osx
tags: ['osx']
- include: tasks/extra-packages.yml
tags: ['extra-packages']
- name: Run configured post-provision ansible task files.
include: "{{ outer_item }}"
loop_control:

31
tasks/extra-packages.yml Normal file
View file

@ -0,0 +1,31 @@
---
- name: Install global Composer packages.
composer:
command: "{{ (item.state | default('present') == 'absent') | ternary('remove', 'require') }}"
arguments: "{{ item.name | default(item) }} {{ item.version | default('@stable') }}"
# Ansible 2.4 supports `global_command` making `working_dir` optional.
working_dir: "{{ lookup('env', 'COMPOSER_HOME') | default('~/.composer', true) }}"
with_items: "{{ composer_packages }}"
- name: Install global NPM packages.
npm:
name: "{{ item.name | default(item) }}"
version: "{{ item.version | default('latest') }}"
state: "{{ item.state | default('present') }}"
global: yes
with_items: "{{ npm_packages }}"
- name: Install global Pip packages.
pip:
name: "{{ item.name | default(item) }}"
version: "{{ item.version | default(omit) }}"
state: "{{ item.state | default('latest') }}"
with_items: "{{ pip_packages }}"
- name: Install global Ruby gems.
gem:
name: "{{ item.name | default(item) }}"
version: "{{ item.version | default(omit) }}"
state: "{{ item.state | default('latest') }}"
user_install: false
with_items: "{{ gem_packages }}"