Completely revamped the playbook. Let homebrew and cask do the hard work.

This commit is contained in:
Jeff Geerling 2014-10-02 23:07:02 -05:00
parent 4f15473fcd
commit 8f8ea4a8e5
32 changed files with 122 additions and 443 deletions

View file

@ -1,15 +0,0 @@
---
- hosts: all
connection: local
vars:
app_name: Adium
app_name_pretty: Adium
app_url: "http://downloads.sourceforge.net/project/adium/Adium_1.5.9.dmg?r=&ts=1392301195&use_mirror=softlayer-ams"
installer_type: app
install_method: dmg
mount_path: /Volumes/Adium\ 1.5.9/
creates: /Applications/Adium.app
downloads: ~/.ansible-downloads/
tasks:
- include: ../install/{{ install_method }}.yml

View file

@ -1,15 +0,0 @@
---
- hosts: all
connection: local
vars:
app_name: Google\ Chrome
app_name_pretty: Google Chrome
app_url: "https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg"
installer_type: app
install_method: dmg
mount_path: /Volumes/Google\ Chrome/
creates: /Applications/Google\ Chrome.app
downloads: ~/.ansible-downloads/
tasks:
- include: ../install/{{ install_method }}.yml

View file

@ -1,14 +0,0 @@
---
- hosts: all
connection: local
vars:
app_name: Cornerstone
app_name_pretty: Cornerstone
app_url: "http://www.zennaware.com/mint/pepper/orderedlist/downloads/download.php?file=http%3A//www.zennaware.com/cornerstone/downloads/Cornerstone-2.7.11.zip"
installer_type: app
install_method: zip
downloads: ~/.ansible-downloads/
creates: /Applications/Cornerstone.app
tasks:
- include: ../install/{{ install_method }}.yml

View file

@ -1,9 +0,0 @@
---
# Note: Once downloaded, you will need to manually run Dropbox to setup.
# TODO: Maybe still use normal DMG routine for the install instead of sh?
- hosts: all
connection: local
tasks:
- name: Install Dropbox.
shell: curl -fkL https://gist.github.com/raw/963046/install-dropbox.sh | sh creates=/Applications/Dropbox.app

View file

@ -1,15 +0,0 @@
---
- hosts: all
connection: local
vars:
app_name: Firefox
app_name_pretty: Firefox
app_url: "https://download.mozilla.org/?product=firefox-27.0&os=osx&lang=en-US"
installer_type: app
install_method: dmg
mount_path: /Volumes/Firefox/
downloads: ~/.ansible-downloads/
creates: /Applications/Firefox.app
tasks:
- include: ../install/{{ install_method }}.yml

View file

@ -1,15 +0,0 @@
---
- hosts: all
connection: local
vars:
app_name: HandBrake
app_name_pretty: HandBrake
app_url: "http://handbrake.fr/rotation.php?file=HandBrake-0.9.9-MacOSX.6_GUI_x86_64.dmg"
installer_type: app
install_method: dmg
mount_path: /Volumes/HandBrake-0.9.9-MacOSX.6_GUI_x86_64/
downloads: ~/.ansible-downloads/
creates: /Applications/HandBrake.app
tasks:
- include: ../install/{{ install_method }}.yml

View file

@ -1,13 +0,0 @@
---
- hosts: all
connection: local
tasks:
- name: Install Xcode CLI tools
shell: /usr/bin/xcode-select --install creates=/usr/bin/gcc
sudo: yes
- name: Run Homebrew install script
shell: ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" creates=/usr/local/bin/brew
register: brew_result
sudo: yes

View file

@ -1,14 +0,0 @@
---
- hosts: all
connection: local
vars:
app_name: Knock
app_name_pretty: Knock
app_url: "http://knocktounlock.com/download"
installer_type: app
install_method: zip
downloads: ~/.ansible-downloads/
creates: /Applications/Knock.app
tasks:
- include: ../install/{{ install_method }}.yml

View file

