Add lifecycle hooks to various phases (including provisioners)
sethvargo opened this issue · comments
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.
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.
👍 This is a must for our team
What about post-test?
It can be really useful if you want to push artifacts if the tests succeeded.
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.
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
More evidence for need of this feature:
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.)
+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?
bump any further updates to this one?
@fnichol @tyler-ball buuuuuump
+1 for multi-provisioning
bump
bump
+1
+1
+1
+1 this would be very useful
+1000
any updates on this ?
Related #564
+1 on behalf of a commercial user I work with. (Thanks, @cheeseplus, for tagging for future release)
+1 for post_create_command
- anyone know of a work around to hack this until the post_create_command
is available? Trying to execute a command after vagrant is up, but before Chef starts. Maybe it's possible to do this with a separate Vagrantfile.rb that gets merged with the config.vm.provision "shell"
configuration?
A hack would be to call kitchen exec <command>
after kitchen create
and before kitchen converge
+1 I would really like this!
+1
+1
+1
+1, for an implementation that would allow a run-multiple-provisioners-in-sequence scenario.
Cheers!
+1
+1
+1, would love to run both a Terraform and Ansible provisioner in sequence. Found a workaround (trigger ansible within terraform), but it doesn't feel like the right way to do it at all.
+1
+1
+1
+1
+1
+1
+1
I've locked this since the stream of +1s are not adding anything; we understand that people would like this feature but right now it is not planned or specced. If someone wants to take a crack at designing and implementing it we'd be very happy to help and mentor them!
Fixed by #1428