]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-cookbooks.git/commitdiff
Add All-in-one recipe
authorGuilhem Lettron <guilhem.lettron@optiflows.com>
Tue, 29 Apr 2014 14:01:27 +0000 (16:01 +0200)
committerGuilhem Lettron <guilhem.lettron@optiflows.com>
Tue, 6 May 2014 14:34:16 +0000 (16:34 +0200)
13 files changed:
.kitchen.yml
Berksfile
attributes/default.rb
libraries/default.rb
recipes/_common.rb [new file with mode: 0644]
recipes/all_in_one.rb [new file with mode: 0644]
recipes/cephfs.rb
recipes/conf.rb
recipes/mds.rb
recipes/mon.rb
recipes/osd.rb
test/integration/Vagrantfile.erb [new file with mode: 0644]
test/integration/aio/bats/ceph-running.bats [new file with mode: 0644]

index 5963e970cf8ddddbbc4cca6d0230363248918906..ca29bb0e284a9917628ea3ee81e8d11408d4b9ce 100644 (file)
@@ -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]
index c4bb297b7275b30a05f31711108f9db82b9623e5..db8f00b47be99a424c3a5d6f3a1b35c098f85550 100644 (file)
--- a/Berksfile
+++ b/Berksfile
@@ -1,3 +1,7 @@
 site :opscode
 
 metadata
+
+group :integration do
+  cookbook 'apt'
+end
index 8d9a48ea83f7fd466ddecc044ab6a4efd0f7ce1d..66dcf0d04de4aecd55b25eb549f2db3ab6730d94 100644 (file)
@@ -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
index 142b31475a3af2531be173378c82007d26d2d384..3e12340e97cbc5e051ca41782e9a2b33025c8a76 100644 (file)
@@ -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 (file)
index 0000000..37a0da8
--- /dev/null
@@ -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 (file)
index 0000000..cfd6568
--- /dev/null
@@ -0,0 +1,4 @@
+
+include_recipe 'ceph::mon'
+include_recipe 'ceph::osd'
+# include_recipe 'ceph::radosgw'
index 0d6e4b6489cfef07f3a1ca2179a48738256e0e1f..6017c2f4ed16de4c64d01da57ccc70f0d1bf38cc 100644 (file)
@@ -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'
index f7352602b1332c5d80f283f7f5c724f4ca370081..43d6a543c6db4049250bf019ccc8adf9e072da57 100644 (file)
@@ -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
index 01111353d688754a9c6bd1953a4a400fa965a41a..93476cf42fa70e2552fa8cb5fbe44d9356561434 100644 (file)
@@ -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'
 
index 69dfb64c67dbc8262de3d631ce3479751aad4a7e..30e6994b536309f41cf22b10a29c59e4c63ee8ba 100644 (file)
 #  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'
index dd20e699f38be56684af259c871f01b6a6db02ad..3407e51a78783c5ab4a9da9509873d8138a22882 100644 (file)
@@ -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 (file)
index 0000000..b3d22a1
--- /dev/null
@@ -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 (file)
index 0000000..388fb6a
--- /dev/null
@@ -0,0 +1,7 @@
+@test "ceph is running" {
+  ceph -s | grep HEALTH
+}
+
+@test "ceph is healthy" {
+  ceph -s | grep HEALTH_OK
+}