test-kitchen icon indicating copy to clipboard operation
test-kitchen copied to clipboard

Add lifecycle hooks to various phases (including provisioners)

Open sethvargo opened this issue 12 years ago • 41 comments

Example #257

@fnichol is going to tack on some more information/whiteboard picture :smile:.

sethvargo avatar Jan 17 '14 22:01 sethvargo

I think I've got a +1 for "support multiple provisioners to run in sequence"

I'd like to be able to provision a machine by first applying the chef_zero provisioner and then applying the shell provisioner to it.

I'd also like to be able to slurp back artifacts after the converge is done.

The goal is to replicate what we used to be able to do with Vagrant in the omnibus-chef project. We need to be able to chain provisioners, because we want to leverage the omnibus cookbook to configure the server, but since we're building chef we need to rm -rf chef and go on to issue the omnibus build commands -- probably not a sane thing to do with chef after it deletes itself. I also want to get the built packages back.

Maybe we could write a 'test' using busser that actually did the build, but that feels wrong as well, the test phase should be running rspec against the built artifact.

lamont-granquist avatar May 20 '14 21:05 lamont-granquist

If you can chain provisioners this also solves the "arbitrary commands before provisioning" problem in #311 since you can just do the reverse of what I want to do and run your shell provisioner first to setup your CA certs or install wget/curl, and then you run your chef provisioner.

lamont-granquist avatar May 20 '14 21:05 lamont-granquist

:+1: This is a must for our team

johntdyer avatar May 21 '14 13:05 johntdyer

What about post-test? It can be really useful if you want to push artifacts if the tests succeeded.

thedrow avatar May 23 '14 05:05 thedrow

yeah i'd like to pull artifacts back down to a directory in a post-test. being able to run a command to push and deploy post-test is another obvious use case. chaining multiple different post-test plugins would also probably be a thing as well but might be a stretch at first.

lamont-granquist avatar May 29 '14 00:05 lamont-granquist

hooks would be very useful. for example what i would like is to be able to cleanup after doing a converge or verify. (ie remove chef and the repository but leave the server configured). Currently we only have the option to destroy the server

neillturner avatar Jun 25 '14 09:06 neillturner

More evidence for need of this feature:

https://twitter.com/miah_/status/498159138393047040

lamont-granquist avatar Aug 09 '14 17:08 lamont-granquist

I have a rather specific corner case for this feature. I have a number of cookbooks that have AWS-specific things in them. One thing that they commonly do is update resource tags via the resource_tag resource from the aws cookbook:

aws_resource_tag 'elasticsearch cluster tag' do
  resource_id node['ec2']['instance_id']
  tags 'ElasticsearchCluster' => node.chef_environment
end

My issue arises because I use test-kitchen with the kitchen-ec2 driver in our CI environment to do integration testing, and the instances get created in a VPC.

For VPC instances, ohai does not detect that they're running on EC2 automatically, and so a hint file needs to be created before Chef runs at /etc/chef/ohai/hints/ec2.json.

Normally this is simply done with the bootstrapping script for our base AMI, but our cookbooks use the Canonical AMIs so that they can be tested more generically so there's no hint present to tell Ohai to populate the node.ec2 attributes.

Ideally, it would be nice if test-kitchen supported multiple provisioners so that I could run a simple shell provisioner before the chef-zero provisioner that touches the hint file for Ohai.

(Obviously there's a number of ways I could approach this, one of which would be to add functionality to kitchen-ec2 instead to touch the hint file right after starting the instance if the subnet_id option is set.)

ghost avatar Sep 12 '14 21:09 ghost

+1 I have the exact same issue as above. Do we have any idea when this might be done? Or does anyone have a good work around for this vpc hint issue, other than modifying the image?

awesomescot-zz avatar Oct 07 '14 23:10 awesomescot-zz

bump any further updates to this one?

CpuID avatar Jul 10 '15 00:07 CpuID

@fnichol @tyler-ball buuuuuump

lamont-granquist avatar Jul 10 '15 15:07 lamont-granquist

+1 for multi-provisioning

PurrBiscuit avatar Jul 10 '15 19:07 PurrBiscuit

bump

lxhunter avatar Aug 15 '15 11:08 lxhunter

bump

sochoa avatar Sep 24 '15 18:09 sochoa

+1

sawanoboly avatar Sep 28 '15 03:09 sawanoboly

+1

francoiskha avatar Sep 30 '15 20:09 francoiskha

+1

habelson avatar Oct 22 '15 15:10 habelson

+1 this would be very useful

z0mi3ie avatar Nov 04 '15 20:11 z0mi3ie

+1000

willejs avatar Nov 11 '15 12:11 willejs

any updates on this ?

Chili-Man avatar Dec 03 '15 02:12 Chili-Man