Libert Libert - 4 months ago 30
Ruby Question

Chef - Change files group recursively

I have the following structure:

/opt/conf/files.txt

What I'm trying to achieve is:

sudo chgrp -R tomcat conf


Change all the files in the 'conf' directory to the group 'tomcat'

I tried this:

directory "/opt/conf" do
group 'tomcat'
mode '0070'
recursive true
end


but it just change the group to tomcat but not the files inside the conf directory.

How can achieve to change all the content of the conf directory using recipes?

Answer

That is not something the directory resource supports. You'll have to use chown or chgrp in an execute resource. There is a good reason for this, I promise, but it's a long and winding tale of convergent ontologies.