vagrant,chef , How to provide a way for Chef users to de-register their disposable Vagrant VM?


How to provide a way for Chef users to de-register their disposable Vagrant VM?

Question:

Tag: vagrant,chef

I've been wrestling with this one for a while, figured I would open it up to the stackoverflow community:

I've got a setup where multiple developers can clone and spin up a Vagrant VM which will get provisioned with Chef. The VM has a hostname unique for the user, based on the host's hostname.

If a user wants to destroy and recreate it, they are instructed to use vagrant destroy, which, with the help of the vagrant-butcher plugin, will de-register the VM from Chef.

However, inevitably, users will rm -rf their VM and attempt to re-create it, getting the dreaded HTTP 403 Forbidden from Chef, because the VM is already registered with a different key.

I then have to manually delete the node and client from Chef, then have them try it again.

Has anyone ever through of a creative way of providing a user a way of de-registering an obsolete VM to be able to re-use the name (assuming both the .pem key and the vagrant folder is gone)?


Answer:

Run the following script :-)

knife client delete $(hostname) -y
knife node delete $(hostname) -y

Update

Avoid using a shared development environment. Use test kitchen to create a stand-alone test driven development environment. Under the hood it can still use vagrant with chef zero (in memory chef server)

http://kitchen.ci/

Even better news is that test kitchen comes pre-installed with the chef development kit.


Related:


Pausing for input in vagrant shell script


