diff --git a/README.md b/README.md index 5e976f1..54041c8 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,12 @@ This is very much a work in progress, and is mostly a means for me to document m **Caveat**: This set of playbooks is not meant to be a great example of Ansible best practices. I just want to wrap my Mac's configuration in Ansible so I can quickly bring up a new development Mac without having to restore from a Time Machine backup. +## Installation + + 1. Clone this repository somewhere. + 2. Install Ansible. + 3. Run `ansible-playbook main.yml --ask-sudo-pass`. + ## Additions coming soon ### General changes: @@ -16,11 +22,15 @@ This is very much a work in progress, and is mostly a means for me to document m - Cornerstone SVN - Tower (Git) + - MenuMeters + - nvAlt - PCKeyboardHack + - My dotfiles - etc... ### Settings to be added: + - Terminal theme (Jeff's OSX) - Sublime text settings/package manager - Keyboard remappings (Caps Lock -> escape) - Faster key repeat rates diff --git a/apps/chrome.yml b/apps/chrome.yml index b9b3977..314918a 100644 --- a/apps/chrome.yml +++ b/apps/chrome.yml @@ -1,6 +1,6 @@ --- -- hosts: {{ hosts }} - user: {{ user }} +- hosts: all + connection: local vars: app_name: Google\ Chrome app_name_pretty: Google Chrome @@ -8,8 +8,7 @@ installer_type: app install_method: dmg mount_path: /Volumes/Google\ Chrome/ - vars_files: - - ../setup-vars.yml + downloads: ~/.ansible-downloads/ + tasks: - - include: ../setup.yml - include: ../install/{{ install_method }}.yml \ No newline at end of file diff --git a/apps/firefox.yml b/apps/firefox.yml index 18c1210..c5fcf9f 100644 --- a/apps/firefox.yml +++ b/apps/firefox.yml @@ -1,6 +1,6 @@ --- -- hosts: {{ hosts }} - user: {{ user }} +- hosts: all + connection: local vars: app_name: Firefox app_name_pretty: Firefox @@ -8,8 +8,7 @@ installer_type: app install_method: dmg mount_path: /Volumes/Firefox/ - vars_files: - - ../setup-vars.yml + downloads: ~/.ansible-downloads/ + tasks: - - include: ../setup.yml - include: ../install/{{ install_method }}.yml \ No newline at end of file diff --git a/apps/handbrake.yml b/apps/handbrake.yml index 80c8b1e..4b611ec 100644 --- a/apps/handbrake.yml +++ b/apps/handbrake.yml @@ -1,6 +1,6 @@ --- -- hosts: {{ hosts }} - user: {{ user }} +- hosts: all + connection: local vars: app_name: HandBrake app_name_pretty: HandBrake @@ -8,8 +8,7 @@ installer_type: app install_method: dmg mount_path: /Volumes/HandBrake-0.9.9-MacOSX.6_GUI_x86_64/ - vars_files: - - ../setup-vars.yml + downloads: ~/.ansible-downloads/ + tasks: - - include: ../setup.yml - include: ../install/{{ install_method }}.yml \ No newline at end of file diff --git a/apps/homebrew.yml b/apps/homebrew.yml index 523f78d..db978bc 100644 --- a/apps/homebrew.yml +++ b/apps/homebrew.yml @@ -1,10 +1,6 @@ --- -- hosts: {{ hosts }} - user: {{ user }} - gather_facts: false - vars_files: - - ../setup-vars.yml +- hosts: all + connection: local tasks: - - include: ../setup.yml - name: Run Homebrew install script shell: ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" \ No newline at end of file diff --git a/apps/sequel-pro.yaml b/apps/sequel-pro.yml similarity index 73% rename from apps/sequel-pro.yaml rename to apps/sequel-pro.yml index cea151f..744c3c4 100644 --- a/apps/sequel-pro.yaml +++ b/apps/sequel-pro.yml @@ -1,6 +1,6 @@ --- -- hosts: {{ hosts }} - user: {{ user }} +- hosts: all + connection: local vars: app_name: Sequel\ Pro app_name_pretty: Sequel Pro @@ -8,8 +8,7 @@ installer_type: app install_method: dmg mount_path: /Volumes/Sequel\ Pro\ 1.0.2/ - vars_files: - - ../setup-vars.yml + downloads: ~/.ansible-downloads/ + tasks: - - include: ../setup.yml - include: ../install/{{ install_method }}.yml \ No newline at end of file diff --git a/apps/sublime.yml b/apps/sublime.yml index c18d6b0..8b6c7a2 100644 --- a/apps/sublime.yml +++ b/apps/sublime.yml @@ -1,6 +1,6 @@ --- -- hosts: {{ hosts }} - user: {{ user }} +- hosts: all + connection: local vars: app_name: Sublime\ Text app_name_pretty: Sublime\ Text @@ -8,12 +8,13 @@ installer_type: app install_method: dmg mount_path: /Volumes/Sublime\ Text/ - vars_files: - - ../setup-vars.yml + downloads: ~/.ansible-downloads/ + tasks: - - include: ../setup.yml - 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 \ No newline at end of file + file: src=/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl dest=/usr/bin/sublime state=link + sudo: true \ No newline at end of file diff --git a/apps/transmit.yml b/apps/transmit.yml index c5d3ada..18db2ec 100644 --- a/apps/transmit.yml +++ b/apps/transmit.yml @@ -1,14 +1,13 @@ --- -- hosts: {{ hosts }} - user: {{ user }} +- 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 - vars_files: - - ../setup-vars.yml + downloads: ~/.ansible-downloads/ + tasks: - - include: ../setup.yml - include: ../install/{{ install_method }}.yml \ No newline at end of file diff --git a/apps/vagrant.yml b/apps/vagrant.yml index 43151f6..32181f6 100644 --- a/apps/vagrant.yml +++ b/apps/vagrant.yml @@ -1,16 +1,15 @@ --- -- hosts: {{ hosts }} - user: {{ user }} +- 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/OSX + install_target: /Volumes/Macintosh\ HD mount_path: /Volumes/Vagrant/ - vars_files: - - ../setup-vars.yml + downloads: ~/.ansible-downloads/ + tasks: - - include: ../setup.yml - - include: ../install/{{ install_method }}.pkg \ No newline at end of file + - include: ../install/{{ install_method }}.yml \ No newline at end of file diff --git a/apps/virtualbox.yml b/apps/virtualbox.yml index a855d08..36da738 100644 --- a/apps/virtualbox.yml +++ b/apps/virtualbox.yml @@ -1,8 +1,6 @@ --- -- include: ../setup.yml - -- hosts: {{ hosts }} - user: {{ user }} +- hosts: all + connection: local vars: app_name: VirtualBox app_name_pretty: VirtualBox @@ -10,8 +8,8 @@ mount_path: /Volumes/VirtualBox/ installer_type: pkg install_method: dmg - install_target: /Volumes/OSX - vars_files: - - ../setup-vars.yml + install_target: /Volumes/Macintosh\ HD + downloads: ~/.ansible-downloads/ + tasks: - include: ../install/{{ install_method }}.yml \ No newline at end of file diff --git a/apps/vlc.yml b/apps/vlc.yml index 2615e6e..d2af74e 100644 --- a/apps/vlc.yml +++ b/apps/vlc.yml @@ -1,6 +1,6 @@ --- -- hosts: {{ hosts }} - user: {{ user }} +- hosts: all + connection: local vars: app_name: VLC app_name_pretty: VLC @@ -8,8 +8,7 @@ installer_type: app install_method: dmg mount_path: /Volumes/vlc-2.1.3/ - vars_files: - - ../setup-vars.yml + downloads: ~/.ansible-downloads/ + tasks: - - include: ../setup.yml - include: ../install/{{ install_method }}.yml \ No newline at end of file diff --git a/install/app.yml b/install/app.yml index b6261a3..dfcd9f2 100644 --- a/install/app.yml +++ b/install/app.yml @@ -1,5 +1,3 @@ --- -- name: Remove existing app if present - file: path=/Applications/{{ app_name }}.app state=absent - name: Copy {{ app_name_pretty }} app to Applications directory - command: cp -R {{ app_name }}.app /Applications chdir={{ downloads }} \ No newline at end of file + command: cp -R {{ app_name }}.app /Applications chdir={{ downloads }} creates=/Applications/{{ app_name }}.app \ No newline at end of file diff --git a/install/dmg.yml b/install/dmg.yml index 831c554..99de8b8 100644 --- a/install/dmg.yml +++ b/install/dmg.yml @@ -1,16 +1,16 @@ --- - name: Download {{ app_name_pretty }} get_url: url={{ app_url }} dest={{ downloads }}/{{ app_name }}.dmg +# TODO: Idempotence. - name: Mount {{ app_name_pretty }} image command: hdiutil attach {{ app_name }}.dmg chdir={{ downloads }} -- name: Remove existing app if present - file: path=/Applications/{{ app_name }}.app state=absent - when_string: {{ installer_type }} == 'app' - name: Copy {{ app_name_pretty }} app to Applications directory - command: cp -R {{ mount_path }}{{ app_name }}.app /Applications - when_string: {{ installer_type }} == 'app' + command: cp -R {{ mount_path }}{{ app_name }}.app /Applications creates=/Applications/{{ app_name }}.app + when: "installer_type == 'app'" - name: Install {{ app_name_pretty }} pkg - command: sudo installer -package {{ mount_path }}{{ app_name }}.pkg -target {{ install_target }} - when_string: {{ installer_type }} == 'pkg' + command: installer -package {{ mount_path }}{{ app_name }}.pkg -target {{ install_target }} + sudo: yes + when: "installer_type == 'pkg'" +# TODO: Idempotence. - name: Unmount {{ app_name_pretty }} image command: hdiutil detach {{ mount_path }} \ No newline at end of file diff --git a/install/pkg.yml b/install/pkg.yml index 654468f..2cb806b 100644 --- a/install/pkg.yml +++ b/install/pkg.yml @@ -1,3 +1,4 @@ --- +# TODO: Idempotence. - name: Install {{ app_name }} pkg command: sudo installer -package {{ app_name }}.pkg -target {{ install_target }} \ No newline at end of file diff --git a/install/tar.yml b/install/tar.yml index 1818d53..2f084a1 100644 --- a/install/tar.yml +++ b/install/tar.yml @@ -9,12 +9,12 @@ 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_string: {{ installer_type }} == 'app' + 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_string: {{ installer_type }} == 'app' + 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_string: {{ installer_type }} == 'pkg' + when: "installer_type == 'pkg'" - name: Remove extraction directory file: path={{ downloads }}{{ app_name }}/ state=absent \ No newline at end of file diff --git a/install/zip.yml b/install/zip.yml index e7426fa..b212685 100644 --- a/install/zip.yml +++ b/install/zip.yml @@ -9,12 +9,12 @@ command: unzip {{ app_name }}.zip -d {{ app_name }}/ chdir={{ downloads }} - name: Remove existing app if present file: path=/Applications/{{ app_name }}.app state=absent - when_string: {{ installer_type }} == 'app' + 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_string: {{ installer_type }} == 'app' + 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_string: {{ installer_type }} == 'pkg' + when: "installer_type == 'pkg'" - name: Remove extraction directory file: path={{ downloads }}{{ app_name }}/ state=absent \ No newline at end of file diff --git a/main.yml b/main.yml index 69e4209..27e9a9a 100644 --- a/main.yml +++ b/main.yml @@ -1,4 +1,16 @@ --- +- name: Mac Development Playbook + hosts: self + user: jgeerling + connection: local + + vars: + - downloads: ~/.ansible-downloads/ + + tasks: + - name: Create Ansible downloads directory + file: path={{ downloads }} state=directory + - include: apps/chrome.yml - include: apps/firefox.yml - include: apps/handbrake.yml diff --git a/setup-vars.yml b/setup-vars.yml deleted file mode 100644 index 88587e9..0000000 --- a/setup-vars.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -downloads: /.ansible-downloads/ \ No newline at end of file diff --git a/setup.yml b/setup.yml deleted file mode 100644 index f74285c..0000000 --- a/setup.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: Create Ansible downloads directory - file: path={{ downloads }} state=directory \ No newline at end of file