From a4c7ef3cc581c2185f8376198fffe2a171f1a30c Mon Sep 17 00:00:00 2001 From: James Saint-Rossy Date: Wed, 10 Aug 2016 17:05:27 -0400 Subject: [PATCH] Initial support for RGW Multisite --- roles/ceph-common/templates/ceph.conf.j2 | 3 ++ roles/ceph-rgw/handlers/main.yml | 4 +-- roles/ceph-rgw/tasks/main.yml | 2 +- roles/ceph-rgw/tasks/multisite/checks.yml | 24 +++++++++++++++ roles/ceph-rgw/tasks/multisite/destroy.yml | 29 +++++++++++++++++++ roles/ceph-rgw/tasks/multisite/main.yml | 19 ++++++++++++ roles/ceph-rgw/tasks/multisite/master.yml | 28 ++++++++++++++++++ .../secondary.yml} | 28 ++++++++++++++++-- 8 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 roles/ceph-rgw/tasks/multisite/checks.yml create mode 100644 roles/ceph-rgw/tasks/multisite/destroy.yml create mode 100644 roles/ceph-rgw/tasks/multisite/main.yml create mode 100644 roles/ceph-rgw/tasks/multisite/master.yml rename roles/ceph-rgw/tasks/{multisite.yml => multisite/secondary.yml} (61%) diff --git a/roles/ceph-common/templates/ceph.conf.j2 b/roles/ceph-common/templates/ceph.conf.j2 index aa383c217..14c5e0bb3 100644 --- a/roles/ceph-common/templates/ceph.conf.j2 +++ b/roles/ceph-common/templates/ceph.conf.j2 @@ -104,6 +104,9 @@ rgw keystone revocation interval = {{ radosgw_keystone_revocation_internal }} rgw s3 auth use keystone = {{ radosgw_s3_auth_use_keystone }} nss db path = {{ radosgw_nss_db_path }} {% endif %} +{% if rgw_zonegroup is defined and rgw_zone is defined %} +rgw zone = {{ rgw_zonegroup }}-{{ rgw_zone }} +{% endif %} {% endif %} {% endfor %} {% endif %} diff --git a/roles/ceph-rgw/handlers/main.yml b/roles/ceph-rgw/handlers/main.yml index a448e19bd..ccb822659 100644 --- a/roles/ceph-rgw/handlers/main.yml +++ b/roles/ceph-rgw/handlers/main.yml @@ -1,3 +1,3 @@ --- -- include: multisite.yml - when: rgw_zone is defined and rgw_multisite and ( is_jewel or is_after_jewel ) +- name: update period + command: radosgw-admin period update --commit diff --git a/roles/ceph-rgw/tasks/main.yml b/roles/ceph-rgw/tasks/main.yml index f79ee73aa..2388a5124 100644 --- a/roles/ceph-rgw/tasks/main.yml +++ b/roles/ceph-rgw/tasks/main.yml @@ -5,7 +5,7 @@ - include: openstack-keystone.yml when: radosgw_keystone -- include: multisite.yml +- include: ./multisite/main.yml when: rgw_zone is defined and rgw_multisite and ( is_jewel or is_after_jewel ) - include: start_radosgw.yml diff --git a/roles/ceph-rgw/tasks/multisite/checks.yml b/roles/ceph-rgw/tasks/multisite/checks.yml new file mode 100644 index 000000000..849e1ff33 --- /dev/null +++ b/roles/ceph-rgw/tasks/multisite/checks.yml @@ -0,0 +1,24 @@ +--- +- name: Check if the realm already exists + command: radosgw-admin realm get --rgw-realm={{ rgw_realm }} + register: realmcheck + failed_when: False + changed_when: False + +- name: Check if the zonegroup already exists + command: radosgw-admin zonegroup get --rgw-zonegroup={{ rgw_zonegroup }} + register: zonegroupcheck + failed_when: False + changed_when: False + +- name: Check if the zone already exists + command: radosgw-admin zone get --rgw-zone={{ rgw_zone }} + register: zonecheck + failed_when: False + changed_when: False + +- name: Check if the system user already exists + command: radosgw-admin user info --uid=zone.user + register: usercheck + failed_when: False + changed_when: False diff --git a/roles/ceph-rgw/tasks/multisite/destroy.yml b/roles/ceph-rgw/tasks/multisite/destroy.yml new file mode 100644 index 000000000..baae33a16 --- /dev/null +++ b/roles/ceph-rgw/tasks/multisite/destroy.yml @@ -0,0 +1,29 @@ +--- +- name: Delete the zone user + command: radosgw-admin user rm --uid=zone.user + run_once: true + failed_when: false + notify: + - update period + +- name: Delete the zone + command: radosgw-admin zone delete --rgw-zonegroup={{ rgw_zonegroup }} --rgw-zone={{ rgw_zone }} + run_once: true + failed_when: false + notify: + - update period + +- name: Delete the zonegroup + command: radosgw-admin zonegroup delete --rgw-zonegroup={{ rgw_zonegroup }} + run_once: true + failed_when: false + notify: + - update period + +- name: Delete the realm + command: radosgw-admin realm delete --rgw-realm={{ rgw_realm }} + run_once: true + failed_when: false + notify: + - update period + diff --git a/roles/ceph-rgw/tasks/multisite/main.yml b/roles/ceph-rgw/tasks/multisite/main.yml new file mode 100644 index 000000000..44c696b90 --- /dev/null +++ b/roles/ceph-rgw/tasks/multisite/main.yml @@ -0,0 +1,19 @@ +--- +- include: checks.yml + +# Include the tasks depending on the zone type +- include: master.yml + when: "{{ rgw_zonemaster }} is defined and {{ rgw_zonemaster }}" + +- include: secondary.yml + when: "{{ rgw_zonesecondary }} is defined and {{ rgw_zonesecondary }}" + +## This is currently handled in the ceph-common ceph.conf template +## Probably should do here so we can use a restart handler for the rgw +#- name: Add zone to RGW stanza in ceph.conf +# lineinfile: +# dest: /etc/ceph/ceph.conf +# regexp: "{{ ansible_host }}" +# insertafter: "^[client.rgw.{{ ansible_host }}]" +# line: "rgw_zone={{ rgw_zonegroup }}-{{ rgw_zone }}" +# state: present diff --git a/roles/ceph-rgw/tasks/multisite/master.yml b/roles/ceph-rgw/tasks/multisite/master.yml new file mode 100644 index 000000000..ccfcf962b --- /dev/null +++ b/roles/ceph-rgw/tasks/multisite/master.yml @@ -0,0 +1,28 @@ +--- +- name: Create the realm + command: radosgw-admin realm create --rgw-realm={{ rgw_realm }} --default + run_once: true + when: ("No such file or directory" in realmcheck.stderr) and rgw_zonemaster + notify: + - update period + +- name: Create the zonegroup + command: radosgw-admin zonegroup create --rgw-zonegroup={{ rgw_zonegroup }} --endpoints=http://{{ ansible_hostname }}:8080 --master --default + run_once: true + when: ("No such file or directory" in zonegroupcheck.stderr) and rgw_zonemaster + notify: + - update period + +- name: Create the zone + command: radosgw-admin zone create --rgw-zonegroup={{ rgw_zonegroup }} --rgw-zone={{ rgw_zone }} --endpoints=http://{{ ansible_hostname }}:8080 --access-key={{ system_access_key }} --secret={{ system_secret_key }} --default --master + run_once: true + when: ("No such file or directory" in zonecheck.stderr) and rgw_zonemaster + notify: + - update period + +- name: Create the zone user + command: radosgw-admin user create --uid=zone.user --display-name="Zone User" --access-key={{ system_access_key }} --secret={{ system_secret_key }} --system + run_once: true + when: "'could not fetch user info: no user info saved' in usercheck.stderr" + notify: + - update period diff --git a/roles/ceph-rgw/tasks/multisite.yml b/roles/ceph-rgw/tasks/multisite/secondary.yml similarity index 61% rename from roles/ceph-rgw/tasks/multisite.yml rename to roles/ceph-rgw/tasks/multisite/secondary.yml index d4afe069e..3c53f63cd 100644 --- a/roles/ceph-rgw/tasks/multisite.yml +++ b/roles/ceph-rgw/tasks/multisite/secondary.yml @@ -8,7 +8,21 @@ - name: Create the realm command: radosgw-admin realm create --rgw-realm={{ rgw_realm }} --default run_once: true - when: ('No such file or directory' in realmcheck.stderr) + when: ("No such file or directory" in realmcheck.stderr) and rgw_zonemaster + notify: + - update period + +- name: Fetch the realm (Secondary) + command: radosgw-admin realm pull --url=http://{{ rgw_pullhost }}:8080 --access-key={{ system_access_key }} --secret={{ system_secret_key }} + run_once: true + when: ("No such file or directory" in realmcheck.stderr) and rgw_zonesecondary + notify: + - update period + +- name: Fetch the realm (Secondary) + command: radosgw-admin period pull --url=http://{{ rgw_pullhost }}:8080 --access-key={{ system_access_key }} --secret={{ system_secret_key }} + run_once: true + when: ("No such file or directory" in realmcheck.stderr) and rgw_zonesecondary notify: - update period @@ -21,7 +35,7 @@ - name: Create the zonegroup command: radosgw-admin zonegroup create --rgw-zonegroup={{ rgw_zonegroup }} --endpoints=http://{{ ansible_hostname }}:8080 --master --default run_once: true - when: ('No such file or directory' in zonegroupcheck.stderr) and rgw_zonemaster + when: ("No such file or directory" in zonegroupcheck.stderr) and rgw_zonemaster notify: - update period @@ -34,7 +48,7 @@ - name: Create the zone command: radosgw-admin zone create --rgw-zonegroup={{ rgw_zonegroup }} --rgw-zone={{ rgw_zone }} --endpoints=http://{{ ansible_hostname }}:8080 --access-key={{ system_access_key }} --secret={{ system_secret_key }} --default --master run_once: true - when: ('No such file or directory' in zonecheck.stderr) and rgw_zonemaster + when: ("No such file or directory" in zonecheck.stderr) and rgw_zonemaster notify: - update period @@ -50,3 +64,11 @@ when: "'could not fetch user info: no user info saved' in usercheck.stderr" notify: - update period + +#- name: Add zone to RGW stanza in ceph.conf +# lineinfile: +# dest: /etc/ceph/ceph.conf +# regexp: "{{ ansible_host }}" +# insertafter: "^[client.rgw.{{ ansible_host }}]" +# line: "rgw_zone={{ rgw_zonegroup }}-{{ rgw_zone }}" +# state: present -- 2.39.5