test_pivotal_workstation 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/.gitignore +3 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.markdown +31 -0
  5. data/Rakefile +1 -0
  6. data/lib/test_pivotal_workstation.rb +5 -0
  7. data/lib/test_pivotal_workstation/attributes/default.rb +20 -0
  8. data/lib/test_pivotal_workstation/attributes/git_pairs.rb +5 -0
  9. data/lib/test_pivotal_workstation/attributes/git_projects.rb +3 -0
  10. data/lib/test_pivotal_workstation/attributes/github_for_mac.rb +4 -0
  11. data/lib/test_pivotal_workstation/attributes/gitx.rb +1 -0
  12. data/lib/test_pivotal_workstation/attributes/mouse_locator.rb +5 -0
  13. data/lib/test_pivotal_workstation/attributes/nginx.rb +11 -0
  14. data/lib/test_pivotal_workstation/attributes/pg_admin.rb +4 -0
  15. data/lib/test_pivotal_workstation/attributes/rvm.rb +8 -0
  16. data/lib/test_pivotal_workstation/attributes/sizeup.rb +1 -0
  17. data/lib/test_pivotal_workstation/attributes/versions.rb +6 -0
  18. data/lib/test_pivotal_workstation/attributes/vim.rb +2 -0
  19. data/lib/test_pivotal_workstation/attributes/workspace_directory.rb +1 -0
  20. data/lib/test_pivotal_workstation/libraries/applescript.rb +5 -0
  21. data/lib/test_pivotal_workstation/libraries/bash_profile_include.rb +11 -0
  22. data/lib/test_pivotal_workstation/libraries/brew.rb +38 -0
  23. data/lib/test_pivotal_workstation/libraries/directories.rb +25 -0
  24. data/lib/test_pivotal_workstation/libraries/marker.rb +42 -0
  25. data/lib/test_pivotal_workstation/libraries/osx_app.rb +97 -0
  26. data/lib/test_pivotal_workstation/libraries/rvm_ruby_install.rb +36 -0
  27. data/lib/test_pivotal_workstation/libraries/user.rb +4 -0
  28. data/lib/test_pivotal_workstation/libraries/version.rb +9 -0
  29. data/lib/test_pivotal_workstation/providers/package.rb +95 -0
  30. data/lib/test_pivotal_workstation/recipes/ack.rb +1 -0
  31. data/lib/test_pivotal_workstation/recipes/active_corners.rb +24 -0
  32. data/lib/test_pivotal_workstation/recipes/activemq.rb +1 -0
  33. data/lib/test_pivotal_workstation/recipes/bash_path_order.rb +13 -0
  34. data/lib/test_pivotal_workstation/recipes/bash_profile-arch_flags.rb +1 -0
  35. data/lib/test_pivotal_workstation/recipes/bash_profile-better_history.rb +1 -0
  36. data/lib/test_pivotal_workstation/recipes/bash_profile-no_sudo_gem_install.rb +1 -0
  37. data/lib/test_pivotal_workstation/recipes/bash_profile-ps1.rb +1 -0
  38. data/lib/test_pivotal_workstation/recipes/bash_profile-ree_settings.rb +1 -0
  39. data/lib/test_pivotal_workstation/recipes/bash_profile.rb +11 -0
  40. data/lib/test_pivotal_workstation/recipes/ccmenu.rb +6 -0
  41. data/lib/test_pivotal_workstation/recipes/chrome.rb +6 -0
  42. data/lib/test_pivotal_workstation/recipes/default_editor.rb +55 -0
  43. data/lib/test_pivotal_workstation/recipes/defaults_fast_key_repeat_rate.rb +10 -0
  44. data/lib/test_pivotal_workstation/recipes/disable_front_row.rb +4 -0
  45. data/lib/test_pivotal_workstation/recipes/dock_preferences.rb +13 -0
  46. data/lib/test_pivotal_workstation/recipes/dropbox.rb +6 -0
  47. data/lib/test_pivotal_workstation/recipes/ec2_api_tools.rb +3 -0
  48. data/lib/test_pivotal_workstation/recipes/finder_display_full_path.rb +4 -0
  49. data/lib/test_pivotal_workstation/recipes/firefox.rb +5 -0
  50. data/lib/test_pivotal_workstation/recipes/gem_no_rdoc_no_ri.rb +14 -0
  51. data/lib/test_pivotal_workstation/recipes/git.rb +8 -0
  52. data/lib/test_pivotal_workstation/recipes/git_config_global_defaults.rb +72 -0
  53. data/lib/test_pivotal_workstation/recipes/git_projects.rb +29 -0
  54. data/lib/test_pivotal_workstation/recipes/git_scripts.rb +19 -0
  55. data/lib/test_pivotal_workstation/recipes/github_for_mac.rb +25 -0
  56. data/lib/test_pivotal_workstation/recipes/github_ssh_keys.rb +16 -0
  57. data/lib/test_pivotal_workstation/recipes/gitx.rb +56 -0
  58. data/lib/test_pivotal_workstation/recipes/global_environment_variables.rb +3 -0
  59. data/lib/test_pivotal_workstation/recipes/google_chrome_prevent_updates.rb +10 -0
  60. data/lib/test_pivotal_workstation/recipes/homebrew.rb +27 -0
  61. data/lib/test_pivotal_workstation/recipes/imagemagick.rb +3 -0
  62. data/lib/test_pivotal_workstation/recipes/inputrc.rb +6 -0
  63. data/lib/test_pivotal_workstation/recipes/iterm_set_defaults.rb +167 -0
  64. data/lib/test_pivotal_workstation/recipes/java.rb +8 -0
  65. data/lib/test_pivotal_workstation/recipes/joe.rb +3 -0
  66. data/lib/test_pivotal_workstation/recipes/libreoffice.rb +6 -0
  67. data/lib/test_pivotal_workstation/recipes/lion_basedev.rb +38 -0
  68. data/lib/test_pivotal_workstation/recipes/locate_on.rb +8 -0
  69. data/lib/test_pivotal_workstation/recipes/memcached.rb +20 -0
  70. data/lib/test_pivotal_workstation/recipes/mongodb.rb +20 -0
  71. data/lib/test_pivotal_workstation/recipes/mouse_locator.rb +54 -0
  72. data/lib/test_pivotal_workstation/recipes/mysql.rb +44 -0
  73. data/lib/test_pivotal_workstation/recipes/nginx.rb +46 -0
  74. data/lib/test_pivotal_workstation/recipes/osx_updates.rb +3 -0
  75. data/lib/test_pivotal_workstation/recipes/pg_admin.rb +4 -0
  76. data/lib/test_pivotal_workstation/recipes/pivotal_logos.rb +101 -0
  77. data/lib/test_pivotal_workstation/recipes/postgres.rb +89 -0
  78. data/lib/test_pivotal_workstation/recipes/remove_garageband.rb +11 -0
  79. data/lib/test_pivotal_workstation/recipes/rubymine.rb +8 -0
  80. data/lib/test_pivotal_workstation/recipes/rubymine_preferences_pivotal.rb +36 -0
  81. data/lib/test_pivotal_workstation/recipes/rvm.rb +53 -0
  82. data/lib/test_pivotal_workstation/recipes/safari_preferences.rb +4 -0
  83. data/lib/test_pivotal_workstation/recipes/screen_sharing_app.rb +12 -0
  84. data/lib/test_pivotal_workstation/recipes/screen_sharing_on.rb +16 -0
  85. data/lib/test_pivotal_workstation/recipes/selenium_webdriver.rb +24 -0
  86. data/lib/test_pivotal_workstation/recipes/set_finder_show_hd_on_desktop.rb +4 -0
  87. data/lib/test_pivotal_workstation/recipes/set_multitouch_preferences.rb +9 -0
  88. data/lib/test_pivotal_workstation/recipes/set_screensaver_preferences.rb +21 -0
  89. data/lib/test_pivotal_workstation/recipes/sizeup.rb +19 -0
  90. data/lib/test_pivotal_workstation/recipes/skype.rb +5 -0
  91. data/lib/test_pivotal_workstation/recipes/ssh_copy_id.rb +3 -0
  92. data/lib/test_pivotal_workstation/recipes/sshd_on.rb +16 -0
  93. data/lib/test_pivotal_workstation/recipes/ssl_certificate.rb +50 -0
  94. data/lib/test_pivotal_workstation/recipes/svn.rb +1 -0
  95. data/lib/test_pivotal_workstation/recipes/terminal_focus.rb +4 -0
  96. data/lib/test_pivotal_workstation/recipes/terminal_preferences.rb +9 -0
  97. data/lib/test_pivotal_workstation/recipes/textmate.rb +29 -0
  98. data/lib/test_pivotal_workstation/recipes/textmate_plugins.rb +31 -0
  99. data/lib/test_pivotal_workstation/recipes/textmate_preferences.rb +83 -0
  100. data/lib/test_pivotal_workstation/recipes/timemachine_preferences.rb +22 -0
  101. data/lib/test_pivotal_workstation/recipes/user_owns_usr_local.rb +8 -0
  102. data/lib/test_pivotal_workstation/recipes/vim.rb +66 -0
  103. data/lib/test_pivotal_workstation/recipes/virtualbox.rb +7 -0
  104. data/lib/test_pivotal_workstation/recipes/workspace_directory.rb +5 -0
  105. data/lib/test_pivotal_workstation/resources/package.rb +34 -0
  106. data/lib/test_pivotal_workstation/templates/default/bash_profile-arch_flags.sh.erb +3 -0
  107. data/lib/test_pivotal_workstation/templates/default/bash_profile-better_history.sh.erb +4 -0
  108. data/lib/test_pivotal_workstation/templates/default/bash_profile-ec2_tools.sh.erb +5 -0
  109. data/lib/test_pivotal_workstation/templates/default/bash_profile-git_vim.sh.erb +1 -0
  110. data/lib/test_pivotal_workstation/templates/default/bash_profile-no_sudo_gem_install.sh.erb +2 -0
  111. data/lib/test_pivotal_workstation/templates/default/bash_profile-ps1.sh.erb +8 -0
  112. data/lib/test_pivotal_workstation/templates/default/bash_profile-ree_settings.sh.erb +6 -0
  113. data/lib/test_pivotal_workstation/templates/default/bash_profile-rvm.sh.erb +1 -0
  114. data/lib/test_pivotal_workstation/templates/default/bash_profile-vi_is_minimal_vim.sh.erb +1 -0
  115. data/lib/test_pivotal_workstation/templates/default/bash_profile.erb +6 -0
  116. data/lib/test_pivotal_workstation/templates/default/git_scripts_pairs.erb +12 -0
  117. data/lib/test_pivotal_workstation/templates/default/inputrc.erb +10 -0
  118. data/lib/test_pivotal_workstation/templates/default/launchd.conf.erb +6 -0
  119. data/lib/test_pivotal_workstation/templates/default/nginx.conf.erb +79 -0
  120. data/lib/test_pivotal_workstation/templates/default/org.nginx.nginx.plist.erb +22 -0
  121. data/lib/test_pivotal_workstation/templates/default/pivotal_logos-dsimport.erb +2 -0
  122. data/lib/test_pivotal_workstation/version.rb +3 -0
  123. data/test_pivotal_workstation.gemspec +24 -0
  124. metadata +168 -0
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ *.swp
3
+ *.idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in test_pivotal_workstation.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2009-2010 Matthew Kocher, Steve Conover and Pivotal Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ Pivotal Workstation: A Repeatable, Documented, Decomposable, Shareable and Iterative OSX (ruby) Development Environment
2
+
3
+ # Why?
4
+ Development environments are very personal, yet pairing requires some standard be agreed upon. Traditionally, Pivotal relied on imaging workstations from a gold master image which was updated as time allowed. Creating an image that satisfies everyone is impossible, and creating one that satisfies most people is a time consuming process which happened when Apple happened to release hardware which was not compatible with the old image. Chef and the Pivotal Workstation cookbook allows bringing up a new rails development environment with almost no effort, decide on standards on a per-project basis, then share changes with the rest of the users of the pivotal_workstation cookbook as time goes on. Another motivation was to reduce the amount of time spent at standup discussing how to get xyz to compile/run/launch/work in development.
5
+
6
+ # I'm just setting up my laptop, this all sounds like overkill.
7
+ It might be, but it's probably not. Have you ever spent hours trying to get the mysql gem to compile? Do you go to RVM's home page to figure out how to install it? What about homebrew? Do you not test SSL on your local machine because getting nginx set up with a self signed certificate would take most of the morning? Do you fear setting up a new machine because you'll spend a week running into things you vaguely remember how to fix?
8
+
9
+ # Ok, what exactly do I get?
10
+ Anything you want, nothing you don't. Packages are built with Homebrew, Ruby is installed with RVM. See the [recipes folder](https://github.com/pivotal/pivotal_workstation/tree/master/recipes) for a complete list. Many recipes require homebrew or overwriting your .bash_profile. If you want something that doesn't have a recipe, write one and make a pull request.
11
+
12
+ # Hey, I'm attached to my .bash_profile, isn't this dangerous?
13
+ Yes. Chef needs to be run as root - it can do whatever it wants to your system. The recipes have to make some hard assumptions about your machine, and take over parts of your system. Reading any recipe you're thinking of using is a very good idea - a chef recipe shouldn't be difficult to follow, and it'll give you an idea of how to make your own. In the case of your bash profile, it'll be backed up by chef (to /var/chef/backup), and you can move it into ~/.bash_profile_includes/ and it will be sourced by the provided .bash_profile.
14
+
15
+ # OK, I'm ready to dive in. How should I use this?
16
+ [Soloist](https://github.com/mkocher/soloist) is a simple tool to get started quickly with chef-solo and was written initially to make using the pivotal_workstation cookbook easy. The pivotal_workstation cookbook and soloist were both extracted from wschef, the precursor to this effort. Aside from chef-solo, you'll only need xcode installed.
17
+
18
+ # I want to write my own recipe, what should I know?
19
+ Soloist (or your preferred method of running chef) usually runs chef-solo as root. This means the current user is root, and ~ will be expanded to root's home directory. Some constants, WS_USER and WS_HOME are available when needed.
20
+
21
+ # Does this thing actually work?
22
+ Yes. At Pivotal we take testing seriously, and have all projects under CI. Chef recipes for OSX didn't fit into any existing CI solution, so pivotal_workstation [got its own](https://github.com/mkocher/chefci) which builds [most of the recipes](https://github.com/mkocher/chefci/blob/master/build_scripts/build_all.command) every night and on every check in.
23
+
24
+ # Pull Requests
25
+ Pull requests are welcomed. Creating a cookbook to keep along side pivotal_workstation allows for easy separation between personal/project metadata/recipes and recipes that are of general utility.
26
+
27
+ # Where's pivotal_server?
28
+ It's something we're considering, but it doesn't exist yet. It'll probably show up over at [pivotal_experimental](https://github.com/pivotalexperimental) first.
29
+
30
+ # Who do I complain to?
31
+ pivotal_workstation started as a side project of [Matthew Kocher](https://github.com/mkocher) and [Steve Conover](https://github.com/sconover) of Pivotal Labs in 2009, and made the move to a supported pivotal project at the beginning of 2010.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ require "test_pivotal_workstation/version"
2
+
3
+ module TestPivotalWorkstation
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,20 @@
1
+ #
2
+ # Cookbook Name:: dmg
3
+ # Attributes:: default
4
+ #
5
+ # Copyright 2011, Joshua Timberman
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+ default[:pivotal_workstation][:base_dir] = "/Applications"
20
+ default[:pivotal_workstation][:cache_dir] = Chef::Config[:file_cache_path]
@@ -0,0 +1,5 @@
1
+ node.default["git_pairs_authors"] = [
2
+ {"initials" => "mk", "name" => "Matthew Kocher", "shortname" => "mkocher"},
3
+ {"initials" => "bc", "name" => "Brian Cunnie", "shortname" => "cunnie"},
4
+ {"initials" => "sc", "name" => "Santa Claus"}
5
+ ]
@@ -0,0 +1,3 @@
1
+ node.default["git_projects"] = [
2
+ # ["example_name", "git@github.com/foo"]
3
+ ]
@@ -0,0 +1,4 @@
1
+ # node.default["github_for_mac_download_uri"]="https://central.github.com/mac/latest"
2
+ # too bad latest is redirect to url with spaces in the name :(
3
+ node.default["github_for_mac_download_uri"]="https://github-central.s3.amazonaws.com/mac/GitHub%20for%20Mac%201.0.6.zip"
4
+ node.default["github_for_mac_app_path"]="/Applications/GitHub.app"
@@ -0,0 +1 @@
1
+ node.default["gitx_download_location"]="https://github.com/downloads/laullon/gitx/GitX-L_v0.8.3.zip"
@@ -0,0 +1,5 @@
1
+ node.default["mouse_locator_download_uri"]="http://homepage.mac.com/douglasn/MouseLocator.dmg"
2
+ node.default["mouse_locator_dmg_mnt"]="/Volumes/Mouse Locator v1.1"
3
+ node.default["mouse_locator_src"]="#{node['mouse_locator_dmg_mnt']}/Mouse Locator v1.1 Installer.app/Contents/Resources/Distribution/MouseLocator.prefPane"
4
+ node.default["mouse_locator_dst"]="#{ENV['HOME']}/Library/PreferencePanes/MouseLocator.prefPane"
5
+ node.default["mouse_locator_app"]="#{node['mouse_locator_dst']}/Contents/Resources/MouseLocatorAgent.app"
@@ -0,0 +1,11 @@
1
+ node.default["nginx_settings"]= {
2
+ "server_name" => "localhost.local",
3
+ "server_port" => 8080,
4
+ "server_document_root"=> "/var/www/apps/example/current/public"
5
+ }
6
+
7
+ node.default["ssl_settings"]= {
8
+ "common_name" => "*.local",
9
+ "cert_path" => "/usr/local/etc/certificates",
10
+ "ca_path" => "/usr/local/etc/certificates/demoCA"
11
+ }
@@ -0,0 +1,4 @@
1
+ # this link is an html page, even though it uses .dmg; picked a US mirror at random
2
+ # node.default["pg_admin_download_uri"]="http://wwwmaster.postgresql.org/download/mirrors-ftp/pgadmin3/release/v1.12.3/osx/pgadmin3-1.12.3.dmg"
3
+ node.default["pg_admin_download_uri"]="http://wwwmaster.postgresql.org/redir/198/h/pgadmin3/release/v1.12.3/osx/pgadmin3-1.12.3.dmg"
4
+ node.default["pg_admin_app_path"]="/Applications/pgAdmin3.app"
@@ -0,0 +1,8 @@
1
+ node.default["rvm"]= {
2
+ "rubies" => {
3
+ "ree-1.8.7-2011.03" => "CC=gcc-4.2",
4
+ "ruby-1.8.7-p174" => "CC=gcc-4.2",
5
+ "ruby-1.9.2-p180" => ""
6
+ },
7
+ "default_ruby" => "ruby-1.9.2-p180"
8
+ }
@@ -0,0 +1 @@
1
+ node.default["sizeup_download_uri"]="http://irradiatedsoftware.com/download/SizeUp.zip"
@@ -0,0 +1,6 @@
1
+ node.default[:versions]= {
2
+ "homebrew" => "11b5b74effd45119816c7bc2710751adbee5f82d",
3
+ "rvm" => "c2a58c6779d19be17a3c3cfddc13e6a0297648b8",
4
+ "Pivotal-Preferences-RubyMine" => "d0eb393ab3d4c92ac80ce3135aa9f71e59cccbd3",
5
+ "RubyMine-VersionString" => "32",
6
+ }
@@ -0,0 +1,2 @@
1
+ node.default["vim_home"]="#{WS_HOME}/.vim"
2
+ node.default["vim_hash"]="87392f4f200f005245dca5cf6a7a063f8e68b9df"
@@ -0,0 +1 @@
1
+ node.default["workspace_directory"]="workspace"
@@ -0,0 +1,5 @@
1
+ class Chef::Resource::Execute
2
+ def applescript(script)
3
+ command "osascript -e \"#{script.gsub('"', '\\"')}\""
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ class Chef::Recipe
2
+ def bash_profile_include(bash_file)
3
+ include_recipe "pivotal_workstation::bash_profile"
4
+
5
+ template "#{BASH_INCLUDES_SUBDIR}/#{bash_file}.sh" do
6
+ source "bash_profile-#{bash_file}.sh.erb"
7
+ owner WS_USER
8
+ backup false
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,38 @@
1
+ class Chef::Recipe
2
+ def brew_install(package)
3
+ include_recipe "pivotal_workstation::homebrew"
4
+
5
+ execute "brew install #{package}" do
6
+ user WS_USER
7
+ command "brew install #{package}"
8
+ not_if "brew list #{package}"
9
+ end
10
+ end
11
+
12
+ def brew_installed?(package)
13
+ include_recipe "pivotal_workstation::homebrew"
14
+
15
+ system("brew list #{package}")
16
+ end
17
+
18
+ def brew_remove(package)
19
+ include_recipe "pivotal_workstation::homebrew"
20
+
21
+ brew_installed = `brew list | grep #{package}`
22
+ unless brew_installed.empty?
23
+ execute "brew remove #{package}" do
24
+ user WS_USER
25
+ command "brew remove #{package}"
26
+ end
27
+ end
28
+ end
29
+
30
+ def brew_update
31
+ include_recipe "pivotal_workstation::homebrew"
32
+
33
+ execute "brew update" do
34
+ user WS_USER
35
+ command "brew update"
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,25 @@
1
+ class Chef::Recipe
2
+ # Chef has a bug (http://tickets.opscode.com/browse/CHEF-1327)
3
+ # When the "directory" command is used with "recursive = true",
4
+ # only the deepest directory obtains the ownership specified
5
+ # by the block. For example,
6
+ # directory "a/b/c" do
7
+ # owner "foo"
8
+ # recursive true
9
+ # end
10
+ # creates directories "a" and "a/b" owned by root, and "a/b/c"
11
+ # owned by "foo".
12
+ # To avoid this, the following command takes a
13
+ # list of implicitly nested directories, and creates each one
14
+ # individually. For example,
15
+ # recursive_directories ['a', 'b', 'c'] do
16
+ # owner "foo"
17
+ # end
18
+ # Will create the directories "a", "a/b" and "a/b/c", each
19
+ # owned by "foo".
20
+ def recursive_directories(dirs, &block)
21
+ dirs.each_index do |i|
22
+ directory(File.join(dirs[0..i]), &block)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,42 @@
1
+ class Chef::Recipe
2
+
3
+ MARKER_DIR = "#{ENV['HOME']}/.install_markers"
4
+
5
+ #Regarding marker files:
6
+ #
7
+ #The idea here is you have a simple "signal" on disk that tells you when you've
8
+ #successfully run something, and you don't want to run it again if you don't have to.
9
+ #
10
+ #Also, the decision to rerun a unit of work becomes explicit - and owned by you.
11
+ #(it's not based on trusting a target program to respond in some way).
12
+ #You don't have to learn and keep up this "re-run" logic per unit of work / program
13
+ #
14
+ #Also, simply ls'ing the marker dir gives you interesting information all in once place -
15
+ #i.e. what markers are there and what are their timestamps?
16
+ #
17
+ #And reinstalls are easy - just rm the relevant marker file.
18
+
19
+ def run_unless_marker_file_exists(marker_file_name)
20
+
21
+ directory MARKER_DIR do
22
+ owner WS_USER
23
+ recursive true
24
+ end
25
+
26
+ marker_path = File.join(MARKER_DIR, marker_file_name)
27
+ if File.exists?(marker_path)
28
+ log "skipping #{marker_file_name}: marker file found (#{marker_path}), detail: #{`ls -la #{marker_path}`.strip}"
29
+ else
30
+
31
+ log "no marker file found for #{marker_file_name} in #{MARKER_DIR}, running"
32
+
33
+ yield
34
+
35
+ execute "touching marker file #{marker_path} after successful run" do
36
+ user WS_USER
37
+ command "touch #{marker_path}"
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,97 @@
1
+ class Chef::Recipe
2
+ def zip_app_install(options)
3
+ raise ArgumentError.new("Options must include :app") unless options[:app]
4
+ raise ArgumentError.new("Options must include :uri") unless options[:uri]
5
+
6
+ if options[:force]
7
+ execute ":force is true, removing marker file for '#{options[:app]}'" do
8
+ command "rm -f #{File.join(MARKER_DIR, options[:app])}"
9
+ user WS_USER
10
+ end
11
+ end
12
+
13
+ run_unless_marker_file_exists(options[:app]) do
14
+ download_dir = "/tmp/#{options[:app]}"
15
+ downloaded_zip_file = "#{download_dir}/#{options[:app]}.zip"
16
+
17
+ execute "delete/(re)create download dir (#{options[:app]})" do
18
+ command "rm -rf #{download_dir}"
19
+ command "mkdir -p #{download_dir}"
20
+ user WS_USER
21
+ end
22
+
23
+ remote_file downloaded_zip_file do
24
+ source options[:uri]
25
+ owner WS_USER
26
+ group "staff"
27
+ end
28
+
29
+ execute "uncompress application (#{options[:app]})" do
30
+ # unzip doesn't respct MacOS resource forks
31
+ # => http://xahlee.org/UnixResource_dir/macosx.html
32
+ command "ditto -xk '#{downloaded_zip_file}' #{download_dir}/"
33
+ user WS_USER
34
+ end
35
+
36
+ install_applications(download_dir)
37
+
38
+ execute "delete download dir (#{options[:app]})" do
39
+ command "rm -rf #{download_dir}"
40
+ user WS_USER
41
+ end
42
+ end
43
+ end
44
+
45
+ def dmg_app_install(options)
46
+ raise ArgumentError.new("Options must include :app") unless options[:app]
47
+ raise ArgumentError.new("Options must include :uri") unless options[:uri]
48
+
49
+ run_unless_marker_file_exists(options[:app]) do
50
+ downloaded_file = "/tmp/#{options[:app]}.dmg"
51
+ mount_point = "/Volumes/#{options[:app]}"
52
+
53
+ remote_file downloaded_file do
54
+ source options[:uri]
55
+ owner WS_USER
56
+ group "staff"
57
+ end
58
+
59
+ execute "mount dmg (#{options[:app]})" do
60
+ command "hdiutil attach -mountpoint #{mount_point} #{downloaded_file}"
61
+ user WS_USER
62
+ end
63
+
64
+ install_applications(mount_point)
65
+
66
+ execute "unmount dmg (#{options[:app]})" do
67
+ command "hdiutil detach #{mount_point}"
68
+ user WS_USER
69
+ end
70
+
71
+ execute "delete downloaded dmg (#{options[:app]})" do
72
+ command "rm -rf #{downloaded_file}"
73
+ user WS_USER
74
+ end
75
+ end
76
+ end
77
+
78
+ private
79
+
80
+ def install_applications(source_dir)
81
+ installable_apps = `\cd #{source_dir}/ && \ls -d1 #{source_dir}/*.app`.split("\n")
82
+
83
+ unless installable_apps.empty?
84
+ execute "remove any existing .app(s) from /Applications/ (#{installable_apps.join(",")})" do
85
+ apps_to_remove = installable_apps.map{|a| "'/Applications/#{a}'" }.join(" ")
86
+ command "rm -rf #{apps_to_remove}"
87
+ user WS_USER
88
+ end
89
+
90
+ execute "copy .app(s) into /Applications/ (#{installable_apps.join(",")})" do
91
+ apps_to_install = installable_apps.map{|a| "'#{source_dir}/#{a}'" }.join(" ")
92
+ command "cp -Rf #{apps_to_install} /Applications/"
93
+ user WS_USER
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,36 @@
1
+ class Chef::Recipe
2
+ def rvm_ruby_install(ruby_version, env_override)
3
+ include_recipe "pivotal_workstation::rvm"
4
+
5
+ #don't use the marker file system for this. we guess that people are likely to be installing rubies by hand using rvm.
6
+ #...that guess might be wrong.
7
+ unless File.exists?("#{::RVM_HOME}/bin/#{ruby_version}")
8
+
9
+ execute "clean out the archive and src directories each time. bad downloads cause problems with rvm" do
10
+ command "rm -rf #{::RVM_HOME}/archives/*; rm -rf #{::RVM_HOME}/src/*"
11
+ user WS_USER
12
+ end
13
+
14
+ install_cmd = "#{env_override} #{RVM_COMMAND} install #{ruby_version}"
15
+
16
+ #this fixes an rvm problem with openssl when installing an mri version
17
+ install_cmd << " -C --with-openssl-dir=#{::RVM_HOME}/usr" if ruby_version =~ /^ruby-/
18
+
19
+ #| (! grep 'error') : if we see rvm errors in stderr, fail
20
+ #this is due to an rvm bug (we've notified the author). as soon as curl error cause rvm to exit nonzero,
21
+ #we can get rid of this
22
+ install_cmd << " 2>&1 | (! grep error)"
23
+
24
+ execute "installing #{ruby_version} with RVM: #{install_cmd}" do
25
+ command install_cmd
26
+ user WS_USER
27
+ end
28
+
29
+ execute "check #{ruby_version}" do
30
+ command "#{RVM_COMMAND} list | grep #{ruby_version}"
31
+ user WS_USER
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,4 @@
1
+ WS_USER = ENV['SUDO_USER'].strip
2
+ WS_HOME = ENV['HOME']
3
+
4
+ raise "should not be root" if WS_USER=="root"
@@ -0,0 +1,9 @@
1
+ class Chef::Recipe
2
+ def marker_version_string_for(application_name)
3
+ application_name + "-" + version_string_for(application_name)
4
+ end
5
+
6
+ def version_string_for(application_name)
7
+ node[:versions][application_name] || raise("you must define a version for #{application_name} in attributes.")
8
+ end
9
+ end