Skip to content
Snippets Groups Projects
Commit 5a40c8af authored by Sébastien Han's avatar Sébastien Han
Browse files

ceph: implement cluster name support


we now have the ability to enable the `cluster` variable with a specific
value that will determine the name of the cluster.

Signed-off-by: default avatarSébastien Han <seb@redhat.com>
parent 1b0074ee
No related branches found
No related tags found
No related merge requests found
......@@ -3,12 +3,12 @@
# the admin key is not instantanely created so we have to wait a bit
- name: wait for client.admin key exists
wait_for:
path: /etc/ceph/ceph.client.admin.keyring
path: /etc/ceph/{{ cluster }}.client.admin.keyring
- name: create ceph rest api keyring when mon is not containerized
command: ceph auth get-or-create client.restapi osd 'allow *' mon 'allow *' -o /etc/ceph/ceph.client.restapi.keyring
command: ceph --cluster {{ cluster }} auth get-or-create client.restapi osd 'allow *' mon 'allow *' -o /etc/ceph/{{ cluster }}.client.restapi.keyring
args:
creates: /etc/ceph/ceph.client.restapi.keyring
creates: /etc/ceph/{{ cluster }}.client.restapi.keyring
changed_when: false
when:
cephx and
......@@ -41,9 +41,9 @@
run_once: true
with_items:
- "{{ ceph_keys.stdout_lines }}"
- /var/lib/ceph/bootstrap-osd/ceph.keyring
- /var/lib/ceph/bootstrap-rgw/ceph.keyring
- /var/lib/ceph/bootstrap-mds/ceph.keyring
- /var/lib/ceph/bootstrap-osd/{{ cluster }}.keyring
- /var/lib/ceph/bootstrap-rgw/{{ cluster }}.keyring
- /var/lib/ceph/bootstrap-mds/{{ cluster }}.keyring
when: cephx
- name: drop in a motd script to report status when logging in
......
......@@ -4,7 +4,7 @@
# the role 'ceph-common' doesn't get inherited so the condition can not be evaluate
# since those check are performed by the ceph-common role
- name: create filesystem pools
command: ceph osd pool create {{ item }} {{ pool_default_pg_num }}
command: ceph --cluster {{ cluster }} osd pool create {{ item }} {{ pool_default_pg_num }}
with_items:
- cephfs_data
- cephfs_metadata
......@@ -12,6 +12,6 @@
when: not {{ ceph_version.stdout | version_compare('0.84', '<') }}
- name: create ceph filesystem
command: ceph fs new {{ cephfs }} {{ cephfs_metadata }} {{ cephfs_data }}
command: ceph --cluster {{ cluster }} fs new {{ cephfs }} {{ cephfs_metadata }} {{ cephfs_data }}
changed_when: false
when: not {{ ceph_version.stdout | version_compare('0.84', '<') }}
......@@ -38,16 +38,16 @@
- name: create monitor directory
file:
path: /var/lib/ceph/mon/ceph-{{ monitor_name }}
path: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}
state: directory
owner: "{{ dir_owner }}"
group: "{{ dir_group }}"
mode: "{{ dir_mode }}"
- name: ceph monitor mkfs with keyring (for or after infernalis release)
command: ceph-mon --setuser ceph --setgroup ceph --mkfs -i {{ monitor_name }} --fsid {{ fsid }} --keyring /var/lib/ceph/tmp/keyring.mon.{{ monitor_name }}
command: ceph-mon --cluster {{ cluster }} --setuser ceph --setgroup ceph --mkfs -i {{ monitor_name }} --fsid {{ fsid }} --keyring /var/lib/ceph/tmp/keyring.mon.{{ monitor_name }}
args:
creates: /var/lib/ceph/mon/ceph-{{ monitor_name }}/keyring
creates: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring
when:
cephx and
is_ceph_infernalis
......@@ -55,7 +55,7 @@
- name: ceph monitor mkfs without keyring (for or after infernalis release)
command: ceph-mon --setuser ceph --setgroup ceph --mkfs -i {{ monitor_name }} --fsid {{ fsid }}
args:
creates: /var/lib/ceph/mon/ceph-{{ monitor_name }}/store.db
creates: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/store.db
when:
not cephx and
is_ceph_infernalis
......@@ -63,7 +63,7 @@
- name: ceph monitor mkfs with keyring (before infernalis release)
command: ceph-mon --mkfs -i {{ monitor_name }} --fsid {{ fsid }} --keyring /var/lib/ceph/tmp/keyring.mon.{{ monitor_name }}
args:
creates: /var/lib/ceph/mon/ceph-{{ monitor_name }}/keyring
creates: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring
when:
cephx and
not is_ceph_infernalis
......@@ -71,7 +71,7 @@
- name: ceph monitor mkfs without keyring (before infernalis release)
command: ceph-mon --mkfs -i {{ monitor_name }} --fsid {{ fsid }}
args:
creates: /var/lib/ceph/mon/ceph-{{ monitor_name }}/store.db
creates: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/store.db
when:
not cephx and
not is_ceph_infernalis
---
- name: create openstack pool
command: ceph osd pool create {{ item.name }} {{ item.pg_num }}
command: ceph --cluster {{ cluster }} osd pool create {{ item.name }} {{ item.pg_num }}
with_items:
- "{{ openstack_glance_pool }}"
- "{{ openstack_cinder_pool }}"
......@@ -10,9 +10,9 @@
failed_when: false
- name: create openstack keys
command: ceph auth get-or-create {{ item.name }} {{ item.value }} -o /etc/ceph/ceph.{{ item.name }}.keyring
command: ceph --cluster {{ cluster }} auth get-or-create {{ item.name }} {{ item.value }} -o /etc/ceph/{{ cluster }}.{{ item.name }}.keyring
args:
creates: /etc/ceph/ceph.{{ item.name }}.keyring
creates: /etc/ceph/{{ cluster }}.{{ item.name }}.keyring
with_items: openstack_keys
changed_when: false
when: cephx
---
- name: collect all the pools
command: rados lspools
command: rados --cluster {{ cluster }} lspools
register: ceph_pools
when: "{{ ceph_version.stdout | version_compare('0.94', '>=') }}"
- name: secure the cluster
command: ceph osd pool set {{ item[0] }} {{ item[1] }} true
command: ceph --cluster {{ cluster }} osd pool set {{ item[0] }} {{ item[1] }} true
with_nested:
- ceph_pools.stdout_lines
- secure_cluster_flags
......
---
- name: activate monitor with upstart
file:
path: /var/lib/ceph/mon/ceph-{{ monitor_name }}/{{ item }}
path: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/{{ item }}
state: touch
owner: "{{ activate_file_owner }}"
group: "{{ activate_file_group }}"
......@@ -13,11 +13,9 @@
when: ansible_distribution == "Ubuntu"
- name: start and add that the monitor service to the init sequence (ubuntu)
service:
name: ceph-mon
state: started
enabled: yes
args: "id={{ monitor_name }}"
command: initctl emit ceph-mon cluster={{ cluster }} id={{ monitor_name }}
changed_when: false
failed_when: false
when: ansible_distribution == "Ubuntu"
# NOTE (leseb): somehow the service ansible module is messing things up
......@@ -51,13 +49,13 @@
is_ceph_infernalis
- name: collect admin and bootstrap keys
command: ceph-create-keys --id {{ monitor_name }}
command: ceph-create-keys --cluster {{ cluster }} --id {{ monitor_name }}
changed_when: false
failed_when: false
when: cephx
- name: get ceph monitor version
shell: ceph daemon mon."{{ monitor_name }}" version | cut -d '"' -f 4 | cut -f 1,2 -d '.'
shell: ceph --cluster {{ cluster }} daemon mon."{{ monitor_name }}" version | cut -d '"' -f 4 | cut -f 1,2 -d '.'
changed_when: false
failed_when: "'No such file or directory' in ceph_version.stderr"
register: ceph_version
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment