Skip to content

Instantly share code, notes, and snippets.

@clarkdave
Created June 13, 2013 11:12
Show Gist options
  • Save clarkdave/5772940 to your computer and use it in GitHub Desktop.
Save clarkdave/5772940 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