add step_into during chefspec tests to correctly test custom resources
2 files changed
tree: 24bb1ec265157d4c611f6009a78593d7c37897c2
  1. .bundle/
  2. attributes/
  3. definitions/
  4. files/
  5. libraries/
  6. providers/
  7. recipes/
  8. resources/
  9. script/
  10. spec/
  11. templates/
  12. test/
  13. .gitignore
  14. .kitchen.yml
  15. .ruby-gemset
  16. .ruby-version
  17. Berksfile
  18. bootstrap.sh
  19. CHANGELOG.md
  20. chefignore
  21. Gemfile
  22. LICENSE
  23. metadata.rb
  24. README.md
  25. Thorfile
  26. vagrant-solo.rb
  27. Vagrantfile
README.md

anaconda cookbook

Chef cookbook for installing Continuum Analytic's Anaconda: "completely free Python distribution for large-scale data processing, predictive analytics, and scientific computing".

This also serves as a live example of the most up-to-date best practices for writing, maintaining, and testing Chef cookbooks:

Requirements

This repo has only been tested with RVM; YMMV with other installation methods (rbenv, chef-dk, etc).

It sounds like Chef-DK is the new recommended installation path, but I have not had a good experience with it (as of 0.1.0-1). Again, YMMV.

Quickstart

The Vagrantfile is written to get you an Anaconda environment with minimal effort:

$> vagrant up --provision
...

$> vagrant ssh
$vagrant> export PATH=/opt/anaconda/2.0.1/bin:${PATH}
$vagrant> conda --version
conda 3.5.5

# if you included `recipe[anaconda::shell_conveniences]` you don't have to do anything;
# it's sourced in /etc/profile.d
$> vagrant ssh
$vagrant> conda --version
conda 3.5.5

To use it in a cookbook:

include_recipe 'anaconda::default'

Usage, recipes, attributes, and resources

The main recipe is anaconda::default. Include it in your runlist, and it will install the package as well as any necessary dependencies.

The following are user-configurable attributes. Check attributes/default.rb for default values.

  • anaconda
    • version: the version to install
    • flavor: either x86 (32-bit) or x86_64 (64-bit)
    • install_root: the parent directory of all anaconda installs. note that individual installs go into #{install_root}/#{version}
    • accept_license: must be explicitly set to the string yes; any other value will reject the license.
    • owner: the user who owns the install
    • group: the group who owns the install

recipe[anaconda::shell_conveniences]

Include this to have the environment set for all users (login shells) via /etc/profile.d. Useful for development.

$> vagrant ssh
$vagrant> which conda
/opt/anaconda/2.0.1/bin/conda

resource anaconda_package

You can use the anaconda_package resource to install new packages into the Anaconda environment:

# I do not know what 'astroid' is, just using it as a sample package
anaconda_package 'astroid' do
  # the other supported action is `:remove`
  action :install
end

See the resource definition for additional options; in general, all it does is present the same options as conda install/conda remove.

Tests

Run the full test suite:

# this will take a really long time
$> script/cibuild
...

# check the final result; bash return codes: 0 is good, anything else is not
$> echo $?

Run just the chefspecs:

$> rspec

Run just the test kitchen serverspec integration tests:

# this is what takes so long: every platform and version is fully built in vagrant
# the list of OSes is defined in [.kitchen.yml](.kitchen.yml)
$> kitchen verify

# test a specific OS; `kitchen list`
$> kitchen verify default-ubuntu-1204

Check the style with Foodcritic:

$> foodcritic

Releases and issues

Standard stuff:

  • master is the active version in development
  • releases are made with Github, and git tag'ed

Issues should be opened in the Github issue tracker

TODO

  • autodetect 64-bit versus 32
  • (TODO does it matter? who uses it?) populate metadata.rb: suggests, supports, etc
  • add a pre-provision for kitchen tests to avoid redownloading the installer on every test (really slows down the tests)
  • figure out how to publish onto http://community.opscode.com/; the documentation is unbelievably bad

Author

Author:: Matt Chu (matt.chu@gmail.com)