Ask Your Question
1

How to manage a file with a dynamic value

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

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

Comments

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 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
4

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

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

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 ...
(more)
edit flag offensive delete link more

Comments

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 -0500 )edit

Updated my answer with information on seeding an initial value.

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

This worked perfectly. Thanks.

atayarani gravatar imageatayarani ( 2014-01-08 12:10:02 -0500 )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

Stats

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

Seen: 406 times

Last updated: Jan 03 '14