john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

Chef modify an existing file

chef best practice recommends to always replace the whole file, unfortunately this isn't always practical

bash "some_commands" do
    user "root"
    cwd "/tmp"
    code <<-EOT
       echo "alias rm='rm -i'" >> /root/.bashrc
    EOT
end

cookbook_file "/root/.pip/pip.conf" do
  source "pip.conf"
  mode 0755
  owner "root"
  group "root"
end



 bash "append_to_config" do
   user "root"
   code <<-EOF
      cat /tmp/parms_to_append.conf >> /etc/config
      rm /tmp/parms_to_append.conf
   EOF
   not_if "grep -q MY_IDENTIFIER /etc/config"
 end

  • « twisted socket bind REUSEADDR shutdown
  • Swap partition sizes boot root usr home var tmp »

Published

Sep 20, 2013

Category

chef

~64 words

Tags

  • chef 15
  • file 92
  • modify 1