Ask Your Question
0

cannot change value in augeas

asked 2015-01-08 08:20:51 -0500

Chutki gravatar image

Hi,

As I already mentioned in previous post, I am quite new to augeas.

I have done few sample test, but I am getting error. None of the manifests got compiled.

below is my first code

class testfile {
augeas { "testfile":
    context => "/files/tmp/testfile",
    changes =>  "set aaaaaa ccccc",
 }
}
include testfile

When I compiled code got below error

Debug: Augeas[testfile](provider=augeas): /augeas/files/etc/logrotate.d/scx.logrotate/error = parse_failed
Debug: Augeas[testfile](provider=augeas): /augeas/files/etc/logrotate.d/scx.logrotate/error/pos = 0
Debug: Augeas[testfile](provider=augeas): /augeas/files/etc/logrotate.d/scx.logrotate/error/line = 1
Debug: Augeas[testfile](provider=augeas): /augeas/files/etc/logrotate.d/scx.logrotate/error/char = 0
Debug: Augeas[testfile](provider=augeas): /augeas/files/etc/logrotate.d/scx.logrotate/error/lens = /opt/puppet/share/augeas/lenses/dist/logrotate.aug:117.13-.56:
Debug: Augeas[testfile](provider=augeas): /augeas/files/etc/logrotate.d/scx.logrotate/error/message = Iterated lens matched less than it should
Debug: Augeas[testfile](provider=augeas): Will attempt to save and only run if files changed
Debug: Augeas[testfile](provider=augeas): sending command 'set' with params ["/files/tmp/testfile/aaaaaa", "ccccc"]

below is my test file

testfile
rrffd
sdsf
bbbbbb
aaaaa

after I compiled code want to change "aaaaaa" to "ccccc"

testfile
rrffd
sdsf
bbbbbb
ccccc

==========================================================================

below is second sample code

class testfile {
augeas { "testfile":
    #context => "/files/tmp/testfile",
    changes =>  "set /files/tmp/testfile/test/01 test4"
 }
}
include testfile

getting below error

Debug: Augeas[testfile](provider=augeas): /augeas/files/etc/ld.so.conf.d/kernel-2.6.32-431.17.1.el6.x86_64.conf/error/message = Iterated lens matched less than it should
Debug: Augeas[testfile](provider=augeas): /augeas/files/etc/logrotate.d/scx.logrotate/error = parse_failed
Debug: Augeas[testfile](provider=augeas): /augeas/files/etc/logrotate.d/scx.logrotate/error/pos = 0
Debug: Augeas[testfile](provider=augeas): /augeas/files/etc/logrotate.d/scx.logrotate/error/line = 1
Debug: Augeas[testfile](provider=augeas): /augeas/files/etc/logrotate.d/scx.logrotate/error/char = 0
Debug: Augeas[testfile](provider=augeas): /augeas/files/etc/logrotate.d/scx.logrotate/error/lens = /opt/puppet/share/augeas/lenses/dist/logrotate.aug:117.13-.56:
Debug: Augeas[testfile](provider=augeas): /augeas/files/etc/logrotate.d/scx.logrotate/error/message = Iterated lens matched less than it should
Debug: Augeas[testfile](provider=augeas): Will attempt to save and only run if files changed
Debug: Augeas[testfile](provider=augeas): sending command 'set' with params ["/files/tmp/testfile/test/01", "test4"]
Debug: Augeas[testfile](provider=augeas): Skipping because no files were changed
Debug: Augeas[testfile](provider=augeas): Closed the augeas connection
Debug: Finishing transaction 23894500
Debug: Storing state
Debug: Stored state in 0.09 seconds
Notice: Finished catalog run in 1.44 seconds

below is test file,want to change "test test1" to "test test4"

test test1
test test2
test test3

after compilation need to change like below

test test4
test test2
test test3

what my understanding from the above code is "/files/tmp/testfile/test/01" it will go and set label ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-01-08 09:02:35 -0500

domcleal gravatar image

/tmp/testfile is not a file that Augeas parses by default, you need to configure the resource appropriately.

If you just want numbered, line parsing then you should use the Simplelines.lns (source: Puppet docs: Loading generic lenses for non-standard files), e.g.

augeas { "testfile":
  lens    => 'Simplelines.lns',
  incl    => '/tmp/testfile',
  changes => 'set 01 "test test4"'
}

(context is implicit when using incl)

If you want more specific, intelligent parsing of the file, you'll have to provide more information about precisely what file format you intend to parse and edit.

edit flag offensive delete link more

Comments

Thanks. It got worked

Chutki gravatar imageChutki ( 2015-01-09 08:18:39 -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: 2015-01-08 08:20:51 -0500

Seen: 242 times

Last updated: Jan 08 '15