From: Jiří Suchomel Date: Thu, 25 Sep 2014 09:02:48 +0000 (+0200) Subject: create 'done' file (and friends) for ubuntu only X-Git-Tag: v0.8.0~13^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cb8ac7bb6ad8c6626b6a30ebed7f88d92da4b383;p=ceph-cookbooks.git create 'done' file (and friends) for ubuntu only --- diff --git a/recipes/mon.rb b/recipes/mon.rb index f69e679..d98c7b5 100644 --- a/recipes/mon.rb +++ b/recipes/mon.rb @@ -41,44 +41,44 @@ end # TODO: cluster name cluster = 'ceph' -unless File.exist?("/var/lib/ceph/mon/ceph-#{node['hostname']}/done") - keyring = "#{Chef::Config[:file_cache_path]}/#{cluster}-#{node['hostname']}.mon.keyring" +keyring = "#{Chef::Config[:file_cache_path]}/#{cluster}-#{node['hostname']}.mon.keyring" - execute 'format mon-secret as keyring' do - command lazy { "ceph-authtool '#{keyring}' --create-keyring --name=mon. --add-key='#{mon_secret}' --cap mon 'allow *'" } - creates "#{Chef::Config[:file_cache_path]}/#{cluster}-#{node['hostname']}.mon.keyring" - only_if { mon_secret } - end +execute 'format mon-secret as keyring' do + command lazy { "ceph-authtool '#{keyring}' --create-keyring --name=mon. --add-key='#{mon_secret}' --cap mon 'allow *'" } + creates "#{Chef::Config[:file_cache_path]}/#{cluster}-#{node['hostname']}.mon.keyring" + only_if { mon_secret } +end - execute 'generate mon-secret as keyring' do - command "ceph-authtool '#{keyring}' --create-keyring --name=mon. --gen-key --cap mon 'allow *'" - creates "#{Chef::Config[:file_cache_path]}/#{cluster}-#{node['hostname']}.mon.keyring" - not_if { mon_secret } - notifies :create, 'ruby_block[save mon_secret]', :immediately - end +execute 'generate mon-secret as keyring' do + command "ceph-authtool '#{keyring}' --create-keyring --name=mon. --gen-key --cap mon 'allow *'" + creates "#{Chef::Config[:file_cache_path]}/#{cluster}-#{node['hostname']}.mon.keyring" + not_if { mon_secret } + notifies :create, 'ruby_block[save mon_secret]', :immediately +end - ruby_block 'save mon_secret' do - block do - fetch = Mixlib::ShellOut.new("ceph-authtool '#{keyring}' --print-key --name=mon.") - fetch.run_command - key = fetch.stdout - node.set['ceph']['monitor-secret'] = key - node.save - end - action :nothing +ruby_block 'save mon_secret' do + block do + fetch = Mixlib::ShellOut.new("ceph-authtool '#{keyring}' --print-key --name=mon.") + fetch.run_command + key = fetch.stdout + node.set['ceph']['monitor-secret'] = key + node.save end + action :nothing +end - execute 'ceph-mon mkfs' do - command "ceph-mon --mkfs -i #{node['hostname']} --keyring '#{keyring}'" - end +execute 'ceph-mon mkfs' do + command "ceph-mon --mkfs -i #{node['hostname']} --keyring '#{keyring}'" +end - ruby_block 'finalise' do - block do - ['done', service_type].each do |ack| - ::File.open("/var/lib/ceph/mon/ceph-#{node['hostname']}/#{ack}", 'w').close - end +# needed only by https://github.com/ceph/ceph/blob/master/src/upstart/ceph-mon-all-starter.conf +ruby_block 'finalise' do + block do + ['done', service_type].each do |ack| + ::File.open("/var/lib/ceph/mon/ceph-#{node['hostname']}/#{ack}", 'w').close end end + only_if { node['platform'] == 'ubuntu' } end if service_type == 'upstart'