Escape the base64 encoded key in regexp matching

The base64 encoding of ceph keys often contains the slash / character.
This interferes with the regexp matcher slashes and thus never exits
with code 0.

The fix is to use a different RE delimiter.

Change-Id: Ia262b36250ebeb833b4a125e6b1f3976f8b069cd
Closes-Bug: #1333657
This commit is contained in:
David Gurtner
2014-06-24 13:43:50 +02:00
parent 8e0346d0ee
commit 8462154fb8
3 changed files with 4 additions and 2 deletions

View File

@@ -118,7 +118,7 @@ set -ex
ceph-authtool ${keyring_path} --name '${name}' --add-key '${secret}' ${caps}",
unless => "/bin/true # comment to satisfy puppet syntax requirements
set -ex
sed -n 'N;/.*${name}.*\\n\\s*key = ${secret}/p' ${keyring_path} | grep ${name}",
sed -n 'N;\\%.*${name}.*\\n\\s*key = ${secret}%p' ${keyring_path} | grep ${name}",
require => [ Package['ceph'], File[$keyring_path], ],
logoutput => true,
}

View File

@@ -28,7 +28,7 @@ describe 'ceph::key' do
machines = ENV['MACHINES'] ? ENV['MACHINES'].split : [ 'first', 'second' ]
fsid = 'a4807c9a-e76f-4666-a297-6d6cbc922e3a'
mon_key = 'AQCztJdSyNb0NBAASA2yPZPuwXeIQnDJ9O8gVw=='
admin_key = 'AQA0TVRTsP/aHxAAFBvntu1dSEJHxtJeFFrRsg=='
admin_key = 'AQA0TVRTsP/aHxAAFBvntu1dSEJHxtJeFFrRsg==' # client.admin key needs to contain a / character!
volume_key = 'AQAMTVRTSOHmHBAAH5d1ukHrAnxuSbrWSv9KGA=='
mon_host = '$::ipaddress_eth1'
# passing it directly as unqoted array is not supported everywhere
@@ -195,6 +195,7 @@ describe 'ceph::key' do
r.exit_code.should_not == 1
r.refresh
r.exit_code.should_not == 1
r.stdout.should_not =~ /Exec\[ceph-key-client\.admin\]/ # client.admin key needs to contain a / character!
end
shell 'ceph auth list' do |r|

View File

@@ -131,6 +131,7 @@ ensure: purged
end
shell(:node => vm, :command => 'test -b /dev/sdb && sgdisk --zap-all --clear --mbrtogpt -- /dev/sdb')
shell(:node => vm, :command => 'rm -rf /var/lib/ceph; rm -rf /etc/ceph')
end
end