git,shell,vagrant
I am using the VVV vagrant box (https://github.com/Varying-Vagrant-Vagrants/VVV) I am trying to build my own shell script that downloads a repository. I am doing this: echo "cloning staging server repo" git clone https://[email protected]/rep/therepo.git If I run this shell script on its own then the command prompt will ask me to...

problems understanding workflow and set up of vagrant and laravel homestead


laravel,vagrant,virtual-machine,homestead
Up till now I've used a wamp server and thought I'd give Laravel Homestead a try as it's meant to be easier! I'm having problems getting the set up right and I'm confused about what I'm doing and where I should be doing them. I've got vagrant and virtual box...

knife-windows is definitely installed but bootstrap still fails


chef,knife
I have definitely installed knife-windows. Chef gem list shows knife-windows but when I run bootstrap I'm told it's not installed. sudo -u user -H sh -c "cd /home/user/chef-repo/; chef gem list" sudo -u user -H sh -c "cd /home/user/chef-repo/; knife bootstrap windows winrm $VMIP -r 'role[build_server]' -x 'domain\user' -V -P...

Difference between convergence and idempotency in CHEF


chef,theory,configuration-management
What is the basic difference between convergence and idempotency in CHEF?

Puppetelabs Vagrant Box password not working


vagrant,puppet
I'm trying to bring up a Puppetlabs vagrant box and the password is not working. Tried 'vagrant' and 'puppet'. Anyone get these working?

Equivalent of String.Format in a Chef/Bash Recipe


linux,chef
looking for something similar to .Net string format in a chef recipe ie. string phone = String.format("phone: {0}",_phone); I have a Chef recipe where I need to build up a command string with 30 of these params so hoping for a tidy way to build the string, in principle Im...

Passing commands to subprocess in shell


bash,shell,vagrant,karaf
if a certain command (in my case ./karaf) runs a sub-process in a shell, that accepts its own commands, is there someway to execute the subsequently listed commands in a script as commands to the subprocess? For example, sudo ./karaf opens a process in the shell that accepts its own...

Support multiple notifies in definitions


chef
This is a followup question from Configure providers from variables, in a generic way I wrapped some providers into definitions and I was wondering how to handle the notifies. I succeeded in writing a cheap implementation where I can pass an array of arrays, similar to this: provider_definition name do...

Cannot find the LWRP in custom cookbook


chef,cookbook
I am building a cookbook that installs my node js files and then sets up initd scripts for them. Unfortunately I cannot call the non-default LWRP in the cookbook. Here is the error from the chef-client run: 26>> blah_node_as_service 'setting up pricing service' do 27: directory '/var/blah/blah-pricing/' 28: script 'pricing-http-server-cluster.js'...

PHPStorm Drush on Vagrant


drupal-7,vagrant,phpstorm,drush
I'm wondering if it's possible to use the command line tool in PHPstorm to run Drush on a Vagrant box? If so how do I go about this? Thanks, Neil....

Ruby: Looping and calling associative arrays (TypeError no implicit conversion of String into Integer)


ruby-on-rails,arrays,ruby,chef
So I have this piece of code: node['nginx'][0]['server_name']='black.domain.com' node['nginx'][0]['app_server']='http://10.50.0.163:8090' node['nginx'][0]['redirect_path']='/mesh' node['nginx'][1]['server_name']='red.domain.com' node['nginx'][1]['app_server']='http://10.50.0.163:8090' node['nginx'][1]['redirect_path']='/mesh' node.default['nginx'].each do |key, value| value.each do |prop| Chef::Log.info prop['app_server'] end end Like the title says it's erorring out on: 21>> Chef::Log.info prop['app_server'] My question is...

Creating a docker swarm cluster in Vagrant


ubuntu,vagrant,virtual-machine,docker-swarm
I'm trying to create a swarm cluster of diffferent ubuntu VMs running in Vagrant. These have docker enabled via the vagrant file that boots them. Of the three VM's I started the swarm cluster on one machine in the following way docker pull swarm docker run --rm swarm create This...

Display django runserver output from Vagrant guest VM in host Mac notifications?


python,django,osx,notifications,vagrant
I can think of many ways to skin this cat, and Googling hasn't shown an elegant solution either. Does anyone have an easy / elegant way to forward the output from Django's runserver command in a terminal connected to a guest Vagrant VM to the host to display to Mac's...

Chef in local mode cookbooks only


vagrant,chef
I'm trying to setup a workflow to develop Chef cookbooks locally. We're currently using Chef Server with the provisioned nodes using chef-client. As part of the new workflow, we want to be able to start using Vagrant to test cookbooks locally to avoid incurring in the costs of testing on...

How to use/implement this Chef recipe?


chef,chef-recipe
I am really new with Chef, but am trying to use this Chef recipe: https://gist.github.com/kardeiz/7273938 I thought that I needed to create a new cookbook and put the recipe into default.rb, and the .erb into templates/default, but when I try to use the cookbook ("dcpromote") in chef-client, I am getting...

Vagrant shell provisioning phpPgAdmin password


bash,shell,vagrant,vagrantfile,phppgadmin
How would I get my Vagrant shell script to supply the password when creating a user while provisioning phpPgAdmin? ie. when I supply this command sudo htpasswd -c /etc/phppgadmin/.htpasswd vagrant it prompts for a password for the vagrant user so I can login to phpPgAdmin. How can I script this...

Configure providers from variables, in a generic way


ruby,chef,aws-opsworks
How can I create a recipe that will populate its attributes using the fiels from an instance of an object in a generic way? As an example, consider the following recipe: component = $auth_docker docker_image component.name do registry component.registry tag component.tag action :pull end When you have 50s of recipes...

Installing Passenger & Nginx using Vagrant shell script


shell,nginx,vagrant,passenger
This is my first post to SO so I hope I'm asking this correctly. I wrote a shell script to automate the installation of Passenger & Nginx (along with some other components) without any user input on a Vagrant VM running Ubuntu 14.04. It works fine using the following: echo...

Chef cleanup - nodes, environments, cookbooks, roles etc.,


chef
I recently inherited a chef environment that has quite some stale nodes and environments and lot of old cookbooks. For e.g. the AWS console shows that I have around 150 instances running, but a knife status shows 700 nodes. Normally, I use ansible, so I understand how that works to...

Chef Knife not saving changes with editor


chef,chef-recipe,chef-solo,knife
I want to create a role with knife. So I run: > knife role create beautifulprayer ERROR: RuntimeError: Please set EDITOR environment variable No problem! Just add the editor. Afterwards: > knife role create beautifulprayer This opens the editor that I have set (subl) and goes ahead once the editor...

Error 'invalid parameter include_src' when provisionning RabbitMQ with Puppet on Vagrant


rabbitmq,vagrant,puppet,git-submodules
I am trying to install the RabbitMQ module on my virtual machine. I used : git submodule add https://github.com/puppetlabs/puppetlabs-rabbitmq.git and I installed every dependecy I could find the same way (which are, like listed in this answer : stdlib, epel, staging and erlang). I reduced my manifest to the bare...

Vagrant box does not see new box_url even after reloading


vagrant,vagrantfile
I updated my Vagrantfile's confg.vm.box_url to a new URL (the box is hosted on a server who's IP changed) and no amount of vagrant reloading will make Vagrant see the new URL. When I run vagrant reload --debug, I see it attempt to fetch metadata from the old URL. The...

The various components of Chef


bash,chef
Just getting started with chef and it looks like there are several components, which I'm finding rather confusing. They are all available for download via https://downloads.chef.io/ chef server to manage the centralized chef server chef client to manage each node chefdk to assist in development of chef chef "workstation" -...

Chef Attributes, How to get the value of a specific key


chef,chef-recipe
I'm trying to manage a chef role as below. In this case the attribute node["customer"]["name"] is an array. In the recipe I need to get the value of the first element of the array node["customer"]["name"] as "foo". "customer" => { "name" => { ["foo"] => { "prod" => { "apache"...

