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 delete learn_chef_iis
then:
knife cookbook upload learn_chef_iis
and when I look at the default.rb in the opcode web app, it still shows the same default.rb (i.e., my changes are not there).
I've seen some suggestions to change the version of the cookbook and I've tried that by editing the metadata.rb "version", but even when I do that, when I do the "knife cookbook upload" I still end up with the same version (0.2.0) and with the unmodified default.rb.
HELP!!! I've been working on this for awhile today and am stuck :(!!
Thanks,
Jim
PS C:\Users\Administrator\chef-repo\learn_chef_iis-0.2.0> knife cookbook upload learn_chef_iis
Uploading learn_chef_iis [0.2.0]
Uploaded 1 cookbook.
PS C:\Users\Administrator\chef-repo\learn_chef_iis-0.2.0> knife cookbook upload learn_chef_iis --force
Uploading learn_chef_iis [0.2.0]
Uploaded 1 cookbook.
PS C:\Users\Administrator\chef-repo\learn_chef_iis-0.2.0>
EDIT:
Here's the modified default.rb. Is this ok? Maybe this default.rb is bad so it causes the "knife upload" to fail?
#
# Cookbook Name:: learn_chef_iis
# Recipe:: default
#
# Copyright (C) 2014
#
#
#
powershell_script 'Install IIS' do
code <<-EOH
Import-Module ServerManager
Add-WindowsFeature Web-Server
EOH
guard_interpreter :powershell_script
not_if "(Get-WindowsFeature -Name Web-Server).InstallState -eq 'Installed'"
end
service 'w3svc' do
action [:enable, :start]
end
template 'c:\inetpub\wwwroot\Default.htm' do
source 'index.html.erb'
end
and, here's a run with "verbose" output:
PS C:\Users\Administrator\chef-repo> knife cookbook upload learn_chef_iis -V
INFO: Using configuration from C:/Users/Administrator/chef-repo/.chef/knife.rb
Uploading learn_chef_iis [0.2.0]
INFO: Validating ruby files
INFO: Validating templates
INFO: Syntax OK
INFO: Saving learn_chef_iis
INFO: Uploading files
INFO: Upload complete!
Uploaded 1 cookbook.
PS C:\Users\Administrator\chef-repo>
EDIT 3:
I don't have an explanation, but I created a new cookbook following:
http://learn.chef.io/learn-the-basics/windows/make-your-recipe-more-manageable/
This one is named "iis".
Then I did "knife cookbook upload iis" and that worked, and I did "chef-client -o "recipe[iis]" on the node and that worked.
I then modified the recipe slightly and did the knife upload and chef-client again and saw the updated info on the IIS.
So, the new cookbook seems to be working and updating.
Strange :(???
According to what you describe your probably have 2 entries in your
knife.rb
for thecookbook_path
setting (it takes an array) See the doc.I'm pretty sure the original cookbook is on the last path listed in the
cookbook_path
so knife upload don't fail but it upload the unmodified version.When you're unsure of where you're living or if you wish to upload a cookbook from a path not in the
cookbook_path
you can override this setting with-o .
when you're on the parent directory for the cookbook or-o /absolut/path/to/parent/dir/
.When you're unsure about a command type it without arguments, the help will be displayed.
And when you're wondering what it does or where it search for something, run knife in verbose mode with
-VV
which gives you a lot of informations:Extract of an upload with -VV: