diff --git a/README.md b/README.md index f4cd154..9255156 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ This is a work in progress, and is mostly a means for me to document my current ### Running a specific set of tagged tasks -You can filter which part of the provisioning process to run by specifying a set of tags using `ansible-playbook`'s `--tags` flag. The tags available are `dotfiles`, `homebrew`, `mas` and `osx`. +You can filter which part of the provisioning process to run by specifying a set of tags using `ansible-playbook`'s `--tags` flag. The tags available are `dotfiles`, `homebrew`, `mas`, `extra-packages` and `osx`. ansible-playbook main.yml -i inventory -K --tags "dotfiles,homebrew" @@ -46,6 +46,21 @@ You can override any of the defaults configured in `default.config.yml` by creat - { id: 557168941, name: "Tweetbot" } - { id: 497799835, name: "Xcode" } + composer_packages: + - name: hirak/prestissimo + - name: drush/drush + version: '^8.1' + + gem_packages: + - name: bundler + state: latest + + npm_packages: + - name: webpack + + pip_packages: + - name: mkdocs + Any variable can be overridden in `config.yml`; see the supporting roles' documentation for a complete list of available variables. ## Included Applications / Configuration (Default) diff --git a/default.config.yml b/default.config.yml index a0f647c..2977aba 100644 --- a/default.config.yml +++ b/default.config.yml @@ -76,5 +76,25 @@ 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: [] + # - name: drush + # state: present # present/absent, default: present + # version: "^8.1" # default: N/A +gem_packages: [] + # - name: bundler + # state: present # present/absent/latest, default: present + # version: "~> 1.15.1" # default: N/A +npm_packages: [] + # - name: webpack + # state: present # present/absent/latest, default: present + # version: "^2.6" # default: N/A +pip_packages: [] + # - name: mkdocs + # state: present # present/absent/latest, default: present + # version: "0.16.3" # default: N/A + # 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 a53c13e..a57e33b 100644 --- a/main.yml +++ b/main.yml @@ -34,6 +34,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..ee9254c --- /dev/null +++ b/tasks/extra-packages.yml @@ -0,0 +1,34 @@ +--- +- 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) }}" + state: "{{ item.state | default('present') }}" + version: "{{ item.version | default(omit) }}" + global: yes + executable: "{{ item.executable | default(omit) }}" + with_items: "{{ npm_packages }}" + +- name: Install global Pip packages. + pip: + name: "{{ item.name | default(item) }}" + state: "{{ item.state | default('present') }}" + version: "{{ item.version | default(omit) }}" + executable: "{{ item.executable | default(omit) }}" + with_items: "{{ pip_packages }}" + +- name: Install global Ruby gems. + gem: + name: "{{ item.name | default(item) }}" + state: "{{ item.state | default('present') }}" + version: "{{ item.version | default(omit) }}" + user_install: no + executable: "{{ item.executable | default(omit) }}" + with_items: "{{ gem_packages }}"