Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thetemplateblog/177cfe9b22bfe478a3c892ab31af5590 to your computer and use it in GitHub Desktop.
Save thetemplateblog/177cfe9b22bfe478a3c892ab31af5590 to your computer and use it in GitHub Desktop.
[CHEF] Insert a line in a file if it doesn't already exist
line = '127.0.0.1 gateway.internal gateway'
file = Chef::Util::FileEdit.new('/etc/hosts')
file.insert_line_if_no_match(/#{line}/, line)
file.write_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment