[meta] Use with_fileglob, fix up defaults playbook
Use `with_fileglob` instead of hacking `with_items` to use `ls`.
Use handlers to only restart OS X services if defaults have changed.
diff --git a/ansible/roles/dotfiles/tasks/dotfiles.yml b/ansible/roles/dotfiles/tasks/dotfiles.yml
index 80941658..ecce06bb 100644
--- a/ansible/roles/dotfiles/tasks/dotfiles.yml
+++ b/ansible/roles/dotfiles/tasks/dotfiles.yml
@@ -12,5 +12,5 @@
state: link
force: yes # Since these won't exist until later.
with_dict: private
-- file: src=~/.dotfiles/.ssh/{{ item }} dest=~/.ssh/{{ item }} state=link
- with_lines: ls ~/.dotfiles/.ssh
+- file: src={{ item }} dest=~/.ssh/{{ item | basename }} state=link
+ with_fileglob: ~/.dotfiles/.ssh/*
diff --git a/ansible/roles/dotfiles/tasks/powerline.yml b/ansible/roles/dotfiles/tasks/powerline.yml
index 0fd9d057..b1b683ba 100644
--- a/ansible/roles/dotfiles/tasks/powerline.yml
+++ b/ansible/roles/dotfiles/tasks/powerline.yml
@@ -12,8 +12,5 @@
install
--user
--editable={{ ansible_env.HOME }}/.dotfiles/src/powerline
-- file:
- src: ~/.dotfiles/src/powerline/scripts/{{ item }}
- dest: /usr/local/bin/{{ item }}
- state: link
- with_lines: ls ~/.dotfiles/src/powerline/scripts
+- file: src={{ item }} dest=/usr/local/bin/{{ item | basename }} state=link
+ with_fileglob: ~/.dotfiles/src/powerline/scripts/*
diff --git a/ansible/roles/osx/handlers/main.yml b/ansible/roles/osx/handlers/main.yml
new file mode 100644
index 00000000..eb641b85
--- /dev/null
+++ b/ansible/roles/osx/handlers/main.yml
@@ -0,0 +1,6 @@
+- name: restart osx system services
+ command: killall {{ item }}
+ with_items:
+ - Finder
+ - Dock
+ - SystemUIServer
diff --git a/ansible/roles/osx/tasks/defaults.yml b/ansible/roles/osx/tasks/defaults.yml
index dfc3f9a3..7fb21ed8 100644
--- a/ansible/roles/osx/tasks/defaults.yml
+++ b/ansible/roles/osx/tasks/defaults.yml
@@ -1,29 +1,10 @@
---
- include_vars: defaults.yml
-# - command: defaults write {{ item }}
- osx_defaults:
domain: "{{ item.domain | default(omit) }}"
key: "{{ item.key }}"
type: "{{ item.type }}"
value: "{{ item.value }}"
with_items: osx_defaults
-
-# - command: defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -bool true # tap to click
-
-# - command: defaults write {{ item }} dontAutoLoad -array
-# /System/Library/CoreServices/Menu Extras/TimeMachine.menu
-# /System/Library/CoreServices/Menu Extras/Bluetooth.menu
-# /System/Library/CoreServices/Menu Extras/Battery.menu
-# with_lines: ls ~/Library/Preferences/ByHost/com.apple.systemuiserver.*
-# - command: /usr/libexec/PlistBuddy -c "{{ item }}" ~/Library/Preferences/com.apple.finder.plist
-# with_items:
-# - Set :DesktopViewSettings:IconViewSettings:arrangeBy grid
-# - Set :FK_StandardViewSettings:IconViewSettings:arrangeBy grid
-# - Set :StandardViewSettings:IconViewSettings:arrangeBy grid
-
-# - command: killall {{ item }}
-# with_items:
-# - Finder
-# - Dock
-# - SystemUIServer
+ notify: restart osx system services
diff --git a/ansible/roles/osx/vars/defaults.yml b/ansible/roles/osx/vars/defaults.yml
index c72b112d..8fb50324 100644
--- a/ansible/roles/osx/vars/defaults.yml
+++ b/ansible/roles/osx/vars/defaults.yml
@@ -135,7 +135,7 @@ osx_defaults:
- domain: com.apple.screencapture
key: location
type: string
- value: ~/Downloads
+ value: "{{ ansible_env.HOME }}/Downloads"
- domain: com.apple.screensaver
key: askForPassword