From 8462154fb8fa8cfc81d8f8ef5dff646f777029f9 Mon Sep 17 00:00:00 2001 From: David Gurtner Date: Tue, 24 Jun 2014 13:43:50 +0200 Subject: [PATCH] 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 --- manifests/key.pp | 2 +- spec/system/ceph_key_spec.rb | 3 ++- spec/system/ceph_osds_spec.rb | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/manifests/key.pp b/manifests/key.pp index 9bb594b8..57fcdc1d 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -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, } diff --git a/spec/system/ceph_key_spec.rb b/spec/system/ceph_key_spec.rb index 67e8b811..ac76cf65 100644 --- a/spec/system/ceph_key_spec.rb +++ b/spec/system/ceph_key_spec.rb @@ -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| diff --git a/spec/system/ceph_osds_spec.rb b/spec/system/ceph_osds_spec.rb index 56b9678e..3a3012ad 100644 --- a/spec/system/ceph_osds_spec.rb +++ b/spec/system/ceph_osds_spec.rb @@ -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