test_pivotal_workstation 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.markdown +31 -0
- data/Rakefile +1 -0
- data/lib/test_pivotal_workstation.rb +5 -0
- data/lib/test_pivotal_workstation/attributes/default.rb +20 -0
- data/lib/test_pivotal_workstation/attributes/git_pairs.rb +5 -0
- data/lib/test_pivotal_workstation/attributes/git_projects.rb +3 -0
- data/lib/test_pivotal_workstation/attributes/github_for_mac.rb +4 -0
- data/lib/test_pivotal_workstation/attributes/gitx.rb +1 -0
- data/lib/test_pivotal_workstation/attributes/mouse_locator.rb +5 -0
- data/lib/test_pivotal_workstation/attributes/nginx.rb +11 -0
- data/lib/test_pivotal_workstation/attributes/pg_admin.rb +4 -0
- data/lib/test_pivotal_workstation/attributes/rvm.rb +8 -0
- data/lib/test_pivotal_workstation/attributes/sizeup.rb +1 -0
- data/lib/test_pivotal_workstation/attributes/versions.rb +6 -0
- data/lib/test_pivotal_workstation/attributes/vim.rb +2 -0
- data/lib/test_pivotal_workstation/attributes/workspace_directory.rb +1 -0
- data/lib/test_pivotal_workstation/libraries/applescript.rb +5 -0
- data/lib/test_pivotal_workstation/libraries/bash_profile_include.rb +11 -0
- data/lib/test_pivotal_workstation/libraries/brew.rb +38 -0
- data/lib/test_pivotal_workstation/libraries/directories.rb +25 -0
- data/lib/test_pivotal_workstation/libraries/marker.rb +42 -0
- data/lib/test_pivotal_workstation/libraries/osx_app.rb +97 -0
- data/lib/test_pivotal_workstation/libraries/rvm_ruby_install.rb +36 -0
- data/lib/test_pivotal_workstation/libraries/user.rb +4 -0
- data/lib/test_pivotal_workstation/libraries/version.rb +9 -0
- data/lib/test_pivotal_workstation/providers/package.rb +95 -0
- data/lib/test_pivotal_workstation/recipes/ack.rb +1 -0
- data/lib/test_pivotal_workstation/recipes/active_corners.rb +24 -0
- data/lib/test_pivotal_workstation/recipes/activemq.rb +1 -0
- data/lib/test_pivotal_workstation/recipes/bash_path_order.rb +13 -0
- data/lib/test_pivotal_workstation/recipes/bash_profile-arch_flags.rb +1 -0
- data/lib/test_pivotal_workstation/recipes/bash_profile-better_history.rb +1 -0
- data/lib/test_pivotal_workstation/recipes/bash_profile-no_sudo_gem_install.rb +1 -0
- data/lib/test_pivotal_workstation/recipes/bash_profile-ps1.rb +1 -0
- data/lib/test_pivotal_workstation/recipes/bash_profile-ree_settings.rb +1 -0
- data/lib/test_pivotal_workstation/recipes/bash_profile.rb +11 -0
- data/lib/test_pivotal_workstation/recipes/ccmenu.rb +6 -0
- data/lib/test_pivotal_workstation/recipes/chrome.rb +6 -0
- data/lib/test_pivotal_workstation/recipes/default_editor.rb +55 -0
- data/lib/test_pivotal_workstation/recipes/defaults_fast_key_repeat_rate.rb +10 -0
- data/lib/test_pivotal_workstation/recipes/disable_front_row.rb +4 -0
- data/lib/test_pivotal_workstation/recipes/dock_preferences.rb +13 -0
- data/lib/test_pivotal_workstation/recipes/dropbox.rb +6 -0
- data/lib/test_pivotal_workstation/recipes/ec2_api_tools.rb +3 -0
- data/lib/test_pivotal_workstation/recipes/finder_display_full_path.rb +4 -0
- data/lib/test_pivotal_workstation/recipes/firefox.rb +5 -0
- data/lib/test_pivotal_workstation/recipes/gem_no_rdoc_no_ri.rb +14 -0
- data/lib/test_pivotal_workstation/recipes/git.rb +8 -0
- data/lib/test_pivotal_workstation/recipes/git_config_global_defaults.rb +72 -0
- data/lib/test_pivotal_workstation/recipes/git_projects.rb +29 -0
- data/lib/test_pivotal_workstation/recipes/git_scripts.rb +19 -0
- data/lib/test_pivotal_workstation/recipes/github_for_mac.rb +25 -0
- data/lib/test_pivotal_workstation/recipes/github_ssh_keys.rb +16 -0
- data/lib/test_pivotal_workstation/recipes/gitx.rb +56 -0
- data/lib/test_pivotal_workstation/recipes/global_environment_variables.rb +3 -0
- data/lib/test_pivotal_workstation/recipes/google_chrome_prevent_updates.rb +10 -0
- data/lib/test_pivotal_workstation/recipes/homebrew.rb +27 -0
- data/lib/test_pivotal_workstation/recipes/imagemagick.rb +3 -0
- data/lib/test_pivotal_workstation/recipes/inputrc.rb +6 -0
- data/lib/test_pivotal_workstation/recipes/iterm_set_defaults.rb +167 -0
- data/lib/test_pivotal_workstation/recipes/java.rb +8 -0
- data/lib/test_pivotal_workstation/recipes/joe.rb +3 -0
- data/lib/test_pivotal_workstation/recipes/libreoffice.rb +6 -0
- data/lib/test_pivotal_workstation/recipes/lion_basedev.rb +38 -0
- data/lib/test_pivotal_workstation/recipes/locate_on.rb +8 -0
- data/lib/test_pivotal_workstation/recipes/memcached.rb +20 -0
- data/lib/test_pivotal_workstation/recipes/mongodb.rb +20 -0
- data/lib/test_pivotal_workstation/recipes/mouse_locator.rb +54 -0
- data/lib/test_pivotal_workstation/recipes/mysql.rb +44 -0
- data/lib/test_pivotal_workstation/recipes/nginx.rb +46 -0
- data/lib/test_pivotal_workstation/recipes/osx_updates.rb +3 -0
- data/lib/test_pivotal_workstation/recipes/pg_admin.rb +4 -0
- data/lib/test_pivotal_workstation/recipes/pivotal_logos.rb +101 -0
- data/lib/test_pivotal_workstation/recipes/postgres.rb +89 -0
- data/lib/test_pivotal_workstation/recipes/remove_garageband.rb +11 -0
- data/lib/test_pivotal_workstation/recipes/rubymine.rb +8 -0
- data/lib/test_pivotal_workstation/recipes/rubymine_preferences_pivotal.rb +36 -0
- data/lib/test_pivotal_workstation/recipes/rvm.rb +53 -0
- data/lib/test_pivotal_workstation/recipes/safari_preferences.rb +4 -0
- data/lib/test_pivotal_workstation/recipes/screen_sharing_app.rb +12 -0
- data/lib/test_pivotal_workstation/recipes/screen_sharing_on.rb +16 -0
- data/lib/test_pivotal_workstation/recipes/selenium_webdriver.rb +24 -0
- data/lib/test_pivotal_workstation/recipes/set_finder_show_hd_on_desktop.rb +4 -0
- data/lib/test_pivotal_workstation/recipes/set_multitouch_preferences.rb +9 -0
- data/lib/test_pivotal_workstation/recipes/set_screensaver_preferences.rb +21 -0
- data/lib/test_pivotal_workstation/recipes/sizeup.rb +19 -0
- data/lib/test_pivotal_workstation/recipes/skype.rb +5 -0
- data/lib/test_pivotal_workstation/recipes/ssh_copy_id.rb +3 -0
- data/lib/test_pivotal_workstation/recipes/sshd_on.rb +16 -0
- data/lib/test_pivotal_workstation/recipes/ssl_certificate.rb +50 -0
- data/lib/test_pivotal_workstation/recipes/svn.rb +1 -0
- data/lib/test_pivotal_workstation/recipes/terminal_focus.rb +4 -0
- data/lib/test_pivotal_workstation/recipes/terminal_preferences.rb +9 -0
- data/lib/test_pivotal_workstation/recipes/textmate.rb +29 -0
- data/lib/test_pivotal_workstation/recipes/textmate_plugins.rb +31 -0
- data/lib/test_pivotal_workstation/recipes/textmate_preferences.rb +83 -0
- data/lib/test_pivotal_workstation/recipes/timemachine_preferences.rb +22 -0
- data/lib/test_pivotal_workstation/recipes/user_owns_usr_local.rb +8 -0
- data/lib/test_pivotal_workstation/recipes/vim.rb +66 -0
- data/lib/test_pivotal_workstation/recipes/virtualbox.rb +7 -0
- data/lib/test_pivotal_workstation/recipes/workspace_directory.rb +5 -0
- data/lib/test_pivotal_workstation/resources/package.rb +34 -0
- data/lib/test_pivotal_workstation/templates/default/bash_profile-arch_flags.sh.erb +3 -0
- data/lib/test_pivotal_workstation/templates/default/bash_profile-better_history.sh.erb +4 -0
- data/lib/test_pivotal_workstation/templates/default/bash_profile-ec2_tools.sh.erb +5 -0
- data/lib/test_pivotal_workstation/templates/default/bash_profile-git_vim.sh.erb +1 -0
- data/lib/test_pivotal_workstation/templates/default/bash_profile-no_sudo_gem_install.sh.erb +2 -0
- data/lib/test_pivotal_workstation/templates/default/bash_profile-ps1.sh.erb +8 -0
- data/lib/test_pivotal_workstation/templates/default/bash_profile-ree_settings.sh.erb +6 -0
- data/lib/test_pivotal_workstation/templates/default/bash_profile-rvm.sh.erb +1 -0
- data/lib/test_pivotal_workstation/templates/default/bash_profile-vi_is_minimal_vim.sh.erb +1 -0
- data/lib/test_pivotal_workstation/templates/default/bash_profile.erb +6 -0
- data/lib/test_pivotal_workstation/templates/default/git_scripts_pairs.erb +12 -0
- data/lib/test_pivotal_workstation/templates/default/inputrc.erb +10 -0
- data/lib/test_pivotal_workstation/templates/default/launchd.conf.erb +6 -0
- data/lib/test_pivotal_workstation/templates/default/nginx.conf.erb +79 -0
- data/lib/test_pivotal_workstation/templates/default/org.nginx.nginx.plist.erb +22 -0
- data/lib/test_pivotal_workstation/templates/default/pivotal_logos-dsimport.erb +2 -0
- data/lib/test_pivotal_workstation/version.rb +3 -0
- data/test_pivotal_workstation.gemspec +24 -0
- metadata +168 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -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.
|
data/README.markdown
ADDED
@@ -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.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -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,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 @@
|
|
1
|
+
node.default["sizeup_download_uri"]="http://irradiatedsoftware.com/download/SizeUp.zip"
|
@@ -0,0 +1 @@
|
|
1
|
+
node.default["workspace_directory"]="workspace"
|
@@ -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,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
|