@ -1,17 +0,0 @@
---
# TODO: This uses a custom installer. Might be able to install from source.
- hosts: all
connection: local
vars:
app_name: Menu\ Meters
app_name_pretty: Menu\ Meters
app_url: "http://www.ragingmenace.com/software/download/MenuMeters.dmg"
installer_type: pkg
install_method: dmg
install_target: /Volumes/Macintosh\ HD
mount_path: /Volumes/Menu\ Meters\ 1.6.1/
creates: /Applications/Menu\ Meters.app
downloads: ~/.ansible-downloads/
tasks:
- include: ../install/{{ install_method }}.yml

View file

@ -1,14 +0,0 @@
---
- hosts: all
connection: local
vars:
app_name: nvALT
app_name_pretty: nvALT
app_url: "http://abyss.designheresy.com/nvaltb/nvalt2.2b106.zip"
installer_type: app
install_method: zip
downloads: ~/.ansible-downloads/
creates: /Applications/nvALT.app
tasks:
- include: ../install/{{ install_method }}.yml

View file

@ -1,16 +0,0 @@
---
- hosts: all
connection: local
vars:
app_name: PCKeyboardHack
app_name_pretty: PCKeyboardHack
app_url: "https://pqrs.org/macosx/keyremap4macbook/files/PCKeyboardHack-10.5.0.dmg"
installer_type: pkg
install_method: dmg
install_target: /Volumes/Macintosh\ HD
mount_path: /Volumes/PCKeyboardHack-10.5.0/
downloads: ~/.ansible-downloads/
creates: /Applications/PCKeyboardHack.app
tasks:
- include: ../install/{{ install_method }}.yml

View file

@ -1,15 +0,0 @@
---
- hosts: all
connection: local
vars:
app_name: Sequel\ Pro
app_name_pretty: Sequel Pro
app_url: "https://sequel-pro.googlecode.com/files/sequel-pro-1.0.2.dmg"
installer_type: app
install_method: dmg
mount_path: /Volumes/Sequel\ Pro\ 1.0.2/
downloads: ~/.ansible-downloads/
creates: /Applications/Sequel\ Pro.app
tasks:
- include: ../install/{{ install_method }}.yml

View file

@ -1,15 +0,0 @@
---
- hosts: all
connection: local
vars:
app_name: Skype
app_name_pretty: Skype
app_url: "http://www.skype.com/go/getskype-macosx.dmg"
installer_type: app
install_method: dmg
mount_path: /Volumes/Skype/
downloads: ~/.ansible-downloads/
creates: /Applications/Skype.app
tasks:
- include: ../install/{{ install_method }}.yml

View file

@ -1,36 +0,0 @@
---
# Sublime Text.
# Note: Currently, to complete installation, you have to manually install
# Package Control; see: https://sublime.wbond.net/installation.
- hosts: all
connection: local
vars:
app_name: Sublime\ Text
app_name_pretty: Sublime\ Text
app_url: "http://c758482.r82.cf2.rackcdn.com/Sublime%20Text%20Build%203059.dmg"
installer_type: app
install_method: dmg
mount_path: /Volumes/Sublime\ Text/
downloads: ~/.ansible-downloads/
creates: /Applications/Sublime\ Text.app
tasks:
- include: ../install/{{ install_method }}.yml
- name: Create symlink subl for Sublime Text's subl command
file: src=/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl dest=/usr/bin/subl state=link
sudo: true
- name: Create symlink sublime for Sublime Text's subl command
file: src=/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl dest=/usr/bin/sublime state=link
sudo: true
- name: Copy Sublime settings files.
copy: "src='../templates/sublime/{{ item }}' dest='~/Library/Application\ Support/Sublime\ Text 3/Packages/User/{{ item }}'"
sudo: no
with_items:
- "Default (OSX).sublime-keymap"
- "Package Control.sublime-settings"
- "Preferences.sublime-settings"
# - name: "Copy settings (example, don't use)."
# shell: cp -r init/Preferences.sublime-settings ~/Library/Application\ Support/Sublime\ Text*/Packages/User/Preferences.sublime-settings 2> /dev/null

View file

