Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Set env vars #3

Closed
wants to merge 5 commits into from

1 participant

@anujbiyani

It seems ec2 ami tools has changed their requirements; it now needs certain environment variables set.
From the readme:

Before running the utilities the EC2_HOME environment variable
needs to be set:

export EC2_HOME=<installation-dir>/ec2-ami-tools-X.X-XXXX

...

The utilities can also be added to the path:

export PATH=$PATH:${EC2_AMITOOL_HOME:-EC2_HOME}/bin

I also changed the name of the cookbook to reflect the name of the repository; this plays nicer with Berkshelf and Librarian-Chef.

Finally I added Chefspec and some simple unit tests. Chefspec isn't yet mature enough to test everything in the recipe, though.

ec2-ami-tools also requires Ruby, but that seems tricky to add as a dependency because users may want to install ruby themselves through rvm or whatever; I'm still trying to figure out how to use include_recipe conditionally so that the ec2-ami-tools recipe can install ruby only if it's not already installed.

@anujbiyani

I found out about another useful amazon tool (EC2 API Tools) that I wanted to add, but it conflicts with the some of the fixes to ec2 ami tools in my pull request. I've created a new cookbook that works with both api tools and ami tools at once: https://github.com/anujbiyani/chef_ec2_cli_tools

@anujbiyani anujbiyani closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 20, 2012
  1. @anujbiyani
  2. @anujbiyani

    change name of cookbook to chef-ec2-ami-tools to play nicer with chef…

    anujbiyani authored
    …spec
    
    add spec for installing unzip
Commits on Dec 21, 2012
  1. @anujbiyani
  2. @anujbiyani

    make an attribute for install_target

    anujbiyani authored
    set EC2_HOME environment variable and add ec2-ami-tools/bin to PATH
Commits on Jan 3, 2013
  1. @anujbiyani
This page is out of date. Refresh to see the latest.
View
3  Gemfile
@@ -0,0 +1,3 @@
+source "http://rubygems.org"
+
+gem "chefspec"
View
84 Gemfile.lock
@@ -0,0 +1,84 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ builder (3.1.4)
+ bunny (0.7.9)
+ chef (10.16.2)
+ bunny (>= 0.6.0, < 0.8.0)
+ erubis
+ highline (>= 1.6.9)
+ json (>= 1.4.4, <= 1.6.1)
+ mixlib-authentication (>= 1.3.0)
+ mixlib-cli (>= 1.1.0)
+ mixlib-config (>= 1.1.2)
+ mixlib-log (>= 1.3.0)
+ mixlib-shellout
+ moneta
+ net-ssh (~> 2.2.2)
+ net-ssh-multi (~> 1.1.0)
+ ohai (>= 0.6.0)
+ rest-client (>= 1.0.4, < 1.7.0)
+ treetop (~> 1.4.9)
+ uuidtools
+ yajl-ruby (~> 1.1)
+ chefspec (0.9.0)
+ chef (>= 0.9.12)
+ erubis
+ minitest-chef-handler (~> 0.6.0)
+ rspec (~> 2.11.0)
+ ci_reporter (1.8.3)
+ builder (>= 2.1.2)
+ diff-lcs (1.1.3)
+ erubis (2.7.0)
+ highline (1.6.15)
+ ipaddress (0.8.0)
+ json (1.6.1)
+ mime-types (1.19)
+ minitest (4.3.3)
+ minitest-chef-handler (0.6.4)
+ chef
+ ci_reporter
+ minitest
+ mixlib-authentication (1.3.0)
+ mixlib-log
+ mixlib-cli (1.2.2)
+ mixlib-config (1.1.2)
+ mixlib-log (1.4.1)
+ mixlib-shellout (1.1.0)
+ moneta (0.6.0)
+ net-ssh (2.2.2)
+ net-ssh-gateway (1.1.0)
+ net-ssh (>= 1.99.1)
+ net-ssh-multi (1.1)
+ net-ssh (>= 2.1.4)
+ net-ssh-gateway (>= 0.99.0)
+ ohai (6.14.0)
+ ipaddress
+ mixlib-cli
+ mixlib-config
+ mixlib-log
+ systemu
+ yajl-ruby
+ polyglot (0.3.3)
+ rest-client (1.6.7)
+ mime-types (>= 1.16)
+ rspec (2.11.0)
+ rspec-core (~> 2.11.0)
+ rspec-expectations (~> 2.11.0)
+ rspec-mocks (~> 2.11.0)
+ rspec-core (2.11.1)
+ rspec-expectations (2.11.3)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.11.3)
+ systemu (2.5.2)
+ treetop (1.4.12)
+ polyglot
+ polyglot (>= 0.3.1)
+ uuidtools (2.1.3)
+ yajl-ruby (1.1.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ chefspec
View
4 attributes/default.rb
@@ -1 +1,3 @@
-default['chef-ec2-ami-tools']['install_root'] = "/usr/local/share"
+install_root = "/usr/local/share"
+default['chef-ec2-ami-tools']['install_root'] = install_root
+default['chef-ec2-ami-tools']['install_target'] = "#{install_root}/ec2-ami-tools"
View
2  metadata.rb
@@ -1,6 +1,6 @@
maintainer "trampoline systems ltd"
maintainer_email "craig@trampolinesystems.com"
license "http://www.apache.org/licenses/LICENSE-2.0.html"
-description "Installs/Configures ec2-ami-tools"
+description "Installs/Configures chef-ec2-ami-tools"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
version "0.0.4"
View
10 recipes/default.rb
@@ -22,7 +22,7 @@
package "unzip"
install_root = node["chef-ec2-ami-tools"]["install_root"]
-install_target = "#{install_root}/ec2-ami-tools"
+install_target = node["chef-ec2-ami-tools"]["install_target"]
remote_file "/tmp/ec2-ami-tools.zip" do
source "http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip"
@@ -45,3 +45,11 @@
end
end
end
+
+file "/etc/profile.d/ec2-ami-tools.sh" do
+ owner "root"
+ group "root"
+ mode 0755
+
+ content %Q{export EC2_HOME=#{install_target}\nexport PATH=$PATH:#{install_target}/bin\n}
+end
View
20 spec/default_spec.rb
@@ -0,0 +1,20 @@
+require 'chefspec'
+
+describe 'chef-ec2-ami-tools::default' do
+ let(:chef_run) { ChefSpec::ChefRunner.new.converge 'chef-ec2-ami-tools::default' }
+
+ it "installs unzip" do
+ chef_run.should install_package 'unzip'
+ end
+
+ it "downloads ec2-ami-tools.zip" do
+ chef_run.should create_remote_file '/tmp/ec2-ami-tools.zip'
+ end
+
+ it "sets the EC2_HOME environment variable" do
+ install_target = chef_run.node['chef-ec2-ami-tools']['install_target']
+ chef_run.should create_file_with_content '/etc/profile.d/ec2-ami-tools.sh',
+ %Q{export EC2_HOME=#{install_target}\nexport PATH=$PATH:#{install_target}/bin\n}
+ chef_run.file('/etc/profile.d/ec2-ami-tools.sh').should be_owned_by('root', 'root')
+ end
+end
Something went wrong with that request. Please try again.