Skip to content

Commit

Permalink
Merge pull request #2 from osxc/cask
Browse files Browse the repository at this point in the history
Install Homebrew Cask (as an option)
  • Loading branch information
rricard committed Sep 6, 2014
2 parents 1c58252 + da21926 commit 6eee6da
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 3 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ Ensure that homebrew is installed on your mac
## Requirements

- XCode Command-Line Tools (needs `git`)
- Needs root if you want to affect other users

## Role variables

| Name | Description | Default |
|-----------------------|--------------------------------------------------|--------------------|
| `installation_method` | The way to install homebrew, `script` or `clone` | `script` |
| `clone_dir` | The path where homebrew will be cloned | `~/src/github.com/Homebrew/homebrew` |
| `clone_dir` | The path where homebrew will be cloned | `/Users/{{ ansible_user_id }}/src/github.com/Homebrew/homebrew` |
| `install_dir` | The path where homebrew will be installed | `/usr/local` |
| `install_cask` | Defines if you want to install Homebrew Cask too | `yes` |
| `affected_users` | The users affected by the custom settings | `[ "{{ ansible_user_id }}" ]` |

## Dependencies

none
- `osxc.common-env`

## License

Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
installation_method: script
clone_dir: "/Users/{{ ansible_user_id}}/src/github.com/Homebrew/homebrew"
install_dir: "/usr/local"
install_cask: yes
affected_users:
- "{{ ansible_user_id }}"
3 changes: 2 additions & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ galaxy_info:
- development
- packaging
- system
dependencies: []
dependencies:
- src: osxc.common-env
20 changes: 20 additions & 0 deletions tasks/cask.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
- name: assert cask presence
stat: path={{ install_dir }}/bin/brew-cask.rb
register: cask_installed

- name: tap the cask repository
homebrew_tap: tap=caskroom/cask state=present
when: cask_installed.stat.exists == false

- name: install brew-cask
homebrew: name=brew-cask state=latest update_homebrew=yes
when: cask_installed.stat.exists == false

- name: add new cask opts to common env
lineinfile: dest=/Users/{{ item }}/.common_env
regexp='^export HOMEBREW_CASK_OPTS'
line='export HOMEBREW_CASK_OPTS="--appdir=/Applications"'
state=present
owner={{ item }}
with_items: affected_users
3 changes: 3 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@

- name: Update Homebrew
homebrew: update_homebrew=yes

- include: cask.yml
when: install_cask
1 change: 1 addition & 0 deletions test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
- hosts: localhost
remote_user: root
tasks:
- file: dest=/Users/{{ ansible_user_id }}/.common_env state=touch
- include_vars: test_vars.yml
- include: tasks/main.yml
3 changes: 3 additions & 0 deletions test_vars.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
clone_dir: "/Users/{{ ansible_user_id}}/src/github.com/Homebrew/homebrew"
install_dir: "/Users/{{ ansible_user_id}}/brew"
install_cask: yes
affected_users:
- "{{ ansible_user_id }}"

0 comments on commit 6eee6da

Please sign in to comment.