@ -1,14 +0,0 @@
---
- hosts: all
connection: local
vars:
app_name: Tower
app_name_pretty: Tower
app_url: "https://macapps.fournova.com/tower1-1060/download"
installer_type: app
install_method: zip
downloads: ~/.ansible-downloads/
creates: /Applications/Tower.app
tasks:
- include: ../install/{{ install_method }}.yml

View file

@ -1,14 +0,0 @@
---
- hosts: all
connection: local
vars:
app_name: Transmit
app_name_pretty: Transmit
app_url: "http://download.panic.com/transmit/Transmit%204.4.6.zip"
installer_type: app
install_method: zip
downloads: ~/.ansible-downloads/
creates: /Applications/Transmit.app
tasks:
- include: ../install/{{ install_method }}.yml

View file

@ -1,16 +0,0 @@
---
- hosts: all
connection: local
vars:
app_name: Vagrant
app_name_pretty: Vagrant
app_url: "https://dl.bintray.com/mitchellh/vagrant/Vagrant-1.4.3.dmg"
installer_type: pkg
install_method: dmg
install_target: /Volumes/Macintosh\ HD
mount_path: /Volumes/Vagrant/
downloads: ~/.ansible-downloads/
creates: /Applications/Vagrant/bin/vagrant
tasks:
- include: ../install/{{ install_method }}.yml

View file

@ -1,16 +0,0 @@
---
- hosts: all
connection: local
vars:
app_name: VirtualBox
app_name_pretty: VirtualBox
app_url: "http://download.virtualbox.org/virtualbox/4.3.6/VirtualBox-4.3.6-91406-OSX.dmg"
mount_path: /Volumes/VirtualBox/
installer_type: pkg
install_method: dmg
install_target: /Volumes/Macintosh\ HD
downloads: ~/.ansible-downloads/
creates: /Applications/VirtualBox.app
tasks:
- include: ../install/{{ install_method }}.yml

View file

@ -1,15 +0,0 @@
---
- hosts: all
connection: local
vars:
app_name: VLC
app_name_pretty: VLC
app_url: "http://get.videolan.org/vlc/2.1.3/macosx/vlc-2.1.3.dmg"
installer_type: app
install_method: dmg
mount_path: /Volumes/vlc-2.1.3/
downloads: ~/.ansible-downloads/
creates: /Applications/VLC.app
tasks:
- include: ../install/{{ install_method }}.yml

View file

@ -1,3 +0,0 @@
---
- name: Copy {{ app_name_pretty }} app to Applications directory
command: cp -R {{ app_name }}.app /Applications chdir={{ downloads }} creates=/Applications/{{ app_name }}.app

View file

@ -1,24 +0,0 @@
---
- name: Download {{ app_name_pretty }}
get_url: url={{ app_url }} dest={{ downloads }}/{{ app_name }}.dmg
- name: Mount {{ app_name_pretty }} image
command: hdiutil attach {{ app_name }}.dmg chdir={{ downloads }} creates={{ creates }}
- name: Copy {{ app_name_pretty }} app to Applications directory
command: cp -R {{ mount_path }}{{ app_name }}.app /Applications creates={{ creates }}
when: "installer_type == 'app'"
- name: Install {{ app_name_pretty }} pkg
command: installer -package {{ mount_path }}{{ app_name }}.pkg -target {{ install_target }} creates={{ creates }}
sudo: yes
when: "installer_type == 'pkg'"
- name: Check if image is mounted
shell: "[ -d {{ mount_path }} ] && echo '1' || echo '0'"
changed_when: false
register: mount_exists
- name: Unmount {{ app_name_pretty }} image
command: hdiutil detach {{ mount_path }}
when: "mount_exists.stdout == '1'"

View file

@ -1,3 +0,0 @@
---
- name: Install {{ app_name_pretty }} via Homebrew
homebrew: name={{ app_name }} state=installed update_homebrew=yes

View file

@ -1,4 +0,0 @@
---
# TODO: Idempotence.
- name: Install {{ app_name }} pkg
command: sudo installer -package {{ app_name }}.pkg -target {{ install_target }} creates={{ creates }}

