Skip to content

Commit

Permalink
refactored homebrew role to be command: module free
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjabong committed Jul 15, 2014
1 parent f502faa commit 2246cb4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
37 changes: 20 additions & 17 deletions roles/homebrew/tasks/main.yml
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
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"

0 comments on commit 2246cb4

Please sign in to comment.