Quantcast
Channel: Ask Puppet: Puppet DevOps Q&A Community - RSS feed
Viewing all articles
Browse latest Browse all 6104

How to resolve "more than one line match patterns" problem using file_line?

$
0
0
Hi I'm trying to change configuration file using puppet. This is my test.txt file that i want to change : [default] #puppet=no abc=123 [nova] #puppet=no I want to change "#puppet=no" to "puppet=yes" **only on [default] tab.** This is my test.pp for two version : file_line{"someline": path => '/root/openstack-puppet/computenode/nova/test.txt', match => '[default]\n#puppet', line => 'puppet=ok' } This one failed to find match pattern, so it just add "puppet=ok" at the end of file. file_line{"someline": path => '/root/openstack-puppet/computenode/nova/test.txt', match => '#puppet', line => 'puppet=ok' } This one failed because of multi match pattern problem. I tried Augeas also, but I can't find how to uncomment using Augeas. Someone please help me with this problem!! ================================================================= I tried in 'match' attribute like this : match => '\[default\]\n#puppet' match => '\[default\]\\n#puppet' match => '\[default\]\\\\n#puppet' All of this cannot find match pattern, so it just add 'puppet=ok' at the end of the file/ Then, I tried 'affter' attribute I run this code : file_line { 'someline': path => '/root/openstack-puppet/computenode/nova/test.txt', after => '\[default\]', multiple => 'false', match => '#puppet', line => 'puppet=ok', } But when I run with "puppet apply" it still makes multi match error : Error: More than one line in file '/root/openstack-puppet/computenode/nova/test.txt' matches pattern '#puppet' Error: /Stage[main]/Main/File_line[someline]/ensure: change from absent to present failed: More than one line in file '/root/openstack-puppet/computenode/nova/test.txt' matches pattern '#puppet' **I think that 'after' attribute cannot applied when 'match' attribute is defined.** When I erase 'match' attribute, it works, but it didn't replace original string('#puppet=no'). It just added new line after [default] like this : [default] puppet=ok #puppet=no abc=123 dedd=0 [nova] #puppet=no **So the issues still remain, how can I erase(or replace) the string '#puppet=no' only on [default] tab??**

Viewing all articles
Browse latest Browse all 6104

Trending Articles