View file

@ -1,20 +0,0 @@
---
- name: Download {{ app_name_pretty }}
get_url: url={{ app_url }} dest={{ downloads }}/{{ app_name }}.tar
- name: Remove existing extraction directory if present
file: path={{ downloads }}{{ app_name }}/ state=absent
- name: Create an extraction directory
file: path={{ downloads }}{{ app_name }}/ state=directory
- name: Extract {{ app_name_pretty }} tarball
command: tar xf {{ app_name }}.tar -C {{ app_name }}/ chdir={{ downloads }}
- name: Remove existing app if present
file: path=/Applications/{{ app_name }}.app state=absent
when: "installer_type == 'app'"
- name: Copy {{ app_name_pretty }} app to Applications directory
command: cp -R {{ app_name }}/{{ app_name }}.app /Applications chdir={{ downloads }}
when: "installer_type == 'app'"
- name: Install {{ app_name_pretty }} pkg
command: sudo installer -package {{ app_name }}/{{ app_name }}.pkg -target {{ install_target }} chdir={{ downloads }}
when: "installer_type == 'pkg'"
- name: Remove extraction directory
file: path={{ downloads }}{{ app_name }}/ state=absent

View file

@ -1,26 +0,0 @@
---
- name: Download {{ app_name_pretty }}
get_url: url={{ app_url }} dest={{ downloads }}/{{ app_name }}.zip
- name: Check if application is already installed.
shell: "[ -f {{ creates }} ] && echo '1' || echo '0'"
changed_when: false
register: installed
- name: Create an extraction directory
file: path={{ downloads }}{{ app_name }}/ state=directory
when: "installed.stdout == '1'"
- name: Extract {{ app_name_pretty }} zip archive
command: unzip {{ app_name }}.zip -d {{ app_name }}/ chdir={{ downloads }} creates={{ creates }}
- name: Copy {{ app_name_pretty }} app to Applications directory
command: cp -R {{ app_name }}/{{ app_name }}.app /Applications chdir={{ downloads }} creates={{ creates }}
when: "installer_type == 'app'"
- name: Install {{ app_name_pretty }} pkg
command: sudo installer -package {{ app_name }}/{{ app_name }}.pkg -target {{ install_target }} chdir={{ downloads }} creates={{ creates }}
when: "installer_type == 'pkg'"
- name: Ensure extraction directory is gone
file: path={{ downloads }}{{ app_name }}/ state=absent

View file

@ -1,34 +1,30 @@
---
- name: Mac Development Playbook
hosts: self
- hosts: self
user: jgeerling
connection: local
vars:
- downloads: ~/.ansible-downloads/
vars_files:
- vars/main.yml
roles:
- geerlingguy.homebrew
tasks:
- name: Create Ansible downloads directory
file: path={{ downloads }} state=directory
- include: preferences/dotfiles.yml
- include: preferences/preferences.yml
- name: Ensure Ansible downloads directory exists.
file:
path: "{{ downloads }}"
state: directory
- include: apps/adium.yml
- include: apps/chrome.yml
- include: apps/cornerstone.yml
- include: apps/dropbox.yml
- include: apps/firefox.yml
- include: apps/handbrake.yml
- include: apps/homebrew.yml
- include: apps/knock.yml
# - include: apps/menumeters.yml
- include: apps/nvalt.yml
- include: apps/pckeyboardhack.yml
- include: apps/sequel-pro.yml
- include: apps/skype.yml
- include: apps/sublime.yml
- include: apps/tower.yml
- include: apps/transmit.yml
- include: apps/vagrant.yml
- include: apps/virtualbox.yml
- include: apps/vlc.yml
- include: tasks/dotfiles.yml
- include: tasks/preferences.yml
- name: Get list of apps installed with cask.
command: brew cask list
register: homebrew_cask_list
changed_when: false
- name: Install apps via `brew cask`.
command: >
brew cask install {{ item }} --appdir={{ homebrew_cask_appdir }}
with_items: homebrew_cask_apps
when: "'{{ item }}' not in homebrew_cask_list.stdout"

View file

