Chef-Provisioning


#1

I am trying to provision VMs in chef using the chef-provisioning-vagrant gem. I
keep running into “Errno::ENOENT
No such file or directory - vagrant status test_machine” errors during the
chef-client run.

Environment used: Red Hat Enterprise Linux Server release 6.2 (Santiago)
Steps:

  1. Installed chef-provisioning and chef-provisioning-vagrant gems.

  2. Set the driver details with the command: export CHEF_DRIVER=vagrant

  3. Created a recipe named ‘simple.rb’ with the following contents:
    require 'chef/provisioning’
    machine ‘test_machine’ do
    tag 'itsa_me’
    converge true
    end

  4. Ran the recipe with the command:
    chef-client -z simple.rb

        This gave the following output:
        [root@desktop1 machine_recipe]# chef-client -z simple.rb
    

[2014-11-25T09:49:54+05:30] WARN: No config file found or specified on command
line, using command line options.
[2014-11-25T09:49:54+05:30] WARN: No cookbooks directory found at or above
current directory. Assuming /root/machine_recipe.
[2014-11-25T09:49:55+05:30] WARN:


SSL validation of HTTPS requests is disabled. HTTPS connections are still
encrypted, but chef is not able to detect forged replies or man in the middle
attacks.

To fix this issue add an entry like this to your configuration file:

  # Verify all HTTPS connections (recommended)
  ssl_verify_mode :verify_peer

  # OR, Verify only connections to chef-server
  verify_api_cert true

To check your SSL configuration, or troubleshoot errors, you can use the
knife ssl check command like so:

  knife ssl check -c

Starting Chef Client, version 11.12.4
resolving cookbooks for run list: []
Synchronizing Cookbooks:
Compiling Cookbooks…
[2014-11-25T09:50:00+05:30] WARN: Node desktop1.example.com has an empty run
list.
Converging 1 resources
Recipe: @recipe_files::/root/machine_recipe/simple.rb

  • machine[test_machine] action converge
    • create new file /root/.chef/vms/test_machine.vm
    • update content in file /root/.chef/vms/test_machine.vm from none to
      130faa
    • — /root/.chef/vms/test_machine.vm 2014-11-25 09:50:00.271216083
      +0530
    • +++ /tmp/.test_machine.vm20141125-26563-1vmasgg 2014-11-25
      09:50:00.272215193 +0530
    • @@ -1 +1,6 @@
    • +Vagrant.configure(‘2’) do |outer_config|
      • outer_config.vm.define “test_machine” do |config|
      • config.vm.hostname = “test_machine”
      • end
    • +end
    • create node test_machine at http://127.0.0.1:8889
    • add normal.tags = [“itsa_me”]
    • add normal.chef_provisioning =
      {“location”=>{“driver_url”=>“vagrant:/root/.chef/vms”,
      “driver_version”=>“0.8.1”, “vm_name”=>“test_machine”,
      “vm_file_path”=>"/root/.chef/vms/test_machine.vm", “allocated_at”=>“2014-11-25
      04:20:00 UTC”, “host_node”=>“http://127.0.0.1:8889/nodes/”,
      “needs_reload”=>true}}
      ================================================================================
      Error executing action converge on resource ‘machine[test_machine]’
      ================================================================================

Errno::ENOENT

No such file or directory - vagrant status test_machine

Resource Declaration:

In /root/machine_recipe/simple.rb

3: machine ‘test_machine’ do
4: tag 'itsa_me’
5: converge true
6: end

Compiled Resource:

Declared in /root/machine_recipe/simple.rb:3:in `from_file’

machine(“test_machine”) do
action :converge
retries 0
retry_delay 2
guard_interpreter :default
chef_server {:chef_server_url=>“http://127.0.0.1:8889”,
:options=>{:client_name=>“desktop1.example.com”, :signing_key_filename=>nil}}
driver "vagrant"
cookbook_name "@recipe_files"
recipe_name "/root/machine_recipe/simple.rb"
attribute_modifiers [[“tags”,
#Proc:0x00000002c83780@/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/cheffish-0.9/lib/cheffish.rb:149]]
converge true
end

Running handlers:
[2014-11-25T09:50:00+05:30] ERROR: Running exception handlers
Running handlers complete

[2014-11-25T09:50:00+05:30] ERROR: Exception handlers complete
[2014-11-25T09:50:00+05:30] FATAL: Stacktrace dumped to
/root/.chef/local-mode-cache/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 5.395236455 seconds
[2014-11-25T09:50:00+05:30] ERROR: machine[test_machine]
(@recipe_files::/root/machine_recipe/simple.rb line 3) had an error:
Errno::ENOENT: No such file or directory - vagrant status test_machine
[2014-11-25T09:50:00+05:30] FATAL: Chef::Exceptions::ChildConvergeError: Chef
run process exited unsuccessfully (exit code 1)

  1. After the above step, a new file ‘test_machine.json’ was seen to be
    created in the <working_directory>/nodes folder with contents
    {
    “name”: “test_machine”,
    “normal”: {
    “tags”: [
    “itsa_me”
    ],
    “chef_provisioning”: {
    “location”: {
    “driver_url”: “vagrant:/root/.chef/vms”,
    “driver_version”: “0.8.1”,
    “vm_name”: “test_machine”,
    “vm_file_path”: “/root/.chef/vms/test_machine.vm”,
    “allocated_at”: “2014-11-25 04:20:00 UTC”,
    “host_node”: “http://127.0.0.1:8889/nodes/”,
    “needs_reload”: true
    }
    }
    }
    }
    Note: I was able to, modify the tags of the machine created by running the
    following recipe
    require 'chef/provisioning’
    machine ‘test_machine’ do
    tag 'test’
    converge true
    end
    Though the tags were modified, the error was still seen.

Any pointers on how to get rid of the error will be appreciated.

Thanks


#2

On Tue, Nov 25, 2014 at 10:01 AM, pratik_gadiya@persistent.co.in wrote:

I am trying to provision VMs in chef using the chef-provisioning-vagrant gem. I
keep running into “Errno::ENOENT
No such file or directory - vagrant status test_machine” errors during the
chef-client run.

Do you actually have Vagrant installed on the machine where you’re
doing the provisioning?

  • Julian


[ Julian C. Dunn jdunn@aquezada.com * Sorry, I’m ]
[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]