Forked from clarkdave/chef-insert-line-if-no-match.rb
Created
April 21, 2016 16:28
-
-
Save 0x00dec0de/b7ff22f57dae59923e5ddb203ebbb749 to your computer and use it in GitHub Desktop.
[CHEF] Insert a line in a file if it doesn't already exist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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