resolver playbook
change
commit bab1979d4b32442bb27d4f967f36a5b253a433a4
author Alpha Chen <alpha.chen@gmail.com>
date
parent 3b89b5cf
diff --git a/ansible/dnsmasq.yml b/ansible/dnsmasq.yml
new file mode 100644
index 00000000..689cfaf6
--- /dev/null
+++ b/ansible/dnsmasq.yml
@@ -0,0 +1,6 @@
+- hosts: dev
+  tasks:
+  - name: install dnsmasq
+    homebrew: name=dnsmasq state=present
+  - name: link conf files
+    command: chdir={{ ansible_env.HOME }}/.dotfiles stow --target=/usr/local/etc/dnsmasq.conf --stow {{ item }}
diff --git a/ansible/resolver.yml b/ansible/resolver.yml
new file mode 100644
index 00000000..0c8a973c
--- /dev/null
+++ b/ansible/resolver.yml
@@ -0,0 +1,32 @@
+---
+- hosts: all
+  vars:
+    dnsmasq_conf: "{{ ansible_env.HOME }}/Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist"
+  tasks:
+  - include: tasks/update_dotfiles.yml
+  - name: Install Dnsmasq
+    homebrew: name=dnsmasq state=present
+  - name: Stow dnsmasq.conf
+    command: chdir={{ ansible_env.HOME }}/.dotfiles stow --target=/usr/local/etc --stow dnsmasq
+  - name: Make local LaunchDaemons directory
+    file: path={{ ansible_env.HOME }}/Library/LaunchDaemons state=directory
+  - name: Delete old launchd config
+    sudo: True
+    file: path={{ dnsmasq_conf }} state=absent
+    # Copy the config instead of linking since it needs to be owned by root.
+  - name: Copy launchd config
+    sudo: True
+    command: cp /usr/local/opt/dnsmasq/homebrew.mxcl.dnsmasq.plist {{ dnsmasq_conf }}
+  - name: Fix launchd config permissions
+    sudo: True
+    file: path={{ ansible_env.HOME }}/Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist owner=root
+  - name: Load Dnsmasq
+    sudo: True
+    command: launchctl load {{ dnsmasq_conf }}
+  - name: Create /etc/resolver
+    sudo: True
+    file: path=/etc/resolver state=directory
+    # Link instead of stow since there's a stow bug with relative paths.
+  - name: Symlink /etc/resolver/dev
+    sudo: True
+    file: src={{ ansible_env.HOME }}/.dotfiles/resolver/dev dest=/etc/resolver/dev state=link
diff --git a/ansible/tasks/update_dotfiles.yml b/ansible/tasks/update_dotfiles.yml
new file mode 100644
index 00000000..3f29ba19
--- /dev/null
+++ b/ansible/tasks/update_dotfiles.yml
@@ -0,0 +1,3 @@
+---
+- name: clone/update dotfiles
+  git: repo=https://github.com/kejadlen/dotfiles.git dest=~/.dotfiles