chef-training / chef_classroom

Chef-provisioning cookbook for managing a Chef Training Classroom
Other
5 stars 6 forks source link

Failure when deploying chef portal from local workstation #59

Open burtlo opened 8 years ago

burtlo commented 8 years ago

I execute this statement:

$ chef-client -z -r "role[class],recipe[chef_classroom::deploy_portal]"

And it spends time deploying the portal, then fails at the end.

...
[2015-11-09T16:52:06-06:00] INFO: Reading key frank-6-portal_key from file /Users/franklinwebber/.ssh/frank-6-portal_key
[2015-11-09T16:52:06-06:00] INFO: Executing ls -d /root/chef_classroom/roles/class.json on root@52.23.208.138
[2015-11-09T16:52:08-06:00] INFO: Completed ls -d /root/chef_classroom/roles/class.json on root@52.23.208.138: exit status 0
[2015-11-09T16:52:08-06:00] INFO: Executing mkdir -p /root/chef_classroom/roles on root@52.23.208.138
[2015-11-09T16:52:10-06:00] INFO: Completed mkdir -p /root/chef_classroom/roles on root@52.23.208.138: exit status 0

    ================================================================================
    Error executing action `upload` on resource 'machine_file[/root/chef_classroom/roles/class.json]'
    ================================================================================

    Errno::ENOENT
    -------------
    No such file or directory @ rb_file_s_stat - roles/class.json

    Resource Declaration:
    ---------------------
    # In /Users/franklinwebber/training/provisioners/chef_classroom/local-mode-cache/cache/cookbooks/chef_classroom/recipes/deploy_portal.rb

     25: machine_file "/root/chef_classroom/roles/class.json" do
     26:   machine "#{class_name}-portal"
     27:   local_path node['chef_classroom']['role_json']
     28:   action :upload
     29: end
     30:

    Compiled Resource:
    ------------------
    # Declared in /Users/franklinwebber/training/provisioners/chef_classroom/local-mode-cache/cache/cookbooks/chef_classroom/recipes/deploy_portal.rb:25:in `from_file'

    machine_file("/root/chef_classroom/roles/class.json") do
      action [:upload]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      chef_server {:chef_server_url=>"chefzero://localhost:8889", :options=>{:client_name=>"local_workstation", :signing_key_filename=>nil, :api_version=>"0"}}
      declared_type :machine_file
      cookbook_name "chef_classroom"
      recipe_name "deploy_portal"
      machine "frank-6-portal"
      local_path "roles/class.json"
      path "/root/chef_classroom/roles/class.json"
    end

[2015-11-09T16:52:10-06:00] INFO: Running queued delayed notifications before re-raising exception

Running handlers:
[2015-11-09T16:52:10-06:00] ERROR: Running exception handlers
Running handlers complete
[2015-11-09T16:52:10-06:00] ERROR: Exception handlers complete
Chef Client failed. 1 resources updated in 02 minutes 27 seconds
[2015-11-09T16:52:10-06:00] FATAL: Stacktrace dumped to /Users/franklinwebber/training/provisioners/chef_classroom/local-mode-cache/cache/chef-stacktrace.out
[2015-11-09T16:52:10-06:00] ERROR: machine_file[/root/chef_classroom/roles/class.json] (chef_classroom::deploy_portal line 25) had an error: Errno::ENOENT: No such file or directory @ rb_file_s_stat - roles/class.json
[2015-11-09T16:52:10-06:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

The file exists locally on my system relative to where I am deploying it. It exists in the vendor'd cookbooks. It also exists on the remote machine.

burtlo commented 8 years ago

Workaround

  1. Specifying a fullpath to the file:
default['chef_classroom']['role_json'] = '/Users/franklinwebber/training/provisioners/chef_classroom/roles/class.json'
  1. Vendor cookbooks
berks vendor cookbooks

This solution does not seem ideal.

cheeseplus commented 8 years ago

So because of how Chef Provisioning and the vendoring works there isn't a good way to provide the path in a relative sense that I have found so the attribute ['chef_classroom']['role_json'] MUST be set to a full path for anything to work.

It is less than ideal but I've yet to find a better way to work within the existing mechanics.

burtlo commented 8 years ago

I'll update the documentation to state that the facilitator needs to update the attributes/default.rb file with their amazon credentials and all their settings as well as setup the class.json.

@cheeseplus am I right in thinking that we could move all the configuration overrides into the class.json file?