Mode value for directory resource?


#1

OK, this is bombing on me:

directory “/foo/bar” do
owner "username’
group "groupname"
mode 0700
end

I’ve tried all of

mode "0700"
mode 0700
mode 700
mode “700”

And I always get this:

ERROR: directory[/foo/bar]
(/var/chef/cache/cookbooks/mycookbook/recipes/foo.rb:21:in
`from_file’) had an error:
Option mode’s value 44 does not match regular expression /^\d{3,4}$/

So it looks like something’s converting to decimal (0700 octal = 448
decimal), stripping off the 8 because it’s not a legal octal digit,
and then complaining about the invalid mode. Any help here?

This is chef 0.9.8.


Mark J. Reed markjreed@gmail.com


#2

Oh, and I saw this on
http://wiki.opscode.com/display/chef/Resources#Resources-Directory:

A note about mode: When specifying the mode, the value can be a quoted string, eg “644”. For a >numeric value (i.e., without quotes), it should be 5 digits, e.g., 00644 to ensure that Ruby can parse it >correctly. For more detail, see Ticket CHEF-174.

But neither the quotes nor the leading zero helped.

On Wed, Aug 11, 2010 at 5:05 PM, Mark J. Reed markjreed@gmail.com wrote:

OK, this is bombing on me:

directory “/foo/bar” do
owner "username’
group "groupname"
mode 0700
end

I’ve tried all of

mode "0700"
mode 0700
mode 700
mode “700”

And I always get this:

ERROR: directory[/foo/bar]
(/var/chef/cache/cookbooks/mycookbook/recipes/foo.rb:21:in
`from_file’) had an error:
Option mode’s value 44 does not match regular expression /^\d{3,4}$/

So it looks like something’s converting to decimal (0700 octal = 448
decimal), stripping off the 8 because it’s not a legal octal digit,
and then complaining about the invalid mode. Any help here?

This is chef 0.9.8.


Mark J. Reed markjreed@gmail.com


Mark J. Reed markjreed@gmail.com


#3

