Ask Your Question

How to manage a file with a dynamic value

asked 2014-01-02 16:07:13 -0600

I have an ini-style file that I'm currently managing with augeas resources, but every time puppet runs, it overwrites a value that the application (that uses the config) writes in.

For example, puppet writes: key1=value1 key2=value2 key3=value3

application overwrites one value: key1=value1 key2=hashOf(value2) key3=value3

edit retag flag offensive close merge delete


Silly question: You do not have the capability to calculate the hash of value2 to put it yourself ? Otherwise you might use the `onlyif` parameter of augeas. Not sure if ...(more)

doc75 gravatar imagedoc75 ( 2014-01-04 02:55:39 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-01-02 19:51:40 -0600

updated 2014-01-03 17:14:17 -0600

Given that you're using Augeas, you have the option of managing some parts of the file and not others, so don't manage the value of key2 if the application is going to change it on you without notice.

If you're looking to have Puppet seed the file with initial values, what I tend to do is use a combination of File and Augeas resources

# Seed the file from a static copy
file { '/etc/my_file.ini':
  ensure  => file,
  source  => 'puppet://modules/foo/bar/baz',
  replace => false,

augeas { 'update my_file.ini':
  context => '/files/etc/my_file.ini',
  changes => [
    'set key1 ...
edit flag offensive delete link more


Is there a way I can get puppet to seed the initial value? And how to ensure that key2 exists?

atayarani gravatar imageatayarani ( 2014-01-03 09:33:00 -0600 )edit

Updated my answer with information on seeding an initial value.

rodjek gravatar imagerodjek ( 2014-01-03 17:14:44 -0600 )edit

This worked perfectly. Thanks.

atayarani gravatar imageatayarani ( 2014-01-08 12:10:02 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-01-02 16:07:13 -0600

Seen: 529 times

Last updated: Jan 03 '14