]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
WIP: Implement OSD sections 177/head
authorSébastien Han <sebastien.han@enovance.com>
Thu, 8 Jan 2015 17:27:43 +0000 (12:27 -0500)
committerSébastien Han <sebastien.han@enovance.com>
Fri, 9 Jan 2015 16:14:20 +0000 (11:14 -0500)
Still WIP, @mwheckmann free to test
As requested by #162

Current known issue, since ceph.conf gets modified during every single
run (at the end during the merge) so this will restart ceph daemons.

Signed-off-by: Sébastien Han <sebastien.han@enovance.com>
group_vars/osds
roles/ceph-osd/defaults/main.yml
roles/ceph-osd/tasks/activate_osds.yml
roles/ceph-osd/tasks/osd_fragment.yml [new file with mode: 0644]
roles/ceph-osd/templates/osd.conf.j2 [new file with mode: 0644]

index a3408c5f824bcdaaee7c9de7932b7665cf9ce584..94a90af7abfa08632f6b521749ad7079b6fd0558 100644 (file)
@@ -5,8 +5,27 @@
 # Dummy variable to avoid error because ansible does not recognize the file as a good configuration file when no variable in it.
 dummy:
 
-## Ceph options
+####################
+# OSD CRUSH LOCATION
+####################
+
+# The following options will build a ceph.conf with OSD sections
+# Example:
+# [osd.X]
+# osd crush location = "root=location"
 #
+# This works with your inventory file
+# To match the following 'osd_crush_location' option the inventory must look like:
+#
+# [osds]
+# osd0 ceph_crush_root=foo ceph_crush_rack=bar
+
+crush_location: false
+osd_crush_location: "'root={{ ceph_crush_root }} rack={{ ceph_crush_rack }} host={{ ansible_hostname }}'"
+
+##############
+# CEPH OPTIONS
+##############
 
 #cephx: true
 
index 06b93129a8bcbd3bc618da38ea1649ed594b71a2..f6cc08a00db955bf8c85b3abca3b578614f9e118 100644 (file)
@@ -2,8 +2,27 @@
 # You can override default vars defined in defaults/main.yml here,\r
 # but I would advice to use host or group vars instead\r
 \r
-## Ceph options\r
+####################\r
+# OSD CRUSH LOCATION\r
+####################\r
+\r
+# The following options will build a ceph.conf with OSD sections\r
+# Example:\r
+# [osd.X]\r
+# osd crush location = "root=location"\r
 #\r
+# This works with your inventory file\r
+# To match the following 'osd_crush_location' option the inventory must look like:\r
+#\r
+# [osds]\r
+# osd0 ceph_crush_root=foo ceph_crush_rack=bar\r
+\r
+crush_location: false\r
+osd_crush_location: "'root={{ ceph_crush_root }} rack={{ ceph_crush_rack }} host={{ ansible_hostname }}'"\r
+\r
+##############\r
+# CEPH OPTIONS\r
+##############\r
 \r
 # ACTIVATE THE FSID VARIABLE FOR NON-VAGRANT DEPLOYMENT\r
 fsid: "{{ cluster_uuid.stdout }}"\r
index 806b2b187e91d67dd14e709d8d81a5f9fa797e12..14b448a90bc536a8b4230ee2d4dd177bae367539 100644 (file)
@@ -31,6 +31,9 @@
   ignore_errors: True
   changed_when: False
 
+- include: osd_fragment.yml
+  when: crush_location
+
 - name: Start and add that the OSD service to the init sequence
   service: >
     name=ceph
diff --git a/roles/ceph-osd/tasks/osd_fragment.yml b/roles/ceph-osd/tasks/osd_fragment.yml
new file mode 100644 (file)
index 0000000..13f96ca
--- /dev/null
@@ -0,0 +1,48 @@
+---
+- name: Get OSD path
+  shell: "df | grep {{ item }} | awk '{print $6}'"
+  with_items: devices
+  register: osd_path
+  ignore_errors: true
+
+- name: Get OSD id
+  command: cat {{ item.stdout }}/whoami
+  register: osd_id
+  with_items: osd_path.results
+  ignore_errors: true
+
+- name: Create a Ceph fragment and assemble directory
+  file: >
+    path={{ item }}
+    state=directory
+    owner=root
+    group=root
+    mode=0644
+  with_items:
+    - /etc/ceph/ceph.d/
+    - /etc/ceph/ceph.d/osd_fragments
+
+- name: Create the OSD fragment
+  template: >
+    src=osd.conf.j2
+    dest=/etc/ceph/ceph.d/osd_fragments/osd.{{ item.stdout }}.conf
+  with_items: osd_id.results
+
+- name: Copy ceph.conf for assembling
+  command: cp /etc/ceph/ceph.conf /etc/ceph/ceph.d/
+
+- name: Assemble OSD sections
+  assemble: >
+    src=/etc/ceph/ceph.d/osd_fragments/
+    dest=/etc/ceph/ceph.d/osd.conf
+    owner=root
+    group=root
+    mode=0644
+
+- name: Assemble Ceph conf and OSD fragments
+  assemble: >
+    src=/etc/ceph/ceph.d/
+    dest=/etc/ceph/ceph.conf
+    owner=root
+    group=root
+    mode=0644
diff --git a/roles/ceph-osd/templates/osd.conf.j2 b/roles/ceph-osd/templates/osd.conf.j2
new file mode 100644 (file)
index 0000000..981800a
--- /dev/null
@@ -0,0 +1,2 @@
+[osd.{{ item.stdout }}]
+osd crush location = {{ osd_crush_location }}