質問

I'm getting the following error when I try to run my Chef recipe and I am at a loss as to what I'm doing wrong. I'm only really getting started with it.

================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/app/recipes/default.rb
================================================================================

Chef::Exceptions::ValidationFailed
----------------------------------
Option group's value #<Chef::Node::Attribute:0x7f5282d15700> does not match regular expression [/^([-a-zA-Z0-9_.\\ ]+)$/, /^\d+$/]

Cookbook Trace:
---------------
  /var/chef/cache/cookbooks/app/recipes/default.rb:25:in `from_file'
  /var/chef/cache/cookbooks/app/recipes/default.rb:23:in `from_file'

Relevant File Content:
----------------------
/var/chef/cache/cookbooks/app/recipes/default.rb:

  1:  #
  2:  # Cookbook Name:: app
  3:  # Recipe:: default
  4:  #
  5:
  6:  group node[:app][:group][:name] do
  7:      gid node[:app][:group][:gid]
  8:      append true
  9:  end

[2014-02-03T09:42:24+00:00] ERROR: Running exception handlers
[2014-02-03T09:42:24+00:00] FATAL: Saving node information to /var/chef/cache/failed-run-data.json
[2014-02-03T09:42:24+00:00] ERROR: Exception handlers complete
[2014-02-03T09:42:24+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-02-03T09:42:24+00:00] FATAL: Chef::Exceptions::ValidationFailed: Option group's value #<Chef::Node::Attribute:0x7f5282d15700> does not match regular expression [/^([-a-zA-Z0-9_.\\ ]+)$/, /^\d+$/]

These are the values from attributes/default.rb:

default[:app][:group][:name]            = "nginx"
default[:app][:group][:gid]             = 123456

I have changed it so the values are in the code and still get the same error:

================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/app/recipes/default.rb
================================================================================

Chef::Exceptions::ValidationFailed
----------------------------------
Option group's value #<Chef::Node::Attribute:0x7fa2b7ef2ef8> does not match regular expression [/^([-a-zA-Z0-9_.\\ ]+)$/, /^\d+$/]

Cookbook Trace:
---------------
  /var/chef/cache/cookbooks/app/recipes/default.rb:25:in `from_file'
  /var/chef/cache/cookbooks/app/recipes/default.rb:23:in `from_file'

Relevant File Content:
----------------------
/var/chef/cache/cookbooks/app/recipes/default.rb:

  1:  #
  2:  # Cookbook Name:: app
  3:  # Recipe:: default
  4:  #
  5:
  6:  group "nginx" do
  7:      gid 123456
  8:      append true
  9:  end

[2014-02-03T09:53:35+00:00] ERROR: Running exception handlers
[2014-02-03T09:53:35+00:00] FATAL: Saving node information to /var/chef/cache/failed-run-data.json
[2014-02-03T09:53:35+00:00] ERROR: Exception handlers complete
[2014-02-03T09:53:35+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-02-03T09:53:35+00:00] FATAL: Chef::Exceptions::ValidationFailed: Option group's value #<Chef::Node::Attribute:0x7fa2b7ef2ef8> does not match regular expression [/^([-a-zA-Z0-9_.\\ ]+)$/, /^\d+$/]
役に立ちましたか?

解決

Changing my code to the following worked:

default[:app][:group]                    = "nginx"

And

group node[:app][:group] do
    append true
end

For some reason it doesn't like node[:app][:group][:name]

他のヒント

Sometimes, you get the same error when you don't have the hostname in /etc/hosts.

Even though maybe that machine does not belong to a domain, you should still add the hostname next to the loopback address 127.0.0.1.

Hope it helps!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top