On chef 0.9.8, using shef -s (standalone), I tested this quite briefly:
Ohai2u aj@AJ-Christensens-MacBook-Pro.local!
chef > recipe
chef:recipe > directory “/tmp/foo”
=> #<Chef::Resource::Directory:0x101f90310 @not_if_args={},
@cookbook_name=nil, @updated=false, @resource_name=:directory,
@notifies_immediate=[], @before=nil,
@run_context=#<Chef::RunContext:0x101fbda18
@resource_collection=#<Chef::ResourceCollection:0x101fbd928
@resources_by_name={“directory[/tmp/foo]”=>0},
@resources=[#<Chef::Resource::Directory:0x101f90310 …>],
@insert_after_idx=nil>, @cookbook_collection={},
@node=<Chef::Node:0x80fe04b8 @name=“AJ-Christensens-MacBook-Pro.local”>,
@definitions={}>, @recursive=false, @not_if=nil, @action=:create,
@name="/tmp/foo", @only_if_args={}, @allowed_actions=[:nothing, :create,
:delete], @noop=nil, @ignore_failure=false, @node=<Chef::Node:0x80fe04b8
@name=“AJ-Christensens-MacBook-Pro.local”>, @only_if=nil,
@enclosing_provider=nil, @supports={}, @params={}, @path="/tmp/foo",
@source_line="(irb#1):1:in irb_binding'", @notifies_delayed=[], @provider=nil> chef:recipe > directory "/tmp/foo" do chef:recipe > mode 00700 chef:recipe ?> end => #<Chef::Resource::Directory:0x101f89df8 @mode=448, @not_if_args={}, @cookbook_name=nil, @updated=false, @resource_name=:directory, @notifies_immediate=[], @before=nil, @run_context=#<Chef::RunContext:0x101fbda18 @resource_collection=#<Chef::ResourceCollection:0x101fbd928 @resources_by_name={"directory[/tmp/foo]"=>1}, @resources=[#<Chef::Resource::Directory:0x101f90310 @not_if_args={}, @cookbook_name=nil, @updated=false, @resource_name=:directory, @notifies_immediate=[], @before=nil, @run_context=#<Chef::RunContext:0x101fbda18 ...>, @recursive=false, @not_if=nil, @action=:create, @name="/tmp/foo", @only_if_args={}, @allowed_actions=[:nothing, :create, :delete], @noop=nil, @ignore_failure=false, @node=<Chef::Node:0x80fe04b8 @name="AJ-Christensens-MacBook-Pro.local">, @only_if=nil, @enclosing_provider=nil, @supports={}, @params={}, @path="/tmp/foo", @source_line="(irb#1):1:inirb_binding’", @notifies_delayed=[],
@provider=nil>, #<Chef::Resource::Directory:0x101f89df8 …>],
@insert_after_idx=nil>, @cookbook_collection={},
@node=<Chef::Node:0x80fe04b8 @name=“AJ-Christensens-MacBook-Pro.local”>,
@definitions={}>, @recursive=false, @not_if=nil, @action=:create,
@name="/tmp/foo", @only_if_args={}, @allowed_actions=[:nothing, :create,
:delete], @noop=nil, @ignore_failure=false, @node=<Chef::Node:0x80fe04b8
@name=“AJ-Christensens-MacBook-Pro.local”>, @only_if=nil,
@enclosing_provider=nil, @supports={}, @params={}, @path="/tmp/foo",
@source_line="(irb#1):2:in irb_binding'", @notifies_delayed=[], @provider=nil> chef:recipe > run_chef [Thu, 12 Aug 2010 09:19:08 +1200] DEBUG: Processing directory[/tmp/foo] on AJ-Christensens-MacBook-Pro.local [Thu, 12 Aug 2010 09:19:08 +1200] DEBUG: directory[/tmp/foo] using Chef::Provider::Directory [Thu, 12 Aug 2010 09:19:08 +1200] INFO: Creating directory[/tmp/foo] at /tmp/foo [Thu, 12 Aug 2010 09:19:08 +1200] DEBUG: Processing directory[/tmp/foo] on AJ-Christensens-MacBook-Pro.local [Thu, 12 Aug 2010 09:19:08 +1200] DEBUG: directory[/tmp/foo] using Chef::Provider::Directory [Thu, 12 Aug 2010 09:19:08 +1200] INFO: Setting mode to 700 for directory[/tmp/foo] => true chef:recipe >ls -la /tmp/foo`
=> “total 0\ndrwx------ 2 aj wheel 68 12 Aug 09:19 .\ndrwxrwxrwt 14
root wheel 476 12 Aug 09:19 …\n”

Works for me :slight_smile:

On 12 August 2010 09:10, Mark J. Reed markjreed@gmail.com wrote:

Oh, and I saw this on
http://wiki.opscode.com/display/chef/Resources#Resources-Directory:

A note about mode: When specifying the mode, the value can be a quoted
string, eg “644”. For a >numeric value (i.e., without quotes), it should be
5 digits, e.g., 00644 to ensure that Ruby can parse it >correctly. For more
detail, see Ticket CHEF-174.

But neither the quotes nor the leading zero helped.

On Wed, Aug 11, 2010 at 5:05 PM, Mark J. Reed markjreed@gmail.com wrote:

OK, this is bombing on me:

directory “/foo/bar” do
owner "username’
group "groupname"
mode 0700
end

I’ve tried all of

mode "0700"
mode 0700
mode 700
mode “700”

And I always get this:

ERROR: directory[/foo/bar]
(/var/chef/cache/cookbooks/mycookbook/recipes/foo.rb:21:in
`from_file’) had an error:
Option mode’s value 44 does not match regular expression /^\d{3,4}$/

So it looks like something’s converting to decimal (0700 octal = 448
decimal), stripping off the 8 because it’s not a legal octal digit,
and then complaining about the invalid mode. Any help here?

