From bab1979d4b32442bb27d4f967f36a5b253a433a4 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Thu, 26 Jun 2014 21:46:22 -0700 Subject: [PATCH] resolver playbook --- ansible/dnsmasq.yml | 6 ++++++ ansible/resolver.yml | 32 +++++++++++++++++++++++++++++++ ansible/tasks/update_dotfiles.yml | 3 +++ 3 files changed, 41 insertions(+) create mode 100644 ansible/dnsmasq.yml create mode 100644 ansible/resolver.yml create mode 100644 ansible/tasks/update_dotfiles.yml diff --git a/ansible/dnsmasq.yml b/ansible/dnsmasq.yml new file mode 100644 index 0000000..689cfaf --- /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 0000000..0c8a973 --- /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 0000000..3f29ba1 --- /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