Skip to content

Commit

Permalink
Install Omnibus if require_chef_omnibus version differs from current.
Browse files Browse the repository at this point in the history
This will allow a user to upgrade or downgrade their Omnibus package
version to match the version string in require_chef_omnibus. If the
version string matches what is currently installed, the installation is
skipped.

**Note** This commit also supports a value of `"latest"` for
require_chef_omnibus which drops the version flag when calling the omnibus
installation script. Since calculating the lastest Chef release is
nontrivial, the Omnibus installer will be called on every converge when
`"latest"` is set--whether Chef is installed or not.

Closes #32
  • Loading branch information
fnichol committed Feb 18, 2013
1 parent 9995f58 commit 15b85bd
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/kitchen/driver/ssh_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,23 @@ def chef_home
end

def install_omnibus(ssh_args)
flag = config[:require_chef_omnibus]
version = flag.is_a?(String) ? "-s -- -v #{flag}" : ""
flag = config[:require_chef_omnibus].downcase
version = if flag.is_a?(String) && flag != "latest"
"-s -- -v #{flag}"
else
""
end

ssh(ssh_args, <<-INSTALL.gsub(/^ {10}/, ''))
if [ ! -d "/opt/chef" ] ; then
should_update_chef() {
case "#{flag}" in
$(chef-solo --v | awk '{print $2}')) return 1 ;;
latest|*) return 0 ;;
esac
}
if [ ! -d "/opt/chef" ] || should_update_chef ; then
echo '-----> Installing Chef Omnibus (#{flag})'
curl -sSL https://www.opscode.com/chef/install.sh \

This comment has been minimized.

Copy link
@schisamo

schisamo Feb 19, 2013

Contributor

I'm wondering if this should be wget -O - https://www.opscode.com/chef/install.sh as curl is not a default package on many platforms.

This comment has been minimized.

Copy link
@fnichol

fnichol Feb 19, 2013

Author Contributor

You might be right, should we do the wget, curl, fail fallback that install.sh does? This is the one place where I depended on curl or wget--I'd love to avoid that but this was the first pass implementation which has lasted quite a while.

This comment has been minimized.

Copy link
@jtimberman

jtimberman Feb 19, 2013

Contributor

Why not leverage what the knife bootstrap template chef-full does?

https://github.com/opscode/chef/blob/master/lib/chef/knife/bootstrap/chef-full.erb#L4-L25

This comment has been minimized.

Copy link
@fnichol

fnichol Feb 19, 2013

Author Contributor

@jtimberman agreed, tracking in #61

| sudo bash #{version}
fi
Expand Down

0 comments on commit 15b85bd

Please sign in to comment.