This is chef 0.9.8.


Mark J. Reed markjreed@gmail.com


Mark J. Reed markjreed@gmail.com


#4

Hm. It’s working on some hosts but not in others; I will have to
track it down. They’re all Ubuntu 10.04 32-bit running 0.9.8, so I’m
a bit perplexed.

Thanks for trying to reproduce it.

On Wed, Aug 11, 2010 at 5:19 PM, AJ Christensen aj@junglist.gen.nz wrote:

On chef 0.9.8, using shef -s (standalone), I tested this quite briefly:
Ohai2u aj@AJ-Christensens-MacBook-Pro.local!
chef > recipe
chef:recipe > directory “/tmp/foo”
=> #<Chef::Resource::Directory:0x101f90310 @not_if_args={},
@cookbook_name=nil, @updated=false, @resource_name=:directory,
@notifies_immediate=[], @before=nil,
@run_context=#<Chef::RunContext:0x101fbda18
@resource_collection=#<Chef::ResourceCollection:0x101fbd928
@resources_by_name={“directory[/tmp/foo]”=>0},
@resources=[#<Chef::Resource::Directory:0x101f90310 …>],
@insert_after_idx=nil>, @cookbook_collection={},
@node=<Chef::Node:0x80fe04b8 @name=“AJ-Christensens-MacBook-Pro.local”>,
@definitions={}>, @recursive=false, @not_if=nil, @action=:create,
@name="/tmp/foo", @only_if_args={}, @allowed_actions=[:nothing, :create,
:delete], @noop=nil, @ignore_failure=false, @node=<Chef::Node:0x80fe04b8
@name=“AJ-Christensens-MacBook-Pro.local”>, @only_if=nil,
@enclosing_provider=nil, @supports={}, @params={}, @path="/tmp/foo",
@source_line="(irb#1):1:in irb_binding'", @notifies_delayed=[], @provider=nil> chef:recipe > directory "/tmp/foo" do chef:recipe > mode 00700 chef:recipe ?> end => #<Chef::Resource::Directory:0x101f89df8 @mode=448, @not_if_args={}, @cookbook_name=nil, @updated=false, @resource_name=:directory, @notifies_immediate=[], @before=nil, @run_context=#<Chef::RunContext:0x101fbda18 @resource_collection=#<Chef::ResourceCollection:0x101fbd928 @resources_by_name={"directory[/tmp/foo]"=>1}, @resources=[#<Chef::Resource::Directory:0x101f90310 @not_if_args={}, @cookbook_name=nil, @updated=false, @resource_name=:directory, @notifies_immediate=[], @before=nil, @run_context=#<Chef::RunContext:0x101fbda18 ...>, @recursive=false, @not_if=nil, @action=:create, @name="/tmp/foo", @only_if_args={}, @allowed_actions=[:nothing, :create, :delete], @noop=nil, @ignore_failure=false, @node=<Chef::Node:0x80fe04b8 @name="AJ-Christensens-MacBook-Pro.local">, @only_if=nil, @enclosing_provider=nil, @supports={}, @params={}, @path="/tmp/foo", @source_line="(irb#1):1:inirb_binding’", @notifies_delayed=[],
@provider=nil>, #<Chef::Resource::Directory:0x101f89df8 …>],
@insert_after_idx=nil>, @cookbook_collection={},
@node=<Chef::Node:0x80fe04b8 @name=“AJ-Christensens-MacBook-Pro.local”>,
@definitions={}>, @recursive=false, @not_if=nil, @action=:create,
@name="/tmp/foo", @only_if_args={}, @allowed_actions=[:nothing, :create,
:delete], @noop=nil, @ignore_failure=false, @node=<Chef::Node:0x80fe04b8
@name=“AJ-Christensens-MacBook-Pro.local”>, @only_if=nil,
@enclosing_provider=nil, @supports={}, @params={}, @path="/tmp/foo",
@source_line="(irb#1):2:in irb_binding'", @notifies_delayed=[], @provider=nil> chef:recipe > run_chef [Thu, 12 Aug 2010 09:19:08 +1200] DEBUG: Processing directory[/tmp/foo] on AJ-Christensens-MacBook-Pro.local [Thu, 12 Aug 2010 09:19:08 +1200] DEBUG: directory[/tmp/foo] using Chef::Provider::Directory [Thu, 12 Aug 2010 09:19:08 +1200] INFO: Creating directory[/tmp/foo] at /tmp/foo [Thu, 12 Aug 2010 09:19:08 +1200] DEBUG: Processing directory[/tmp/foo] on AJ-Christensens-MacBook-Pro.local [Thu, 12 Aug 2010 09:19:08 +1200] DEBUG: directory[/tmp/foo] using Chef::Provider::Directory [Thu, 12 Aug 2010 09:19:08 +1200] INFO: Setting mode to 700 for directory[/tmp/foo] => true chef:recipe >ls -la /tmp/foo`
=> "total 0\ndrwx------ 2 aj wheel 68 12 Aug 09:19 .\ndrwxrwxrwt 14
root wheel 476 12 Aug 09:19 …\n"
Works for me :slight_smile:
On 12 August 2010 09:10, Mark J. Reed markjreed@gmail.com wrote:

Oh, and I saw this on
http://wiki.opscode.com/display/chef/Resources#Resources-Directory:

A note about mode: When specifying the mode, the value can be a quoted
string, eg “644”. For a >numeric value (i.e., without quotes), it should be
5 digits, e.g., 00644 to ensure that Ruby can parse it >correctly. For more
detail, see Ticket CHEF-174.

But neither the quotes nor the leading zero helped.

On Wed, Aug 11, 2010 at 5:05 PM, Mark J. Reed markjreed@gmail.com wrote:

OK, this is bombing on me:

directory “/foo/bar” do
owner "username’
group "groupname"
mode 0700
end

I’ve tried all of

mode "0700"
mode 0700
mode 700
mode “700”

And I always get this:

ERROR: directory[/foo/bar]
(/var/chef/cache/cookbooks/mycookbook/recipes/foo.rb:21:in
`from_file’) had an error:
Option mode’s value 44 does not match regular expression /^\d{3,4}$/