@ -1,29 +0,0 @@
---
# Install Jeff Geerling's dotfiles.
- name: Clone dotfiles repository into temporary location.
git: >
repo=https://github.com/geerlingguy/dotfiles.git
dest=~/Dropbox/Development/GitHub/dotfiles
sudo: no
- name: Check if .bash_profile is a link.
shell: ls -F ~/.bash_profile
register: is_link
changed_when: false
- name: Remove current .bash_profile file if necessary.
file: path=~/.bash_profile state=absent
when: "'@' not in is_link.stdout"
- name: Link dotfiles into home folder.
file: src=~/Dropbox/Development/GitHub/dotfiles/{{ item }} dest=~/{{ item }} state=link
sudo: no
with_items:
- .bash_profile
- .gitignore
- .inputrc
- .osx
- .vimrc
- name: Run .osx dotfiles.
shell: date

View file

@ -1,8 +0,0 @@
---
# Preferences.
# TODO: Idempotence, and set it as the default.
# - name: Add Terminal settings.
# shell: open templates/terminal/JJG-Term.terminal
# TODO: Make these happen.
# git config --global color.ui true

36
tasks/dotfiles.yml Normal file
View file

@ -0,0 +1,36 @@
---
# Install Jeff Geerling's dotfiles.
- name: Clone dotfiles repository (if it doesn't already exist).
git:
repo: https://github.com/geerlingguy/dotfiles.git
dest: ~/Dropbox/Development/GitHub/dotfiles
sudo: no
- name: Check if .bash_profile is a link.
shell: ls -F ~/.bash_profile
register: is_link
changed_when: false
- name: Remove current .bash_profile file if necessary.
file:
path: ~/.bash_profile
state: absent
when: "'@' not in is_link.stdout"
- name: Link dotfiles into home folder.
file:
src: "~/Dropbox/Development/GitHub/dotfiles/{{ item }}"
dest: "~/{{ item }}"
state: link
sudo: no
with_items:
- .bash_profile
- .gitignore
- .inputrc
- .osx
- .vimrc
# TODO - This requires sudo password (interactive prompt)... AND it restarts
# Terminal, thus ending the playbook run. D'oh!
# - name: Run .osx dotfiles.
# shell: ~/.osx

12
tasks/preferences.yml Normal file
View file

@ -0,0 +1,12 @@
---
# Preferences.
# TODO: Idempotence, and set it as the default.
# - name: Add Terminal settings.
# shell: open templates/terminal/JJG-Term.terminal
# TODO: Configure Sublime Text (see templates/sublime/*).
# TODO: Configure git (should this be in my .osx file, though?).
# git config --global color.ui true
# git config --global user.name "Jeff Geerling"
# git config --global user.email "geerlingguy@mac.com"

View file

@ -5,7 +5,6 @@
"DocBlockr",
"Drupal Snippets",
"FileDiffs",
"Git",
"GitHub Flavored Markdown Preview",
"Goto Documentation",
"Goto Drupal API",

51
vars/main.yml Normal file
View file

@ -0,0 +1,51 @@
---
downloads: ~/.ansible-downloads/
homebrew_installed_packages:
- autoconf
- gettext
- libevent
- packer
- python
- sqlite
- mysql
- phpunit
- ssh-copy-id
- cowsay
- ios-sim
- readline
- subversion
- kdiff3
- openssl
- pv
- wget
# - caskroom/cask/brew-cask
homebrew_taps:
- caskroom/cask
- homebrew/binary
- homebrew/dupes
- homebrew/php
- homebrew/versions
homebrew_cask_appdir: /Applications
homebrew_cask_apps:
- adium
- google-chrome
- dropbox
- firefox
- handbrake
- menumeters
- nvalt
- sequel-pro
- skype
- skitch
- sublime-text # Note - Sublime Text 2 only, at this time...
- tower
- transmit
- vlc
# TODO - Would these potentially break existing installs on current Mac?
# - vagrant
# - virtualbox
# TODO - No cask available (yet).
# Seil (https://pqrs.org/osx/karabiner/seil.html.en)