-1
用木偶來修改listener.ora
文件:正確的方式正則表達式匹配括號中的木偶file_line後第
file_line { 'addFloatingListenerTCPS':
ensure => present,
path => "${LSNR_PATH}/listener.ora",
line => " (ADDRESS = (PROTOCOL = TCPS)(HOST = ${FLOATING_IP})(PORT = 1522))",
after => "^\s+(ADDRESS = (PROTOCOL = TCPS)(HOST = DB)(PORT = 1522))",
require => Class["othernode"]
}
這不會導致任何傀儡錯誤,但會將新條目在年底一路該文件,而不是在它應該在的偵聽器塊內部。 (對我來說,這表示after
屬性值與文件內容不匹配,因此puppet默認爲追加模式)。
改變after
屬性值來逃避所有的括號:
after => "^\s+\(ADDRESS = \(PROTOCOL = TCPS\)\(HOST = DB\)\(PORT = 1522\)\)",
生成在控制檯中出現多個警告:
Warning: Unrecognised escape sequence '\(' in file /etc/puppet/modules/test_conf/manifests/init.pp at line 30
Warning: Unrecognised escape sequence '\(' in file /etc/puppet/modules/test_conf/manifests/init.pp at line 30
Warning: Unrecognised escape sequence '\)' in file /etc/puppet/modules/test_conf/manifests/init.pp at line 30
Warning: Unrecognised escape sequence '\(' in file /etc/puppet/modules/test_conf/manifests/init.pp at line 30
Warning: Unrecognised escape sequence '\)' in file /etc/puppet/modules/test_conf/manifests/init.pp at line 30
Warning: Unrecognised escape sequence '\(' in file /etc/puppet/modules/test_conf/manifests/init.pp at line 30
Warning: Unrecognised escape sequence '\)' in file /etc/puppet/modules/test_conf/manifests/init.pp at line 30
Warning: Unrecognised escape sequence '\)' in file /etc/puppet/modules/test_conf/manifests/init.pp at line 30
使得它在衛星無法使用。但是,執行完成後,新條目位於應該在的塊內。
這就提出了多個問題:
- 在括號解釋爲特殊字符,如果是這樣,爲什麼他們不能逃脫?
- 傀儡stdlib正則表達式處理回參考嗎?
它的工作原理:'「^ \\ S + \\(地址爲\\(PROTOCOL = TCPS \\)\\(HOST = DB \\)\\(PORT = 1522 \\)\\)「' – MohaMad