-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored homebrew role to be command: module free
- Loading branch information
Showing
2 changed files
with
21 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
--- | ||
# installs homebrew system-wide | ||
|
||
- name: clone homebrew | ||
git: repo=https://github.com/Homebrew/homebrew.git dest={{ brew_repo_path }} update=no | ||
|
||
# let's stat some things and register some conditionals | ||
- name: assert new homebrew installation | ||
command: test -e /usr/local/bin/brew | ||
ignore_errors: True | ||
stat: path={{ brew_install_path }}/bin/brew | ||
register: brew_installed | ||
|
||
- name: get old /usr/local | ||
copy: src=/usr/local/ dest={{ brew_repo_path }} force=no | ||
when: brew_installed|failed | ||
- name: clone homebrew if needed | ||
git: "repo=https://github.com/Homebrew/homebrew dest={{ brew_repo_path }} update=no" | ||
when: brew_installed.stat.exists == false | ||
|
||
- name: fix user acls | ||
command: chmod -R +x {{ brew_repo_path }}/bin | ||
when: brew_installed|failed | ||
- name: copy {{ brew_install_path }} to {{ brew_repo_path }} | ||
sudo: True | ||
synchronize: src={{ brew_install_path }}/ dest={{ brew_repo_path }} copy_links=yes | ||
when: brew_installed.stat.exists == false | ||
|
||
- name: clean up /usr/local | ||
- name: fix user acl on {{ brew_repo_path }} and clean up {{ brew_install_path }} | ||
sudo: True | ||
command: rm -rf /usr/local | ||
when: brew_installed|failed | ||
file: path={{ item.path }} state={{ item.state|default('directory') }} | ||
owner={{ ansible_user_id }} group=staff mode=0755 | ||
with_items: | ||
- { path: '{{ brew_repo_path }}' } | ||
- { path: '{{ brew_repo_path }}/bin' } | ||
- { path: '{{ brew_install_path }}' , state: 'absent' } | ||
when: brew_installed.stat.exists == false | ||
|
||
- name: link the repo to the brew installation path | ||
- name: ensure {{ brew_repo_path }} is linked to the {{ brew_install_path }} | ||
sudo: True | ||
file: state=link src={{ brew_repo_path }} dest={{ brew_install_path }} owner={{ ansible_user_id }} | ||
when: brew_installed|failed | ||
when: brew_installed.stat.exists == false | ||
|
||
- name: update homebrew | ||
homebrew: update_homebrew=yes | ||
when: brew_installed.stat.exists == true |
3 changes: 1 addition & 2 deletions
3
roles/homebrew/defaults/main.yml → roles/homebrew/vars/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
--- | ||
# variables precising where to install homebrew | ||
|
||
brew_repo_path: "{{ ansible_env.HOME }}/src/github.com/mxcl/homebrew" | ||
|
||
brew_install_path: "/usr/local" | ||
brew_repo_path: "{{ ansible_env.HOME }}/src/github.com/mxcl/homebrew" |