2017-10-04 102 views
0

我嘗試使用木偶,但我的經驗如此之低。我需要你的幫助;)Puppet | XML編輯解決方案

我想編輯XML文件(LibreOffice的設置)

... 
<item oor:path="/org.openoffice.Office.Paths/Paths/org.openoffice.Office.Paths:NamedPath['Template']"><prop oor:name="UserPaths" oor:op="fuse"><value></value></prop></item> 
... 

我需要添加1,2用戶路徑(,裏面)。最終的XML應該是這樣的

... 
<item oor:path="/org.openoffice.Office.Paths/Paths/org.openoffice.Office.Paths:NamedPath['Template']"><prop oor:name="UserPaths" oor:op="fuse"><value><it>file:///path/to/dir1/</it><it>file:///path/to/dir2/</it></value></prop></item> 
... 

我可以如何使它與木偶?

回答

0

您可以使用stdlib函數file_line替換有問題的行。

該函數可以用你想要的數據換行到你的xml文件中。

例子:

file_line { 'Change file xml file line': 
ensure => present, 
path => '/xml/file/path', 
line => '<item oor:path="/org.openoffice.Office.Paths/Paths/org.openoffice.Office.Paths:NamedPath['Template']"><prop oor:name="UserPaths" oor:op="fuse"><value><it>file:///path/to/dir1/</it><it>file:///path/to/dir2/</it></value></prop></item>', 
match => '<item oor:path=', 
} 

請檢查有關file_line功能

https://github.com/puppetlabs/puppetlabs-stdlib

更多信息