包装器供应docker与厨师独奏获取节点名称找不到错误

我正在使用厨师版本11.16.4和packer v 0.7.1与docker v1.3.0

在安装厨师独奏后,我无法获得厨师独奏来运行厨师独奏菜单。

我收到以下错误:

错误:无法确定节点名称:configurationnode_name或configuration系统的主机名和fqdn

我在互联网上探索,试图找出发生了什么事情,而这个错误似乎很less见,因为node_name通常由系统给定一个默认值,或者在solo.rb中分配,这在我看来不能直接在包装器中被覆盖configuration模板。

我是否做了我的打包器configuration错误,或者这是厨师独奏和docker供应之间的不兼容问题?

我正在使用下面的打包器configuration:

{ "variables": { "version": "", "base-image-version": "" }, "builders":[{ "type": "docker", "image": "centos:latest", "pull": true, "export_path": "zookeeper-base-{{user `version`}}.tar" }], "provisioners":[ { "type": "chef-solo", "cookbook_paths": ["../chef-simple/cookbooks"], "install_command":"curl -L https://www.opscode.com/chef/install.sh | bash", "execute_command":"chef-solo --no-color -c {{.ConfigPath}} -j {{.JsonPath}}", "run_list":["recipe[zookeeper::install]"], "json":{"node_name":"zookeeper-box","env_name":"dev","ip":"10.10.10.10"}, "prevent_sudo":true }], "post-processors": [{ "type": "docker-import", "repository": "ed-sullivan/zookeeper-base", "tag": "{{user `version`}}" }] } 

我通过将一个Docker主机名添加到json文件中的execute_command来解决这个问题。

"run_command": ["-d", "--hostname=foobar", "-i", "-t", "{{.Image}}", "/bin/bash"]

我还必须安装主机名包(我认为厨师使用它来查找主机名)和curl包。

"inline": ["yum -y update; yum -y install curl; yum -y install hostname"]

希望有帮助!

我最终通过创buildconfiguration模板来解决这个问题,该模板定义了node_name,并使用文件提供程序安装chef文件。

这是更新的configuration

 { "variables": { "version": "0.1", "base-image-version": "", "chef_dir" : "/tmp/packer-chef-client", "chef_env" : "dev" }, "builders":[{ "type": "docker", "image": "centos:latest", "pull": true, "export_path": "zookeeper-base-{{user `version`}}.tar" }], "provisioners":[ { "type": "shell", "inline": [ "mkdir -p {{user `chef_dir`}}", "yum install -y tar" ] }, { "type": "file", "source": "../chef/cookbooks", "destination": "{{user `chef_dir`}}" }, { "type": "chef-solo", "install_command":"curl -L https://www.opscode.com/chef/install.sh | bash", "execute_command":"chef-solo --no-color -c {{.ConfigPath}} -j {{.JsonPath}}", "run_list":["recipe[zookeeper::install]"], "prevent_sudo":true, "config_template":"./solo.rb.template" }], } 

和相应的configuration模板文件

 log_level :info log_location STDOUT local_mode true ssl_verify_mode verify_peer role_path "{{user `chef_dir`}}/roles" data_bag_path "{{user `chef_dir`}}/data_bags" environment_path "{{user `chef_dir`}}/environments" cookbook_path [ "{{user `chef_dir`}}/cookbooks" ] node_name "packer-docker-build"