meallhour
meallhour

Reputation: 15571

What is the best way to update profile using chef resource

I am trying to update the profile using the following chef resource

bash 'env_var' do
  code <<-EOH
    echo export APP_ADDR="http://#{node['ipaddress']}:8443" >> /etc/profile
  EOH
  not_if "grep -q APP_ADDR=http://#{node['ipaddress']}:8443 /etc/profile"
end

I want to ask if there is a better way to do the same thing.

Upvotes: 0

Views: 352

Answers (1)

coderanger
coderanger

Reputation: 54181

Most Linux distros support an /etc/profile.d/ folder where you can create individual file snippets rather than updating a file in-place. If you do need to update the file in-place, check out the line cookbook as it has resources like this but with more fine-grained control.

Upvotes: 0

Related Questions