From f68cd4666411429da4a362df2f2645a376728455 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Han?= Date: Thu, 8 Jan 2015 12:27:43 -0500 Subject: [PATCH] WIP: Implement OSD sections MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- group_vars/osds | 21 ++++++++++- roles/ceph-osd/defaults/main.yml | 21 ++++++++++- roles/ceph-osd/tasks/activate_osds.yml | 3 ++ roles/ceph-osd/tasks/osd_fragment.yml | 48 ++++++++++++++++++++++++++ roles/ceph-osd/templates/osd.conf.j2 | 2 ++ 5 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 roles/ceph-osd/tasks/osd_fragment.yml create mode 100644 roles/ceph-osd/templates/osd.conf.j2 diff --git a/group_vars/osds b/group_vars/osds index a3408c5f8..94a90af7a 100644 --- a/group_vars/osds +++ b/group_vars/osds @@ -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 diff --git a/roles/ceph-osd/defaults/main.yml b/roles/ceph-osd/defaults/main.yml index 06b93129a..f6cc08a00 100644 --- a/roles/ceph-osd/defaults/main.yml +++ b/roles/ceph-osd/defaults/main.yml @@ -2,8 +2,27 @@ # You can override default vars defined in defaults/main.yml here, # but I would advice to use host or group vars instead -## 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 +############## # ACTIVATE THE FSID VARIABLE FOR NON-VAGRANT DEPLOYMENT fsid: "{{ cluster_uuid.stdout }}" diff --git a/roles/ceph-osd/tasks/activate_osds.yml b/roles/ceph-osd/tasks/activate_osds.yml index 806b2b187..14b448a90 100644 --- a/roles/ceph-osd/tasks/activate_osds.yml +++ b/roles/ceph-osd/tasks/activate_osds.yml @@ -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 index 000000000..13f96caf9 --- /dev/null +++ b/roles/ceph-osd/tasks/osd_fragment.yml @@ -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 index 000000000..981800ac3 --- /dev/null +++ b/roles/ceph-osd/templates/osd.conf.j2 @@ -0,0 +1,2 @@ +[osd.{{ item.stdout }}] +osd crush location = {{ osd_crush_location }} -- 2.39.5