So it looks like something’s converting to decimal (0700 octal = 448
decimal), stripping off the 8 because it’s not a legal octal digit,
and then complaining about the invalid mode. Any help here?

This is chef 0.9.8.


Mark J. Reed markjreed@gmail.com


Mark J. Reed markjreed@gmail.com


Mark J. Reed markjreed@gmail.com


#5

There are cucumber BDD features for the code, too. I recall Chris Brown
(skeptomai) writing them.

On 12 August 2010 10:40, Mark J. Reed markjreed@gmail.com wrote:

Hm. It’s working on some hosts but not in others; I will have to
track it down. They’re all Ubuntu 10.04 32-bit running 0.9.8, so I’m
a bit perplexed.

Thanks for trying to reproduce it.

On Wed, Aug 11, 2010 at 5:19 PM, AJ Christensen aj@junglist.gen.nz
wrote:

On chef 0.9.8, using shef -s (standalone), I tested this quite briefly:
Ohai2u aj@AJ-Christensens-MacBook-Pro.local!
chef > recipe
chef:recipe > directory “/tmp/foo”
=> #<Chef::Resource::Directory:0x101f90310 @not_if_args={},
@cookbook_name=nil, @updated=false, @resource_name=:directory,
@notifies_immediate=[], @before=nil,
@run_context=#<Chef::RunContext:0x101fbda18
@resource_collection=#<Chef::ResourceCollection:0x101fbd928
@resources_by_name={“directory[/tmp/foo]”=>0},
@resources=[#<Chef::Resource::Directory:0x101f90310 …>],
@insert_after_idx=nil>, @cookbook_collection={},
@node=<Chef::Node:0x80fe04b8 @name=“AJ-Christensens-MacBook-Pro.local”>,
@definitions={}>, @recursive=false, @not_if=nil, @action=:create,
@name="/tmp/foo", @only_if_args={}, @allowed_actions=[:nothing, :create,
:delete], @noop=nil, @ignore_failure=false, @node=<Chef::Node:0x80fe04b8
@name=“AJ-Christensens-MacBook-Pro.local”>, @only_if=nil,
@enclosing_provider=nil, @supports={}, @params={}, @path="/tmp/foo",
@source_line="(irb#1):1:in irb_binding'", @notifies_delayed=[], @provider=nil> chef:recipe > directory "/tmp/foo" do chef:recipe > mode 00700 chef:recipe ?> end => #<Chef::Resource::Directory:0x101f89df8 @mode=448, @not_if_args={}, @cookbook_name=nil, @updated=false, @resource_name=:directory, @notifies_immediate=[], @before=nil, @run_context=#<Chef::RunContext:0x101fbda18 @resource_collection=#<Chef::ResourceCollection:0x101fbd928 @resources_by_name={"directory[/tmp/foo]"=>1}, @resources=[#<Chef::Resource::Directory:0x101f90310 @not_if_args={}, @cookbook_name=nil, @updated=false, @resource_name=:directory, @notifies_immediate=[], @before=nil, @run_context=#<Chef::RunContext:0x101fbda18 ...>, @recursive=false, @not_if=nil, @action=:create, @name="/tmp/foo", @only_if_args={}, @allowed_actions=[:nothing, :create, :delete], @noop=nil, @ignore_failure=false, @node=<Chef::Node:0x80fe04b8 @name="AJ-Christensens-MacBook-Pro.local">, @only_if=nil, @enclosing_provider=nil, @supports={}, @params={}, @path="/tmp/foo", @source_line="(irb#1):1:inirb_binding’", @notifies_delayed=[],
@provider=nil>, #<Chef::Resource::Directory:0x101f89df8 …>],
@insert_after_idx=nil>, @cookbook_collection={},
@node=<Chef::Node:0x80fe04b8 @name=“AJ-Christensens-MacBook-Pro.local”>,
@definitions={}>, @recursive=false, @not_if=nil, @action=:create,
@name="/tmp/foo", @only_if_args={}, @allowed_actions=[:nothing, :create,
:delete], @noop=nil, @ignore_failure=false, @node=<Chef::Node:0x80fe04b8
@name=“AJ-Christensens-MacBook-Pro.local”>, @only_if=nil,
@enclosing_provider=nil, @supports={}, @params={}, @path="/tmp/foo",
@source_line="(irb#1):2:in irb_binding'", @notifies_delayed=[], @provider=nil> chef:recipe > run_chef [Thu, 12 Aug 2010 09:19:08 +1200] DEBUG: Processing directory[/tmp/foo] on AJ-Christensens-MacBook-Pro.local [Thu, 12 Aug 2010 09:19:08 +1200] DEBUG: directory[/tmp/foo] using Chef::Provider::Directory [Thu, 12 Aug 2010 09:19:08 +1200] INFO: Creating directory[/tmp/foo] at /tmp/foo [Thu, 12 Aug 2010 09:19:08 +1200] DEBUG: Processing directory[/tmp/foo] on AJ-Christensens-MacBook-Pro.local [Thu, 12 Aug 2010 09:19:08 +1200] DEBUG: directory[/tmp/foo] using Chef::Provider::Directory [Thu, 12 Aug 2010 09:19:08 +1200] INFO: Setting mode to 700 for directory[/tmp/foo] => true chef:recipe >ls -la /tmp/foo`
=> "total 0\ndrwx------ 2 aj wheel 68 12 Aug 09:19 .\ndrwxrwxrwt
14
root wheel 476 12 Aug 09:19 …\n"
Works for me :slight_smile:
On 12 August 2010 09:10, Mark J. Reed markjreed@gmail.com wrote:

Oh, and I saw this on
http://wiki.opscode.com/display/chef/Resources#Resources-Directory:

A note about mode: When specifying the mode, the value can be a quoted
string, eg “644”. For a >numeric value (i.e., without quotes), it
should be

5 digits, e.g., 00644 to ensure that Ruby can parse it >correctly. For
more

detail, see Ticket CHEF-174.

But neither the quotes nor the leading zero helped.

On Wed, Aug 11, 2010 at 5:05 PM, Mark J. Reed markjreed@gmail.com
wrote:

OK, this is bombing on me:

directory “/foo/bar” do
owner "username’
group "groupname"
mode 0700
end

I’ve tried all of

mode "0700"
mode 0700
mode 700
mode “700”

And I always get this:

ERROR: directory[/foo/bar]
(/var/chef/cache/cookbooks/mycookbook/recipes/foo.rb:21:in
`from_file’) had an error:
Option mode’s value 44 does not match regular expression /^\d{3,4}$/

So it looks like something’s converting to decimal (0700 octal = 448
decimal), stripping off the 8 because it’s not a legal octal digit,
and then complaining about the invalid mode. Any help here?

This is chef 0.9.8.


Mark J. Reed markjreed@gmail.com


Mark J. Reed markjreed@gmail.com


Mark J. Reed markjreed@gmail.com


#6

On Wed, Aug 11, 2010 at 9:05 PM, Mark J. Reed markjreed@gmail.com wrote:

OK, this is bombing on me:

directory “/foo/bar” do
owner "username’
group "groupname"
mode 0700
end

In the case that you’re copying and pasting this, I’ll note that you
have mismatched quotes around username.

Bryan


#7

Ah, thanks, but it’s correct in my actual recipe. That was an
artifact of the “name changed to protect the innocent” after the
copy and paste. :slight_smile: Thanks, though.

On Wed, Aug 11, 2010 at 6:55 PM, Bryan McLellan btm@loftninjas.org wrote:

On Wed, Aug 11, 2010 at 9:05 PM, Mark J. Reed markjreed@gmail.com wrote:

OK, this is bombing on me:

directory “/foo/bar” do
owner "username’
group "groupname"
mode 0700
end

In the case that you’re copying and pasting this, I’ll note that you
have mismatched quotes around username.

