Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lifecycle hooks to various phases (including provisioners) #329

Closed
sethvargo opened this issue Jan 17, 2014 · 41 comments
Closed

Add lifecycle hooks to various phases (including provisioners) #329

sethvargo opened this issue Jan 17, 2014 · 41 comments

Comments

@sethvargo
Copy link
Contributor

Example #257

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

@lamont-granquist
Copy link
Contributor

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
Copy link
Contributor

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.

@johntdyer
Copy link

👍 This is a must for our team

@thedrow
Copy link

thedrow commented May 23, 2014

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

@lamont-granquist
Copy link
Contributor

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.

@neillturner
Copy link
Contributor

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

@lamont-granquist
Copy link
Contributor

More evidence for need of this feature:

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

@ghost
Copy link

ghost commented Sep 12, 2014

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.)

@awesomescot-zz
Copy link

+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?

@CpuID
Copy link

CpuID commented Jul 10, 2015

bump any further updates to this one?

@lamont-granquist
Copy link
Contributor

@fnichol @tyler-ball buuuuuump

@PurrBiscuit
Copy link

+1 for multi-provisioning

@lxhunter
Copy link

bump

1 similar comment
@sochoa
Copy link

sochoa commented Sep 24, 2015

bump

@sawanoboly
Copy link
Contributor

+1

2 similar comments
@francoiskha
Copy link

+1

@habelson
Copy link

+1

@z0mi3ie
Copy link

z0mi3ie commented Nov 4, 2015

+1 this would be very useful

@pburkholder
Copy link

+1 on behalf of a commercial user I work with. (Thanks, @cheeseplus, for tagging for future release)

@cheeseplus cheeseplus removed this from the Accepted Major milestone Mar 23, 2016
@chetanddesai
Copy link

chetanddesai commented Apr 28, 2016

+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?

@mwrock
Copy link
Member

mwrock commented Apr 28, 2016

A hack would be to call kitchen exec <command> after kitchen create and before kitchen converge

@pietervogelaar
Copy link

+1 I would really like this!

pietervogelaar added a commit to pietervogelaar/kitchen-puppet that referenced this issue Jun 22, 2016
The company I work for at the moment does SSL inception on the VPN connection. This way the installation of the puppet agent fails. If I copy the self signed CA pem file into the VM at "/etc/pki/ca-trust/source/anchors/vpn-ca.pem" and run "update-ca-trust", the SSL connection is valid and the puppet agent installation is successful. However, at the moment it's not possible to specify multiple Kitchen provisioners (test-kitchen/test-kitchen#329). An alternative is to use the custom_install_command, but right now this command is executed AFTER the puppet agent installation step, so I can't use it unless it's executed earlier.

Is this a correct solution or do you have an alternative?
@swimfrog
Copy link

+1

2 similar comments
@darwin67
Copy link

+1

@netflash
Copy link

netflash commented Dec 1, 2016

+1

@RamblingCookieMonster
Copy link

+1, for an implementation that would allow a run-multiple-provisioners-in-sequence scenario.

Cheers!

@tshafeev
Copy link

+1

1 similar comment
@gurumaia
Copy link

gurumaia commented Feb 1, 2017

+1

@burythehammer
Copy link

+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.

@azazi-sa
Copy link

+1

6 similar comments
@sputmayer
Copy link

+1

@rylarson
Copy link

+1

@smartb-pair
Copy link

+1

@jestallin
Copy link

+1

@DI-DaveGoodine
Copy link

+1

@seanguo
Copy link

seanguo commented Jun 23, 2017

+1

@test-kitchen test-kitchen locked and limited conversation to collaborators Jun 23, 2017
@thommay
Copy link
Contributor

thommay commented Jun 25, 2017

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!

@tas50 tas50 closed this as completed Jul 3, 2018
@cheeseplus
Copy link

Fixed by #1428

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests