14

I followed the OpsCode quickstart guide and things went fairly smoothly, but now I'm running into issues experimenting with roles. I have a "starter" role in my repo that was provided by OpsCode. When I follow the first official documentation I could find and run the following from the top of my chef repo:

knife upload roles

it simply returns and nothing happens. I get no role (new or updated) on my chef server. The following line does work for creation and updating:

knife role from file .\roles\starter.rb

but I find it overly cumbersome and I would prefer something that just pushes my entire repo up to the server (or at least all of the roles) to make me more confident that everything is up to date.

Josh Gagnon
  • 5,342
  • 3
  • 26
  • 36

3 Answers3

31

Yeah, in this case Chef is a little bit inconsistent. I use the next 3 lines to push by whole repo to chef-server (of course after the tests have passed):

knife cookbook upload --all
knife role from file roles/*.rb
knife data bag from file --all
Draco Ater
  • 20,820
  • 8
  • 62
  • 86
5

knife upload is based on the previous knife-essentials gem (now merged in chef under the name chef_fs).

https://github.com/opscode/chef/issues/1641 (and https://github.com/jkeiser/knife-essentials/issues/67) describe the issue: knife upload only support .json files for roles.

That's why your command knife upload does not output anything.

If you want to use knife upload, you have to convert all roles to json first (https://gist.github.com/red56/834890 for an example)

kamaradclimber
  • 2,479
  • 1
  • 26
  • 45
0

Suggested solution from Draco, didn't work for me to upload the data_bags. Here is what I did.

knife cookbook upload --all
knife role from file roles/*.rb
knife upload data_bags/
Starx
  • 77,474
  • 47
  • 185
  • 261