Vagrant synced folder issue on windows?


windows,html5,apache2,vagrant,atom-editor
I am using vagrant for development of a HTML5 app. I use Apache2 as web server. After I add some lines to my synced json file, my server serves unknown characteres at the end of the file instead of my changes. Any ideas why this strange behaviour happens?

Chef workstation is unable to find knife.rb unless in “chef-repo”


chef,knife
when I run knife node list while in /home/ec2-user it complains "WARNING: No knife configuration file found ERROR: Your private key could not be loaded from /etc/chef/client.pem Check your configuration file and ensure that your private key is readable" when I run knife node list while in /home/ec2-user/chef-repo it...

knife search node platform on windows and mac


chef
I'm running chef 12, on ubuntu 14.04 When I run a knife node show -l "nodename" on a mac the platform attribute comes back with mac_os_x 10.10.3, mac_os_x 10.8.4 etc. When I run this on the windows machines they all return windows 6.1.7601. I don't see the attribute that shows...

Error homestead up


laravel,vagrant,homestead
I'm installing homestead for Laravel 5 (Windows) I've Already installed Vagrant and VirtualBox Following this tutorial: https://laracasts.com/lessons/say-hello-to-laravel-homestead-two When i run homestead up This is the error result: C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/psych.rb:205:in `parse': (<unknown> ): did not find expected key while parsing a block mapping at line 3 column 1 (P sych::SyntaxError) from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/psych.rb:205:in...

The box 'laravel/homestead' could not be found


php,ubuntu,laravel,vagrant,laravel-5
Trying to configure laravel 5.1. Cloned the laravel/homestead After cloning it to Home directory. Throwing error when tried to run the vagrant up command as below: [email protected]:~/laravel/homestead$ vagrant up Bringing machine 'default' up with 'virtualbox' provider... There are errors in the configuration of this machine. Please fix the following errors...

How does Chef recipe get/retrieve parameters from databag?


ruby,chef,chef-recipe
I have been trying to learn Chef and trying to test a small Chef cookbook that would do dcpromo of a Windows 2008 R2 server. I don't remember exactly where I got the two files originally, but I was able to get it working. The original dcpromo_unattend.txt.erb file was: [DCINSTALL]...

Vagrant + puppet + docker


mysql,docker,vagrant,puppet
I'm new with this technologies but I want to learn about automation and containers stuff. I read some documentation about this 3 products and I want to know if is possible to automate almost everything in a large environment using this products. Vagrant for deploy VMs (let's say 10 at...

Chef - no resource or method named windows_http_acl


chef
I'm trying to use the windows_http_acl lwrp inside one of my cookbooks. When I try and use it, I get this error. ================================================================================ Recipe Compile Error in c:/chef/cache/cookbooks/foo/recipes/bar.rb ================================================================================ NoMethodError ------------- No resource or method named `windows_http_acl' for `Chef::Recipe "bar"' Cookbook Trace: --------------- c:/chef/cache/cookbooks/foo/recipes/bar.rb:26:in `from_file' Relevant...

Would using Vagrant be overkill? [on hold]


python,windows,ubuntu,vagrant,virtualbox
I'm a developer-hobbyist running Windows 8.1 on a Yoga 2 Pro. I mostly do Python/Django work but I think I'm gonna pick up Ruby soon. The thing is, Windows always seems to be the limiting factor for any project I want to pick up. Last time I tried to install...

How to access Guest's port 3000 from Host?


ruby-on-rails,vagrant,virtualbox,portforwarding,vagrantfile
Here's my Vagrantfile: # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure(2) do |config| config.vm.box = "ubuntu-14.04-x64" # Sync'd folders config.vm.synced_folder ".", "/vagrant", disabled: true config.vm.synced_folder "~/work", "/home/vagrant/work", create: true config.vm.synced_folder "~/apt-archives", "/var/cache/apt/archives/", create: true # Ubuntu VM config.vm.define "ubuntu" do |ubuntu| ubuntu.vm.provision "shell", path: "provision.sh", privileged: false...

How to change default Nginx setting on Homestead Laravel Virtualbox VM


laravel,nginx,vagrant,virtualbox,homestead
I merely followed the default Laravel Homestead setup here using VirtualBox. Working great. But I need an additional Nginx rewrite setting in my apps vhost file on the VM, something like; location / { if ($request_method !~ "(POST)"){ rewrite .... } try_files $uri $uri/ /index.php?$query_string; } I can add that...

Chef Configuration Constructs by Example


configuration,chef
I am trying to wrap my head around Chef and its many configuration constructs: So we have: Nodes Run Lists Roles Recipes Attributes Environments Cookbooks Templates and even 1 more thing not on that diagram: Data Bags This is a bit overwhelming. After reading pretty deep into the Chef docs,...

