Skip to content

Instantly share code, notes, and snippets.

@elvisciotti
Last active August 29, 2015 14:09
Show Gist options
  • Save elvisciotti/8dacf247312190c64287 to your computer and use it in GitHub Desktop.
Save elvisciotti/8dacf247312190c64287 to your computer and use it in GitHub Desktop.
Puppet task to add a line into a file if not existing and not commented out (prefixed with "#")
# add STRING-XXXXXXX to FILE-YYYYYY
# if commented out, it gets re-added
exec { "[task name]":
command => '/bin/echo "STRING-XXXXXXX" >> FILE-YYYYYY',
unless => '/bin/grep -E "^STRING-XXXXXXX$" FILE-YYYYYY'
}
@elvisciotti
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment