Merge pull request #40 from shellycloud/master
Used encrypted data bags for storing secrets #34.
This commit is contained in:
commit
c48998a6b9
@ -1 +1,2 @@
|
|||||||
default['ceph']['install_debug'] = true
|
default['ceph']['install_debug'] = true
|
||||||
|
default['ceph']['encrypted_data_bags'] = false
|
||||||
|
@ -4,3 +4,4 @@ when 'ubuntu'
|
|||||||
else
|
else
|
||||||
default["ceph"]["mon"]["init_style"] = "sysvinit"
|
default["ceph"]["mon"]["init_style"] = "sysvinit"
|
||||||
end
|
end
|
||||||
|
default["ceph"]["mon"]["secret_file"] = "/etc/chef/secrets/ceph_mon"
|
||||||
|
@ -4,3 +4,4 @@ when 'ubuntu'
|
|||||||
else
|
else
|
||||||
default["ceph"]["osd"]["init_style"] = "sysvinit"
|
default["ceph"]["osd"]["init_style"] = "sysvinit"
|
||||||
end
|
end
|
||||||
|
default["ceph"]["osd"]["secret_file"] = "/etc/chef/secrets/ceph_osd"
|
||||||
|
@ -5,7 +5,7 @@ branch = node['ceph']['branch']
|
|||||||
apt_repository "ceph-#{branch}" do
|
apt_repository "ceph-#{branch}" do
|
||||||
repo_name "ceph"
|
repo_name "ceph"
|
||||||
uri node['ceph']['debian'][branch]['repository']
|
uri node['ceph']['debian'][branch]['repository']
|
||||||
distribution node['lsb']['codename']
|
distribution node['lsb']['codename'] == "jessie" ? "sid" : node['lsb']['codename']
|
||||||
components ['main']
|
components ['main']
|
||||||
key node['ceph']['debian'][branch]['repository_key']
|
key node['ceph']['debian'][branch]['repository_key']
|
||||||
end
|
end
|
||||||
|
@ -41,8 +41,15 @@ cluster = 'ceph'
|
|||||||
unless File.exists?("/var/lib/ceph/mon/ceph-#{node["hostname"]}/done")
|
unless File.exists?("/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"
|
||||||
|
|
||||||
|
monitor_secret = if node['ceph']['encrypted_data_bags']
|
||||||
|
secret = Chef::EncryptedDataBagItem.load_secret(node["ceph"]["mon"]["secret_file"])
|
||||||
|
Chef::EncryptedDataBagItem.load("ceph", "mon", secret)["secret"]
|
||||||
|
else
|
||||||
|
node["ceph"]["monitor-secret"]
|
||||||
|
end
|
||||||
|
|
||||||
execute "format as keyring" do
|
execute "format as keyring" do
|
||||||
command "ceph-authtool '#{keyring}' --create-keyring --name=mon. --add-key='#{node["ceph"]["monitor-secret"]}' --cap mon 'allow *'"
|
command "ceph-authtool '#{keyring}' --create-keyring --name=mon. --add-key='#{monitor_secret}' --cap mon 'allow *'"
|
||||||
creates "#{Chef::Config[:file_cache_path]}/#{cluster}-#{node['hostname']}.mon.keyring"
|
creates "#{Chef::Config[:file_cache_path]}/#{cluster}-#{node['hostname']}.mon.keyring"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -93,15 +100,17 @@ end
|
|||||||
# The key is going to be automatically
|
# The key is going to be automatically
|
||||||
# created,
|
# created,
|
||||||
# We store it when it is created
|
# We store it when it is created
|
||||||
ruby_block "get osd-bootstrap keyring" do
|
unless node['ceph']['encrypted_data_bags']
|
||||||
block do
|
ruby_block "get osd-bootstrap keyring" do
|
||||||
run_out = ""
|
block do
|
||||||
while run_out.empty?
|
run_out = ""
|
||||||
run_out = Mixlib::ShellOut.new("ceph auth get-key client.bootstrap-osd").run_command.stdout.strip
|
while run_out.empty?
|
||||||
sleep 2
|
run_out = Mixlib::ShellOut.new("ceph auth get-key client.bootstrap-osd").run_command.stdout.strip
|
||||||
|
sleep 2
|
||||||
|
end
|
||||||
|
node.override['ceph']['bootstrap_osd_key'] = run_out
|
||||||
|
node.save
|
||||||
end
|
end
|
||||||
node.override['ceph']['bootstrap_osd_key'] = run_out
|
not_if { node['ceph']['bootstrap_osd_key'] }
|
||||||
node.save
|
|
||||||
end
|
end
|
||||||
not_if { node['ceph']['bootstrap_osd_key'] }
|
|
||||||
end
|
end
|
||||||
|
@ -45,7 +45,7 @@ if !search(:node,"hostname:#{node['hostname']} AND dmcrypt:true").empty?
|
|||||||
end
|
end
|
||||||
|
|
||||||
service_type = node["ceph"]["osd"]["init_style"]
|
service_type = node["ceph"]["osd"]["init_style"]
|
||||||
mons = get_mon_nodes("ceph_bootstrap_osd_key:*")
|
mons = node['ceph']['encrypted_data_bags'] ? get_mon_nodes : get_mon_nodes("ceph_bootstrap_osd_key:*")
|
||||||
|
|
||||||
if mons.empty? then
|
if mons.empty? then
|
||||||
puts "No ceph-mon found."
|
puts "No ceph-mon found."
|
||||||
@ -60,8 +60,15 @@ else
|
|||||||
# TODO cluster name
|
# TODO cluster name
|
||||||
cluster = 'ceph'
|
cluster = 'ceph'
|
||||||
|
|
||||||
|
osd_secret = if node['ceph']['encrypted_data_bags']
|
||||||
|
secret = Chef::EncryptedDataBagItem.load_secret(node["ceph"]["osd"]["secret_file"])
|
||||||
|
Chef::EncryptedDataBagItem.load("ceph", "osd", secret)["secret"]
|
||||||
|
else
|
||||||
|
mons[0]["ceph"]["bootstrap_osd_key"]
|
||||||
|
end
|
||||||
|
|
||||||
execute "format as keyring" do
|
execute "format as keyring" do
|
||||||
command "ceph-authtool '/var/lib/ceph/bootstrap-osd/#{cluster}.keyring' --create-keyring --name=client.bootstrap-osd --add-key='#{mons[0]["ceph"]["bootstrap_osd_key"]}'"
|
command "ceph-authtool '/var/lib/ceph/bootstrap-osd/#{cluster}.keyring' --create-keyring --name=client.bootstrap-osd --add-key='#{osd_secret}'"
|
||||||
creates "/var/lib/ceph/bootstrap-osd/#{cluster}.keyring"
|
creates "/var/lib/ceph/bootstrap-osd/#{cluster}.keyring"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user