Bryan


Mark J. Reed markjreed@gmail.com


#8

It seems to break on systems that previously had chef 0.8.16 and then
upgraded to 0.9.8. Systems with a clean install of 0.9.8 work. I’ve
tried deleting everything I could find related to the 0.8.16 install
but still having the issue, so will probably just start over with a
different image. (The joys of working in AWS).

Thanks.

On Wed, Aug 11, 2010 at 7:02 PM, Mark J. Reed markjreed@gmail.com wrote:

Ah, thanks, but it’s correct in my actual recipe. That was an
artifact of the “name changed to protect the innocent” after the
copy and paste. :slight_smile: Thanks, though.

On Wed, Aug 11, 2010 at 6:55 PM, Bryan McLellan btm@loftninjas.org wrote:

On Wed, Aug 11, 2010 at 9:05 PM, Mark J. Reed markjreed@gmail.com wrote:

OK, this is bombing on me:

directory “/foo/bar” do
owner "username’
group "groupname"
mode 0700
end

In the case that you’re copying and pasting this, I’ll note that you
have mismatched quotes around username.

Bryan


Mark J. Reed markjreed@gmail.com


Mark J. Reed markjreed@gmail.com


#9

On Wed, Aug 11, 2010 at 11:04 PM, Mark J. Reed markjreed@gmail.com wrote:

It seems to break on systems that previously had chef 0.8.16 and then
upgraded to 0.9.8. Systems with a clean install of 0.9.8 work. I’ve
tried deleting everything I could find related to the 0.8.16 install
but still having the issue, so will probably just start over with a
different image. (The joys of working in AWS).

sudo gem cleanup ?

Yeah, building from scratch is all sorts of win. Thank you automation gods.

Bryan