How to use Chef Tracking Plugin in Jenkins


jenkins,chef,jenkins-plugins
I have a chef workstation setup on my Jenkins machine and currently use a "execute shell" in jenkins to run a shell script which runs knife bootstrap commands (for configuring nodes) .I have already installed the chef tracking plugin, but dont know how to use it for "tracking when/where/what files...

Iterating over EncryptedDataBagItem in Chef Recipe


ruby,json,chef,devops
I would like to decrypt a chef data bag item (named passwords) and store all of its attributes in a temporary JSON file which is read (and then deleted) by a node.js app. Is there a way to iterate over attributes of a data bag ITEM and get their values?...

Vagrant java 1.6 to 1.8


java,ssh,vagrant
I Installed vagrant on my machine with hashicorp-precise32 virtual machine. It installed java 1.6 whereas i want java 1.8. Do i have to install another virtual machine? How to get java 1.8?

Vagrant Port Fowarding on Windows


ruby-on-rails,vagrant,virtual-machine
I've looked around at some other threads here on Stack Overflow and found some solutions, but nothing is working for me. I am running a Rails Server (using Puma) which defaults to using port 3000. Running rails s on vm => Booting Puma => Rails 4.2.1 application starting in development...

Common session.save_handler for all projects


php,symfony2,session,vagrant
I'm using vagrant virtual machine for local PHP development and I noticed that there are session write issues when using vagrant-winnfsd plugin. The plugin serves fine my needs, that's why I don't want to reconfigure vagrant, but rather solve the read/write problem. I don't know the origin of the problem,...

mup setup/deploy - ECONNREFUSED on 127.0.0.1


vagrant,meteor-up,vagrant-windows
I'm trying to mup deploy the todos example of Meteor to a Vagrant VM running Ubuntu 14.04 LTS x64. Meteor Up supports Windows (I'm on Windows 7): You can use install and use Meteor Up from Linux, Mac and Windows. This is my c:\code\todos\mup.json: { "servers": [ { "host": "127.0.0.1",...

Chef: Uploading modified cookbook not working?


chef
I'm trying to modify and upload a cookbook to my Chef server but when I try that, it looks like the recipe inside the cookbook is not changed in Chef server. I am using a Win2K8 machine as my workstation, and I edit the learn_chef_iis-0.2.0\recipes\default.rb. I then do: knife cookbook...

rails 2.3 server running inside vagrant environment not accessible in host machine mac os x browsers


ruby-on-rails,browser,vagrant,hosts,mongrel
in vagrant I am using: box 'prorail/centos-5.8-x86_64' in vagrant i am running rails 2.3 server like: [[email protected] myapp]$ script/server => Booting Mongrel => Rails 2.3.5 application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server in my hosts file i have added this line at...

Pass a variable from bash into chef template


ruby,chef,chef-recipe,chef-solo
In my chef recipe, I have a bash ruby block. I need some value generated from it passed to my templates. For example, the joke variable in here: bash "create opal user" do code <<-EOH joke='my funny joke' echo $joke EOH end template '/joke.txt' do source 'joke.txt.erb' variable(joke:"#{joke}") end ...

Syncing Vagrant VMs across different physical servers


linux,vagrant,backup,virtual-machine,sync
I'm using Vagrant to deploy my VMs and my current setup looks like this: server1 = VM1, VM2, VM3 ( main production server ) server2 = VM1, VM2, VM3 ( backup server ) My questions is, can I somehow sync the VMs across the different physical servers in case one...

Can I reference multiple versions of a Chef cookbook?


chef,chef-recipe,cookbook
Is it possible to reference multiple versions of a Chef cookbook within a recipe like the following where a recipe in one cookbook (foo) references multiple versions of a recipe in another cookbook (bar) where the version variable is populated before this block? begin case version when "" include_recipe "cookbook-bar"...

Booting up Vagrant from Jenkins throws Permission Denied


jenkins,vagrant,jenkins-plugins,vagrant-plugin
I am trying to Boot up Vagrant VM from Jenkins. I gave Vagrantfile path in 'Boot up Vagrant VM'. When the job runs, I get the following error: Failed to iterate on remote directory vagrant_projs [ vagrant ]: Executing command :[vagrant, up] in folder /Users/abc/Desktop/vagrant_projs [vagrant_projs] $ vagrant up [...

Using one puphpet config for both osx & win


vagrant,puphpet
Is it possible with puphpet configs to have the code directory change according to the host OS? I get that this can be done with the actual vagrant file, but I can't see how to do it from the yaml. I've attempted to add a qualifying field to the yaml:...