meallhour
meallhour

Reputation: 15581

What is the best way to do "chmod +x" within Chef

I am trying to run chmod +x /usr/local/bin/binaryname within chef.
I have used execute resourcefor that as shown below:

execute "run_binary" do
  command "chmod +x binaryname"
  cwd "/usr/local/bin"
  not_if "stat --format=%a /usr/local/bin/binaryname" | grep 755
end

Please let me know if there is a better way

Upvotes: 3

Views: 3616

Answers (1)

coderanger
coderanger

Reputation: 54211

You can use a file resource:

file '/usr/local/bin/binaryname' do
  mode '755'
end

If you don't specify an owner/group/content then Chef doesn't manage those properties.

Upvotes: 6

Related Questions