database/sql: use augeas instead of file_line

It appears sometimes some encoding issues. Also, using augeas is the
cleanest way to modify a file for this use.
This patch use augeas for /etc/services & mysqlchk service on 9200/tcp.
This commit is contained in:
Emilien Macchi 2014-08-11 16:47:09 +02:00
parent d11642ea0b
commit d2d8c911bd
2 changed files with 10 additions and 12 deletions

View File

@ -284,13 +284,17 @@ class cloud::database::sql (
package_name => $mysql_client_package_name,
}
# Haproxy http monitoring
file_line { 'mysqlchk-in-etc-services':
path => '/etc/services',
line => 'mysqlchk 9200/tcp',
match => '^mysqlchk 9200/tcp$',
notify => [ Service['xinetd'], Exec['reload_xinetd'] ]
augeas { 'mysqlchk':
context => '/files/etc/services',
changes => [
'ins service-name after service-name[last()]',
'set service-name[last()] mysqlchkr',
'set service-name[. = "mysqlchk"]/port 9200',
'set service-name[. = "mysqlchk"]/protocol tcp',
],
onlyif => 'match service-name[. = "mysqlchk"] size == 0',
notify => [ Service['xinetd'], Exec['reload_xinetd'] ]
}
file {

View File

@ -86,12 +86,6 @@ describe 'cloud::database::sql' do
end # configure mysql galera server
context 'configure mysqlchk http replication' do
it { should contain_file_line('mysqlchk-in-etc-services').with(
:line => 'mysqlchk 9200/tcp',
:path => '/etc/services',
:notify => ['Service[xinetd]', 'Exec[reload_xinetd]']
)}
it { should contain_file('/etc/xinetd.d/mysqlchk').with_mode('0755') }
it { should contain_file('/usr/bin/clustercheck').with_mode('0755') }
it { should contain_file('/usr/bin/clustercheck').with_content(/MYSQL_USERNAME="#{params[:galera_clustercheck_dbuser]}"/)}