# Chef mount not working with directory

**URL:** <https://discourse.chef.io/t/chef-mount-not-working-with-directory/5375>\
**Category:** Chef Infra (archive)\
**Created:** [May 7, 2014, 3:09pm UTC](https://discourse.chef.io/t/chef-mount-not-working-with-directory/5375 "2014-05-07T15:09:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_Frostl](https://avatars.discourse-cdn.com/v4/letter/c/71c47a/32.png) [@Christian\_Frostl](https://discourse.chef.io/u/Christian_Frostl)\
**Post date:** [May 7, 2014, 3:09pm UTC](https://discourse.chef.io/t/chef-mount-not-working-with-directory/5375/1 "2014-05-07T15:09:53Z")

</div>

HI there,

I have q question regarding the resource type „mount“.  
If I first create a directory resource and afterwards uses the resource  
mount to mount a remote file system on the previous created directory it  
works only for the first chef-client run.  
After the mount of the remote filesystem, the resource directory will fail  
during the next chef-client run.

Following code:

directory “#{tomcat\_bag[‘webserver’][‘mountpoint\_fs\_install’]}” do  
’tomcatusr1’  
group 'tomcatusr1’  
mode 0755  
action :create  
end

mount tomcat\_bag[servertype][‘mountpoint\_fs\_install’] do  
device tomcat\_bag[servertype][‘mountsource\_fs\_install’]  
fstype "nfs"  
options "rw"  
action [:mount, :enable]  
End

Log:  
First run:

- directory[/apps/install] action create (up to date)
- mount[/apps/install] action mount
  - mount [fil0001.stag.nubon.com](http://fil0001.stag.nubon.com):/install to /apps/install

- mount[/apps/install] action enable (up to date)

Second run:

- directory[/apps/install] action create  
===========================================================================  
=====  
Error executing action `create` on resource ‘directory[/apps/install]’  
===========================================================================  
=====

## Errno::EINVAL

Invalid argument - /apps/install

## Resource Declaration:

# In /var/chef/cache/cookbooks/tomcat/recipes/webserver.rb

27: directory “#{tomcat\_bag[‘webserver’][‘mountpoint\_fs\_install’]}” do  
28: owner 'tomcatusr1’  
29: group 'tomcatusr1’  
30: mode 0755  
31: action :create  
32: end  
33:

## Compiled Resource:

# Declared in /var/chef/cache/cookbooks/tomcat/recipes/webserver.rb:27:in

`from\_file’

directory("/apps/install") do  
provider Chef::Provider::Directory  
action [:create]  
retries 0  
retry\_delay 2  
guard\_interpreter :default  
path "/apps/install"  
owner "tomcatusr1"  
group "tomcatusr1"  
mode 493  
cookbook\_name "tomcat"  
recipe\_name "webserver"  
end

Does anybody of you have an idea, how I can fix this problem?

Thanks,  
Christian

---

<div class="post-metadata">

**Author:** ![jdunn](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jdunn/32/1800_2.png) [@jdunn](https://discourse.chef.io/u/jdunn)\
**Post date:** [May 9, 2014, 3:50am UTC](https://discourse.chef.io/t/chef-mount-not-working-with-directory/5375/2 "2014-05-09T03:50:41Z")

</div>

What operating system and Chef client version? It works ok for me here:

$ mount|grep amholding  
/dev/mapper/vg00-lv05 on /amholding type ext4  
(rw,nosuid,nodev,relatime,seclabel,data=ordered)  
$ sudo chef-apply -s  
[sudo] password for jdunn:  
directory '/amholding' do  
owner 'amandabackup'  
group 'tape'  
mode 0700  
action :create  
end  
Recipe: (chef-apply cookbook)::(chef-apply recipe)

- directory[/amholding] action create (up to date)

- Julian

On Wed, May 7, 2014 at 11:09 AM, Christian Fröstl  
[christian.froestl@nubon.com](mailto:christian.froestl@nubon.com) wrote:

> HI there,
> 
> I have q question regarding the resource type „mount“.  
> If I first create a directory resource and afterwards uses the resource  
> mount to mount a remote file system on the previous created directory it  
> works only for the first chef-client run.  
> After the mount of the remote filesystem, the resource directory will fail  
> during the next chef-client run.
> 
> Following code:
> 
> directory "#{tomcat\_bag['webserver']['mountpoint\_fs\_install']}" do  
> 'tomcatusr1'  
> group 'tomcatusr1'  
> mode 0755  
> action :create  
> end
> 
> mount tomcat\_bag[servertype]['mountpoint\_fs\_install'] do  
> device tomcat\_bag[servertype]['mountsource\_fs\_install']  
> fstype "nfs"  
> options "rw"  
> action [:mount, :enable]  
> End
> 
> Log:  
> First run:
> 
> - directory[/apps/install] action create (up to date)
> - mount[/apps/install] action mount
> - mount [fil0001.stag.nubon.com](http://fil0001.stag.nubon.com):/install to /apps/install
> 
> - mount[/apps/install] action enable (up to date)
> 
> Second run:
> 
> - directory[/apps/install] action create  
> ===========================================================================  
> =====  
> Error executing action `create` on resource 'directory[/apps/install]'  
> ===========================================================================  
> =====
> 
> ## Errno::EINVAL
> 
> Invalid argument - /apps/install
> 
> ## Resource Declaration:
> 
> # In /var/chef/cache/cookbooks/tomcat/recipes/webserver.rb
> 
> 27: directory "#{tomcat\_bag['webserver']['mountpoint\_fs\_install']}" do  
> 28: owner 'tomcatusr1'  
> 29: group 'tomcatusr1'  
> 30: mode 0755  
> 31: action :create  
> 32: end  
> 33:
> 
> ## Compiled Resource:
> 
> # Declared in /var/chef/cache/cookbooks/tomcat/recipes/webserver.rb:27:in
> 
> `from\_file'
> 
> directory("/apps/install") do  
> provider Chef::Provider::Directory  
> action [:create]  
> retries 0  
> retry\_delay 2  
> guard\_interpreter :default  
> path "/apps/install"  
> owner "tomcatusr1"  
> group "tomcatusr1"  
> mode 493  
> cookbook\_name "tomcat"  
> recipe\_name "webserver"  
> end
> 
> Does anybody of you have an idea, how I can fix this problem?
> 
> Thanks,  
> Christian

--  
[Julian C. Dunn [jdunn@aquezada.com](mailto:jdunn@aquezada.com) \* Sorry, I'm ]  
[WWW: [Julian Dunn's Blog - Commentary on media, technology, and everything in between.](http://www.aquezada.com/staff/julian) \* only Web 1.0 ]  
[gopher://sdf.org/1/users/keymaker/ \* compliant!]  
[PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9]

---

<div class="post-metadata">

**Author:** ![YAMANO\_Yuji](https://avatars.discourse-cdn.com/v4/letter/y/ecc23a/32.png) [@YAMANO\_Yuji](https://discourse.chef.io/u/YAMANO_Yuji)\
**Post date:** [May 9, 2014, 7:49am UTC](https://discourse.chef.io/t/chef-mount-not-working-with-directory/5375/3 "2014-05-09T07:49:36Z")

</div>

It might be a chwon/chgrp issue on NFS mounts.

At the first run, the directory resource created the local directory /apps/install,  
then chwoned and chgrped it. When the second run, [fil0001.stag.nubon.com](http://fil0001.stag.nubon.com):/install  
was already mounted on /apps/install, and the resource tried to chown and chgrp it.

> On Wed, May 7, 2014 at 11:09 AM, Christian Fröstl  
> [christian.froestl@nubon.com](mailto:christian.froestl@nubon.com) wrote:

> > Log:  
> > First run:
> > 
> > - directory[/apps/install] action create (up to date)
> > - mount[/apps/install] action mount
> > - mount [fil0001.stag.nubon.com](http://fil0001.stag.nubon.com):/install to /apps/install
> > 
> > - mount[/apps/install] action enable (up to date)
> > 
> > Second run:
> > 
> > - directory[/apps/install] action create  
> > ===========================================================================  
> > =====  
> > Error executing action `create` on resource 'directory[/apps/install]'  
> > ===========================================================================  
> > =====
> > 
> > ## Errno::EINVAL
> > 
> > Invalid argument - /apps/install

--  
YAMANO Yuji  
OGIS-RI

---

<div class="post-metadata">

**Author:** ![Christian\_Frostl](https://avatars.discourse-cdn.com/v4/letter/c/71c47a/32.png) [@Christian\_Frostl](https://discourse.chef.io/u/Christian_Frostl)\
**Post date:** [May 9, 2014, 9:52am UTC](https://discourse.chef.io/t/chef-mount-not-working-with-directory/5375/4 "2014-05-09T09:52:54Z")

</div>

Hi there,

Yes you were right. I fixt the rights for users and groups in nfs and  
afterwards the resource directory problem was fixt, too.

Thanks,  
Christian

Am 09.05.14 09:49 schrieb "YAMANO Yuji" unter [Yamano\_Yuji@ogis-ri.co.jp](mailto:Yamano_Yuji@ogis-ri.co.jp):

> It might be a chwon/chgrp issue on NFS mounts.
> 
> At the first run, the directory resource created the local directory  
> /apps/install,  
> then chwoned and chgrped it. When the second run,  
> [fil0001.stag.nubon.com](http://fil0001.stag.nubon.com):/install  
> was already mounted on /apps/install, and the resource tried to chown and  
> chgrp it.
> 
> > On Wed, May 7, 2014 at 11:09 AM, Christian Fröstl  
> > [christian.froestl@nubon.com](mailto:christian.froestl@nubon.com) wrote:
> 
> > > Log:  
> > > First run:
> > > 
> > > - directory[/apps/install] action create (up to date)
> > > - mount[/apps/install] action mount
> > > - mount [fil0001.stag.nubon.com](http://fil0001.stag.nubon.com):/install to /apps/install
> > > 
> > > - mount[/apps/install] action enable (up to date)
> > > 
> > > Second run:
> > > 
> > > - directory[/apps/install] action create
> > > 
> > > # ========================================================================
> > > 
> > > =====  
> > > Error executing action `create` on resource 'directory[/apps/install]'
> > > 
> > > # ========================================================================
> > > 
> > > =====
> > > 
> > > ## Errno::EINVAL
> > > 
> > > Invalid argument - /apps/install
> 
> --  
> YAMANO Yuji  
> OGIS-RI
