diff --git a/default.config.yml b/default.config.yml index af145cb..45792bd 100644 --- a/default.config.yml +++ b/default.config.yml @@ -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: [] diff --git a/main.yml b/main.yml index 1998870..3d25464 100644 --- a/main.yml +++ b/main.yml @@ -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: diff --git a/tasks/extra-packages.yml b/tasks/extra-packages.yml new file mode 100644 index 0000000..8de15ca --- /dev/null +++ b/tasks/extra-packages.yml @@ -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 }}"