厨师:上传修改后的食谱不起作用?
Chef: Uploading modified cookbook not working?
我正在尝试修改食谱并将其上传到我的 Chef 服务器,但是当我尝试这样做时,看起来食谱中的食谱在 Chef 服务器中没有更改。
我正在使用 Win2K8 机器作为我的工作站,我编辑 learn_chef_iis-0.2.0\recipes\default.rb。然后我做:
knife cookbook delete learn_chef_iis
然后:
knife cookbook upload learn_chef_iis
当我在操作码网络应用程序中查看 default.rb 时,它仍然显示相同的 default.rb(即,我的更改不存在)。
我看到了一些更改食谱版本的建议,并且我尝试通过编辑 metadata.rb "version" 来实现,但即使我这样做了,当我执行 "knife cookbook upload" 我仍然得到相同的版本 (0.2.0) 和未修改的 default.rb.
求助!!!我今天已经为此工作了一段时间,但卡住了:(!!
谢谢,
吉姆
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>
编辑:
这是修改后的 default.rb。这个可以吗?也许这个 default.rb 不好,所以它导致 "knife upload" 失败?
#
# 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
并且,这是一个 运行 和 "verbose" 输出:
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>
编辑 3:
我没有解释,但我创建了一本新的食谱如下:
http://learn.chef.io/learn-the-basics/windows/make-your-recipe-more-manageable/
这个名字叫"iis"。
然后我做了 "knife cookbook upload iis" 并且成功了,我在节点上做了 "chef-client -o "recipe[iis]" 并且成功了。
然后我稍微修改了食谱,再次上传了刀具和厨师客户端,并在 IIS 上看到了更新的信息。
所以,新的食谱似乎正在运行和更新。
奇怪:(???
我假设您的 Chef 存储库的结构基本上是这样的:
cookbooks/your_cookbook
包含:
metadata.rb
recipes/default.rb
providers/
resources/
如果您在 metadata.rb
中增加了版本号并且确定您是 运行ning
knife cookbook upload
在目录中,一切正常。 At least that's what the docs say.
或者您可以尝试从该目录退出到您的 chef 存储库的主目录并且 运行:
knife upload cookbooks
或
knife upload /
Again, that's what the docs say.
但是我没有太多的使用经验。 I use Berkshelf which is essential a dependency management tool that's a lot more seemless than Librarian-Chef,在我看来。
只需导航到您的食谱,运行:
berks init
然后当您通过 运行 进行更改时:
berks install
berks upload
更新您的 metadata.rb
文件中的版本号后,将您的食谱推送到您的 Chef 存储库。
希望对您有所帮助!
根据您的描述,您的 knife.rb
中可能有 2 个条目用于 cookbook_path
设置(需要一个数组)See the doc.
我很确定原始食谱在 cookbook_path
中列出的最后一个路径上,因此刀上传不会失败,但它会上传未修改的版本。
当您不确定自己住在哪里或者您希望从不在 cookbook_path
中的路径上传食谱时,您可以使用 -o .
覆盖此设置在食谱的父目录或 -o /absolut/path/to/parent/dir/
.
当您不确定输入不带参数的命令时,将显示帮助。
>knife cookbook upload
USAGE: knife cookbook upload [COOKBOOKS...] (options)
-a, --all Upload all cookbooks, rather than just a single cookbook
-s, --server-url URL Chef Server URL
--chef-zero-host HOST Host to start chef-zero on
--chef-zero-port PORT Port to start chef-zero on
-k, --key KEY API Client Key
--[no-]color Use colored output, defaults to false on Windows, true otherwise
--concurrency NUMBER_OF_THREADS
How many concurrent threads will be used
-c, --config CONFIG The configuration file to use
-o, --cookbook-path PATH:PATH A colon-separated path to look for cookbooks in
--defaults Accept default values for all questions
--include-dependencies Also upload cookbook dependencies
-d, --disable-editing Do not open EDITOR, just accept the data as is
-e, --editor EDITOR Set the editor to use for interactive commands
-E, --environment ENVIRONMENT Set ENVIRONMENT's version dependency match the version you're uploading.
--force Update cookbook versions even if they have been frozen
-F, --format FORMAT Which format to use for output
--freeze Freeze this version of the cookbook so that it cannot be overwritten
-z, --local-mode Point knife commands at local repository instead of server
-u, --user USER API Client Username
--print-after Show the data after a destructive operation
-V, --verbose More verbose output. Use twice for max verbosity
-v, --version Show chef version
-y, --yes Say yes to all prompts for confirmation
-h, --help Show this message
当你想知道它做什么或在哪里搜索某些东西时,运行 knife 在详细模式下 -VV
会给你很多信息:
使用 -VV 提取上传内容:
[...]
Uploading company-collectd [0.1.0]
DEBUG: Versions of cookbook 'collectd' returned by the server: 1.1.2
DEBUG: Matched cookbook 'collectd' with constraint '>= 0.0.0' to cookbook version '1.1.2' on the server
DEBUG: No chefignore file found at d:/chef/repo/cookbooks/chefignore no files will be ignored
INFO: Validating ruby files
DEBUG: Ruby file d:/chef/repo/cookbooks/company-collectd/attributes/default.rb is unchanged, skipping syntax check
DEBUG: Ruby file d:/chef/repo/cookbooks/company-collectd/metadata.rb is unchanged, skipping syntax check
DEBUG: Ruby file d:/chef/repo/cookbooks/company-collectd/recipes/default.rb is unchanged, skipping syntax check
INFO: Validating templates
INFO: Syntax OK
[...]
我正在尝试修改食谱并将其上传到我的 Chef 服务器,但是当我尝试这样做时,看起来食谱中的食谱在 Chef 服务器中没有更改。
我正在使用 Win2K8 机器作为我的工作站,我编辑 learn_chef_iis-0.2.0\recipes\default.rb。然后我做:
knife cookbook delete learn_chef_iis
然后:
knife cookbook upload learn_chef_iis
当我在操作码网络应用程序中查看 default.rb 时,它仍然显示相同的 default.rb(即,我的更改不存在)。
我看到了一些更改食谱版本的建议,并且我尝试通过编辑 metadata.rb "version" 来实现,但即使我这样做了,当我执行 "knife cookbook upload" 我仍然得到相同的版本 (0.2.0) 和未修改的 default.rb.
求助!!!我今天已经为此工作了一段时间,但卡住了:(!!
谢谢,
吉姆
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>
编辑:
这是修改后的 default.rb。这个可以吗?也许这个 default.rb 不好,所以它导致 "knife upload" 失败?
#
# 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
并且,这是一个 运行 和 "verbose" 输出:
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>
编辑 3:
我没有解释,但我创建了一本新的食谱如下:
http://learn.chef.io/learn-the-basics/windows/make-your-recipe-more-manageable/
这个名字叫"iis"。
然后我做了 "knife cookbook upload iis" 并且成功了,我在节点上做了 "chef-client -o "recipe[iis]" 并且成功了。
然后我稍微修改了食谱,再次上传了刀具和厨师客户端,并在 IIS 上看到了更新的信息。
所以,新的食谱似乎正在运行和更新。
奇怪:(???
我假设您的 Chef 存储库的结构基本上是这样的:
cookbooks/your_cookbook
包含:
metadata.rb
recipes/default.rb
providers/
resources/
如果您在 metadata.rb
中增加了版本号并且确定您是 运行ning
knife cookbook upload
在目录中,一切正常。 At least that's what the docs say.
或者您可以尝试从该目录退出到您的 chef 存储库的主目录并且 运行:
knife upload cookbooks
或
knife upload /
Again, that's what the docs say.
但是我没有太多的使用经验。 I use Berkshelf which is essential a dependency management tool that's a lot more seemless than Librarian-Chef,在我看来。
只需导航到您的食谱,运行:
berks init
然后当您通过 运行 进行更改时:
berks install
berks upload
更新您的 metadata.rb
文件中的版本号后,将您的食谱推送到您的 Chef 存储库。
希望对您有所帮助!
根据您的描述,您的 knife.rb
中可能有 2 个条目用于 cookbook_path
设置(需要一个数组)See the doc.
我很确定原始食谱在 cookbook_path
中列出的最后一个路径上,因此刀上传不会失败,但它会上传未修改的版本。
当您不确定自己住在哪里或者您希望从不在 cookbook_path
中的路径上传食谱时,您可以使用 -o .
覆盖此设置在食谱的父目录或 -o /absolut/path/to/parent/dir/
.
当您不确定输入不带参数的命令时,将显示帮助。
>knife cookbook upload
USAGE: knife cookbook upload [COOKBOOKS...] (options)
-a, --all Upload all cookbooks, rather than just a single cookbook
-s, --server-url URL Chef Server URL
--chef-zero-host HOST Host to start chef-zero on
--chef-zero-port PORT Port to start chef-zero on
-k, --key KEY API Client Key
--[no-]color Use colored output, defaults to false on Windows, true otherwise
--concurrency NUMBER_OF_THREADS
How many concurrent threads will be used
-c, --config CONFIG The configuration file to use
-o, --cookbook-path PATH:PATH A colon-separated path to look for cookbooks in
--defaults Accept default values for all questions
--include-dependencies Also upload cookbook dependencies
-d, --disable-editing Do not open EDITOR, just accept the data as is
-e, --editor EDITOR Set the editor to use for interactive commands
-E, --environment ENVIRONMENT Set ENVIRONMENT's version dependency match the version you're uploading.
--force Update cookbook versions even if they have been frozen
-F, --format FORMAT Which format to use for output
--freeze Freeze this version of the cookbook so that it cannot be overwritten
-z, --local-mode Point knife commands at local repository instead of server
-u, --user USER API Client Username
--print-after Show the data after a destructive operation
-V, --verbose More verbose output. Use twice for max verbosity
-v, --version Show chef version
-y, --yes Say yes to all prompts for confirmation
-h, --help Show this message
当你想知道它做什么或在哪里搜索某些东西时,运行 knife 在详细模式下 -VV
会给你很多信息:
使用 -VV 提取上传内容:
[...]
Uploading company-collectd [0.1.0]
DEBUG: Versions of cookbook 'collectd' returned by the server: 1.1.2
DEBUG: Matched cookbook 'collectd' with constraint '>= 0.0.0' to cookbook version '1.1.2' on the server
DEBUG: No chefignore file found at d:/chef/repo/cookbooks/chefignore no files will be ignored
INFO: Validating ruby files
DEBUG: Ruby file d:/chef/repo/cookbooks/company-collectd/attributes/default.rb is unchanged, skipping syntax check
DEBUG: Ruby file d:/chef/repo/cookbooks/company-collectd/metadata.rb is unchanged, skipping syntax check
DEBUG: Ruby file d:/chef/repo/cookbooks/company-collectd/recipes/default.rb is unchanged, skipping syntax check
INFO: Validating templates
INFO: Syntax OK
[...]