From: Guilhem Lettron Date: Tue, 29 Apr 2014 14:01:27 +0000 (+0200) Subject: Add All-in-one recipe X-Git-Tag: v0.8.0~41 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f48fa95e26448c41bb640d2a857a056dc819259a;p=ceph-cookbooks.git Add All-in-one recipe --- diff --git a/.kitchen.yml b/.kitchen.yml index 5963e97..ca29bb0 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,11 +1,16 @@ --- driver_plugin: vagrant driver_config: + vagrantfile_erb: test/integration/Vagrantfile.erb require_chef_omnibus: true platforms: - name: ubuntu-10.04 + run_list: + - recipe[apt] - name: ubuntu-12.04 + run_list: + - recipe[apt] - name: centos-6.4 - name: centos-5.9 @@ -39,3 +44,16 @@ suites: run_list: - "role[ceph-radosgw]" attributes: *defaults +- name: aio + attributes: + ceph: + config-sections: + global: + "osd journal size" : 128 + "osd pool default size": 1 + osd_devices: + - { device: "/dev/sdb" } + - { device: "/dev/sdc" } + - { device: "/dev/sdd" } + run_list: + - recipe[ceph::all_in_one] diff --git a/Berksfile b/Berksfile index c4bb297..db8f00b 100644 --- a/Berksfile +++ b/Berksfile @@ -1,3 +1,7 @@ site :opscode metadata + +group :integration do + cookbook 'apt' +end diff --git a/attributes/default.rb b/attributes/default.rb index 8d9a48e..66dcf0d 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,2 +1,4 @@ -default['ceph']['install_debug'] = true +default['ceph']['install_debug'] = false default['ceph']['encrypted_data_bags'] = false + +default['ceph']['install_repo'] = true diff --git a/libraries/default.rb b/libraries/default.rb index 142b314..3e12340 100644 --- a/libraries/default.rb +++ b/libraries/default.rb @@ -5,7 +5,7 @@ def crowbar? !defined?(Chef::Recipe::Barclamp).nil? end -def get_mon_nodes(extra_search = nil) +def mon_nodes if crowbar? mon_roles = search(:role, 'name:crowbar-* AND run_list:role\[ceph-mon\]') unless mon_roles.empty? @@ -16,12 +16,21 @@ def get_mon_nodes(extra_search = nil) search_string = "ceph_is_mon:true AND chef_environment:#{node.chef_environment}" end - unless extra_search.nil? - search_string = "(#{search_string}) AND (#{extra_search})" + if use_cephx? && !node['ceph']['encrypted_data_bags'] + search_string = "(#{search_string}) AND (ceph_bootstrap_osd_key:*)" end search(:node, search_string) end +def osd_secret + if node['ceph']['encrypted_data_bags'] + secret = Chef::EncryptedDataBagItem.load_secret(node['ceph']['osd']['secret_file']) + return Chef::EncryptedDataBagItem.load('ceph', 'osd', secret)['secret'] + else + return mon_nodes[0]['ceph']['bootstrap_osd_key'] + end +end + # If public_network is specified # we need to search for the monitor IP # in the node environment. @@ -70,7 +79,7 @@ def mon_addresses # primarily to local node mons << node if node['ceph']['is_mon'] - mons += get_mon_nodes + mons += mon_nodes if crowbar? mon_ips = mons.map { |node| Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, 'admin').address } else @@ -87,7 +96,7 @@ end def mon_secret # find the monitor secret mon_secret = '' - mons = get_mon_nodes + mons = mon_nodes if !mons.empty? mon_secret = mons[0]['ceph']['monitor-secret'] elsif mons.empty? && node['ceph']['monitor-secret'] diff --git a/recipes/_common.rb b/recipes/_common.rb new file mode 100644 index 0000000..37a0da8 --- /dev/null +++ b/recipes/_common.rb @@ -0,0 +1,2 @@ + +include_recipe 'ceph::repo' if node['ceph']['install_repo'] diff --git a/recipes/all_in_one.rb b/recipes/all_in_one.rb new file mode 100644 index 0000000..cfd6568 --- /dev/null +++ b/recipes/all_in_one.rb @@ -0,0 +1,4 @@ + +include_recipe 'ceph::mon' +include_recipe 'ceph::osd' +# include_recipe 'ceph::radosgw' diff --git a/recipes/cephfs.rb b/recipes/cephfs.rb index 0d6e4b6..6017c2f 100644 --- a/recipes/cephfs.rb +++ b/recipes/cephfs.rb @@ -17,6 +17,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +include_recipe 'ceph::_common' include_recipe 'ceph::conf' name = 'cephfs' diff --git a/recipes/conf.rb b/recipes/conf.rb index f735260..43d6a54 100644 --- a/recipes/conf.rb +++ b/recipes/conf.rb @@ -1,5 +1,11 @@ -fail 'fsid must be set in config' if node['ceph']['config']['fsid'].nil? -fail 'mon_initial_members must be set in config' if node['ceph']['config']['mon_initial_members'].nil? +# fail 'mon_initial_members must be set in config' if node['ceph']['config']['mon_initial_members'].nil? + +unless node['ceph']['config']['fsid'] + Chef::Log.warn('We are genereting a new uuid for fsid') + require 'securerandom' + node.set['ceph']['config']['fsid'] = SecureRandom.uuid + node.save +end directory '/etc/ceph' do owner 'root' @@ -10,9 +16,11 @@ end template '/etc/ceph/ceph.conf' do source 'ceph.conf.erb' - variables( - :mon_addresses => mon_addresses, - :is_rgw => node['ceph']['is_radosgw'] - ) + variables lazy { + { + :mon_addresses => mon_addresses, + :is_rgw => node['ceph']['is_radosgw'] + } + } mode '0644' end diff --git a/recipes/mds.rb b/recipes/mds.rb index 0111135..93476cf 100644 --- a/recipes/mds.rb +++ b/recipes/mds.rb @@ -17,6 +17,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +include_recipe 'ceph::_common' include_recipe 'ceph::default' include_recipe 'ceph::conf' diff --git a/recipes/mon.rb b/recipes/mon.rb index 69dfb64..30e6994 100644 --- a/recipes/mon.rb +++ b/recipes/mon.rb @@ -14,13 +14,14 @@ # different and are created in # /var/lib/ceph/bootstrap-{osd,mds}/ceph.keyring +node.default['ceph']['is_mon'] = true + +include_recipe 'ceph::_common' include_recipe 'ceph::default' include_recipe 'ceph::conf' service_type = node['ceph']['mon']['init_style'] -node.default['ceph']['is_mon'] = true - directory '/var/run/ceph' do owner 'root' group 'root' diff --git a/recipes/osd.rb b/recipes/osd.rb index dd20e69..3407e51 100644 --- a/recipes/osd.rb +++ b/recipes/osd.rb @@ -31,6 +31,7 @@ # } # ] +include_recipe 'ceph::_common' include_recipe 'ceph::default' include_recipe 'ceph::conf' @@ -44,15 +45,6 @@ package 'cryptsetup' do end service_type = node['ceph']['osd']['init_style'] -# Look for monitors with osd bootstrap keys. -# If we're storing keys in encrypted data bags, then we'll have to trust the roles -if use_cephx? && !node['ceph']['encrypted_data_bags'] - mons = get_mon_nodes('ceph_bootstrap_osd_key:*') -else - mons = get_mon_nodes -end - -return 'No ceph-mon found.' if mons.empty? directory '/var/lib/ceph/bootstrap-osd' do owner 'root' @@ -63,16 +55,10 @@ end # TODO: cluster name cluster = 'ceph' -if node['ceph']['encrypted_data_bags'] - secret = Chef::EncryptedDataBagItem.load_secret(node['ceph']['osd']['secret_file']) - osd_secret = Chef::EncryptedDataBagItem.load('ceph', 'osd', secret)['secret'] -else - osd_secret = mons[0]['ceph']['bootstrap_osd_key'] -end - execute 'format as keyring' do - command "ceph-authtool '/var/lib/ceph/bootstrap-osd/#{cluster}.keyring' --create-keyring --name=client.bootstrap-osd --add-key='#{osd_secret}'" + command lazy { "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" + only_if { osd_secret } end if crowbar? diff --git a/test/integration/Vagrantfile.erb b/test/integration/Vagrantfile.erb new file mode 100644 index 0000000..b3d22a1 --- /dev/null +++ b/test/integration/Vagrantfile.erb @@ -0,0 +1,13 @@ +Vagrant.configure("2") do |config| + config.vm.box = "<%= config[:box] %>" + config.vm.box_url = "<%= config[:box_url ]%>" + config.vm.provider :virtualbox do |vb| + vb.customize [ "storagectl", :id, "--name", "SATA Controller", "--add", "sata", "--controller", "IntelAHCI" ] + end + (0..2).each do |d| + config.vm.provider :virtualbox do |vb| + vb.customize [ "createhd", "--filename", "disk-#{d}", "--size", "1000" ] + vb.customize [ "storageattach", :id, "--storagectl", "SATA Controller", "--port", 3+d, "--device", 0, "--type", "hdd", "--medium", "disk-#{d}.vdi" ] + end + end +end diff --git a/test/integration/aio/bats/ceph-running.bats b/test/integration/aio/bats/ceph-running.bats new file mode 100644 index 0000000..388fb6a --- /dev/null +++ b/test/integration/aio/bats/ceph-running.bats @@ -0,0 +1,7 @@ +@test "ceph is running" { + ceph -s | grep HEALTH +} + +@test "ceph is healthy" { + ceph -s | grep HEALTH_OK +}