[meta] Update OS X Ansible role

Add a bootstrap role to update `~/.dotfiles` and run `sudo` once (so that
Homebrew's internal `sudo` calls work).

Also allow for running Ansible from a remote computer onto the target
Mac.
pull/28/head
Alpha Chen 10 years ago
parent 1fb4714116
commit d07e57d664

@ -3,11 +3,34 @@ A new beginning for what used to be my
appears to be the conventional name of these types of repos nowadays. appears to be the conventional name of these types of repos nowadays.
This uses [Ansible](https://github.com/ansible/ansible) to provision new This uses [Ansible](https://github.com/ansible/ansible) to provision new
machines and [stow](http://www.gnu.org/software/stow/) for managing conf machines.
files that can be symlinked.
# Usage # Usage
There are two ways to go about using this - either locally or remotely. The main
difference is that OS X application settings are only copied over when running
this on a remote machine.
Either way, we start with installing Xcode:
``` shell
xcode-select --install
open 'https://itunes.apple.com/us/app/xcode/id497799835?mt=12'
sudo xcodebuild -license
```
**After running Ansible**, the bootstrap `~/.dotfiles` directory can be removed
and replaced with a symlink to the canonical repo location on Dropbox and SSH
keys can be populated with the included script:
``` shell
rm -rf ~/.dotfiles
ln -s ~/Dropbox/dotfiles ~/.dotfiles
ruby ~/.dotfiles/ansible/scripts/setup_ssh_keys.rb
```
## Local
``` shell ``` shell
# Install Homebrew # Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@ -18,20 +41,23 @@ brew install ansible
# Clone dotfiles # Clone dotfiles
git clone --recursive https://github.com/kejadlen/dotfiles.git ~/.dotfiles git clone --recursive https://github.com/kejadlen/dotfiles.git ~/.dotfiles
# Xcode
open 'https://itunes.apple.com/us/app/xcode/id497799835?mt=12'
sudo xcodebuild -license
# Run Ansible # Run Ansible
cd ~/.dotfiles/ansible && ansible-playbook main.yml --ask-sudo-pass cd ~/.dotfiles/ansible && ansible-playbook main.yml --ask-sudo-pass
rm -f ~/*.retry rm -f ~/*.retry
```
# Post-Dropbox syncing ## Remote
rm -rf ~/.dotfiles
ln -s ~/Dropbox/dotfiles ~/.dotfiles On the remote machine, SSH access must first be enabled (under System
ruby ~/.dotfiles/ansible/scripts/setup_ssh_keys.rb Preferences -> Sharing) and the Xcode Command Line Tools need to be installed
(`xcode-select --install`).
``` shell
cd ~/.dotfiles/ansible && ansible-playbook main.yml --ask-pass --ask-sudo-pass
``` ```
# Misc
To update submodules: To update submodules:
``` shell ``` shell

@ -1,5 +1,5 @@
- hosts: local - hosts: all
connection: local
roles: roles:
- bootstrap
- osx - osx
- dotfiles # - dotfiles

@ -0,0 +1,9 @@
---
- git:
repo: https://github.com/kejadlen/dotfiles.git
recursive: yes
dest: ~/.dotfiles
force: no
- name: no-op so that sudo works in Homebrew later
ping:
sudo: True

@ -7,12 +7,6 @@
- stow - stow
sudo: True sudo: True
when: ansible_os_family == "Debian" when: ansible_os_family == "Debian"
- git:
repo: https://github.com/kejadlen/dotfiles.git
depth: 1
dest: ~/.dotfiles
recursive: yes
force: no
- command: > - command: >
chdir={{ ansible_env.HOME }}/.dotfiles chdir={{ ansible_env.HOME }}/.dotfiles
stow --stow --target={{ ansible_env.HOME }} {{ item }} stow --stow --target={{ ansible_env.HOME }} {{ item }}

@ -0,0 +1,10 @@
---
- name: ensure that Xcode is installed
command: command -v xcodebuild
- stat: path=/usr/local/bin/brew
register: brew
ignore_errors: True
- name: install homebrew
shell: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
when: brew.stat.exists == False

@ -1,11 +1,11 @@
--- ---
- include_vars: casks.yml - include_vars: casks.yml
- file: path={{ ansible_env.HOME }}/Applications state=directory - file: path={{ ansible_env.HOME }}/Applications state=directory
# - homebrew: name=caskroom/cask/brew-cask state=upgraded # - homebrew: name=caskroom/cask/brew-cask state=upgraded
- homebrew_tap: name=caskroom/cask state=present - homebrew_tap: name=caskroom/cask state=present
- homebrew: name=brew-cask state=present - homebrew: name=brew-cask state=present
- homebrew_cask: name={{ item }} state=installed - homebrew_cask: name={{ item }} state=installed
with_items: casks with_items: casks
- command: defaults write {{ item }}
with_items:
- com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false

@ -1,9 +1,9 @@
--- ---
- include_vars: defaults.yml - include_vars: defaults.yml
# - command: defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -int 1
# sudo: True
- command: defaults write {{ item }} - command: defaults write {{ item }}
with_items: osx_defaults with_items: osx_defaults
- command: defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -bool true # tap to click - command: defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -bool true # tap to click
# - command: defaults write {{ item }} dontAutoLoad -array # - command: defaults write {{ item }} dontAutoLoad -array
# /System/Library/CoreServices/Menu Extras/TimeMachine.menu # /System/Library/CoreServices/Menu Extras/TimeMachine.menu
@ -15,6 +15,7 @@
# - Set :DesktopViewSettings:IconViewSettings:arrangeBy grid # - Set :DesktopViewSettings:IconViewSettings:arrangeBy grid
# - Set :FK_StandardViewSettings:IconViewSettings:arrangeBy grid # - Set :FK_StandardViewSettings:IconViewSettings:arrangeBy grid
# - Set :StandardViewSettings:IconViewSettings:arrangeBy grid # - Set :StandardViewSettings:IconViewSettings:arrangeBy grid
- command: killall {{ item }} - command: killall {{ item }}
with_items: with_items:
- Finder - Finder

@ -1,7 +1,7 @@
--- ---
- homebrew: name=dockutil state=present - homebrew: name=dockutil state=present
- command: dockutil --remove all - command: /usr/local/bin/dockutil --remove all
- command: dockutil --add ~/Downloads --view list - command: /usr/local/bin/dockutil --add ~/Downloads --view list
--display stack --display stack
--sort datemodified --sort datemodified
- homebrew: name=dockutil state=absent - homebrew: name=dockutil state=absent

@ -1,5 +1,7 @@
--- ---
- include_vars: fonts.yml - include_vars: fonts.yml
- homebrew_tap: tap=caskroom/fonts state=present - homebrew_tap: tap=caskroom/fonts state=present
- homebrew_cask: name={{ item }} state=installed - homebrew_cask: name={{ item }} state=installed
with_items: fonts with_items: fonts

@ -1,6 +1,8 @@
--- ---
- include_vars: formulae.yml - include_vars: formulae.yml
- homebrew: name={{ item }} state=present - homebrew:
name: "{{ item.name }}"
install_options: "{{ item.install_options | default(omit) }}"
state: present
with_items: formulae with_items: formulae
- homebrew: name=macvim install_options=override-system-vim state=present - command: /usr/local/bin/brew linkapps
- command: brew linkapps

@ -1,11 +1,14 @@
--- ---
- homebrew: update_homebrew=yes - include: bootstrap.yml
- include: formulae.yml - include: formulae.yml
- include: dock.yml - include: dock.yml
- include: casks.yml - include: casks.yml
- include: fonts.yml - include: fonts.yml
- include: defaults.yml - include: defaults.yml
- file: path=~/Library/KeyBindings state=directory
- copy: src=.tmux.conf.local dest=~/.tmux.conf.local # - copy: src=.tmux.conf.local dest=~/.tmux.conf.local
- copy: src=DefaultKeyBinding.dict dest=~/Library/KeyBindings/DefaultKeyBinding.dict
- command: open ~/.dotfiles/Alpha.terminal # - file: path=~/Library/KeyBindings state=directory
# - copy: src=DefaultKeyBinding.dict dest=~/Library/KeyBindings/DefaultKeyBinding.dict
# - command: open ~/.dotfiles/Alpha.terminal

@ -1,5 +1,6 @@
--- ---
casks: casks:
- 1password
- adium - adium
- alfred - alfred
- bittorrent-sync - bittorrent-sync
@ -11,7 +12,6 @@ casks:
- google-chrome - google-chrome
- mailbox - mailbox
- moom - moom
- onepassword
- plug - plug
- qlmarkdown - qlmarkdown
- qlstephen - qlstephen

@ -1,5 +1,8 @@
--- ---
osx_defaults: # named osx_defaults since there's an Ansible conflict w/defaults osx_defaults:
# This is named `osx_defaults` since there's an Ansible conflict when this key
# is named just `defaults`.
- -g NSDisableAutomaticTermination -bool true # Don't quit idle applications - -g NSDisableAutomaticTermination -bool true # Don't quit idle applications
- NSGlobalDomain AppleFontSmoothing -int 2 # subpixel rendering on non-Apple LCDs - NSGlobalDomain AppleFontSmoothing -int 2 # subpixel rendering on non-Apple LCDs
@ -19,9 +22,6 @@ osx_defaults: # named osx_defaults since there's an Ansible conflict w/defaults
- com.apple.dock mineffect -string scale # minimize windows using the scale effect - com.apple.dock mineffect -string scale # minimize windows using the scale effect
- com.apple.dock mru-spaces -bool false # don't rearrange spaces - com.apple.dock mru-spaces -bool false # don't rearrange spaces
- com.apple.dock orientation -string left - com.apple.dock orientation -string left
# - com.apple.dock pinning -string start # don't center the dock
# - com.apple.dock showhidden -bool true # translucent icons for hidden apps
# - com.apple.dock workspaces-auto-swoosh -bool false # don't switch to a space w/open windows for the app
- com.apple.dock wvous-bl-corner -int 10 # set the bottom left hot corner to sleep the display - com.apple.dock wvous-bl-corner -int 10 # set the bottom left hot corner to sleep the display
- com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true - com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
- com.apple.driver.AppleBluetoothMultitouch.trackpad DragLock -int 1 - com.apple.driver.AppleBluetoothMultitouch.trackpad DragLock -int 1
@ -30,17 +30,9 @@ osx_defaults: # named osx_defaults since there's an Ansible conflict w/defaults
- com.apple.finder FXEnableExtensionChangeWarning -bool false # don't ask when changing file extension - com.apple.finder FXEnableExtensionChangeWarning -bool false # don't ask when changing file extension
- com.apple.finder FXPreferredViewStyle -string Nlsv # default to list view - com.apple.finder FXPreferredViewStyle -string Nlsv # default to list view
- com.apple.finder QLEnableTextSelection -bool true # enable text selection in QuickLook - com.apple.finder QLEnableTextSelection -bool true # enable text selection in QuickLook
# - com.apple.finder ShowPathbar -bool true # show path bar
# - com.apple.finder ShowStatusBar -bool true # show status bar
- com.apple.finder _FXShowPosixPathInTitle -bool true # show full path in Finder - com.apple.finder _FXShowPosixPathInTitle -bool true # show full path in Finder
# - com.apple.gamed Disabled -bool true
# - com.apple.iTunes NSUserKeyEquivalents -dict-add "Target Search Field" "@F" # remap cmd+f to find in iTunes
# - com.apple.iTunes invertStoreLinks -bool true
- com.apple.screencapture disable-shadow -bool true # no window shadows when capturing windows - com.apple.screencapture disable-shadow -bool true # no window shadows when capturing windows
- com.apple.screencapture location ~/Downloads - com.apple.screencapture location ~/Downloads
- com.apple.screensaver askForPassword -int 1 - com.apple.screensaver askForPassword -int 1
# - com.apple.systemuiserver menuExtras -array
# "/System/Library/CoreServices/Menu Extras/AirPort.menu" - com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false
# "/System/Library/CoreServices/Menu Extras/Volume.menu"
# "/System/Library/CoreServices/Menu Extras/Clock.menu"
# - com.apple.terminal StringEncodings -array 4 # UTF-8 in Terminal

@ -1,16 +1,16 @@
--- ---
formulae: formulae:
- chruby - name: chruby
- ctags - name: ctags
- direnv - name: direnv
- fasd - name: fasd
- git - name: git
- hub - name: macvim
# - macvim # Needs install_options=override-system-vim install_options: override-system-vim
- ruby-install - name: ruby-install
- reattach-to-user-namespace - name: reattach-to-user-namespace
- the_silver_searcher - name: the_silver_searcher
- tmux - name: tmux
- tree - name: tree
- youtube-dl - name: youtube-dl
- zsh - name: zsh

Loading…
Cancel
Save