Add support for RGW

Signed-off-by: Sébastien Han <sebastien.han@enovance.com>
pull/243/head
Sébastien Han 2015-04-01 14:48:19 +02:00
parent d400d242f8
commit 56de5cc111
1 changed files with 125 additions and 0 deletions

View File

@ -430,3 +430,128 @@
delegate_to: "{{ item }}" delegate_to: "{{ item }}"
with_items: groups.mons[0] with_items: groups.mons[0]
when: migration_completed.stat.exists == False when: migration_completed.stat.exists == False
- hosts: rgws
serial: 1
sudo: True
vars:
backup_dir: /tmp/
tasks:
- name: Check if the node has be migrated already
stat: >
path=/var/lib/ceph/radosgw/migration_completed
register: migration_completed
ignore_errors: True
- name: Check for failed run
stat: >
path=/var/lib/ceph/{{ ansible_hostname }}.tar
register: rgw_archive_leftover
- fail: msg="Looks like an archive is already there, please remove it!"
when: migration_completed.stat.exists == False and rgw_archive_leftover.stat.exists == True
- name: Archive rados gateway configs
shell: >
tar -cpvzf - --one-file-system . /etc/ceph/* /etc/apache2/* | cat > {{ ansible_hostname }}.tar
chdir=/var/lib/ceph/
creates={{ ansible_hostname }}.tar
when: migration_completed.stat.exists == False
- name: Create backup directory
file: >
path={{ backup_dir }}/rgws-backups
state=directory
owner=root
group=root
mode=0644
delegate_to: "{{ item }}"
with_items: groups.backup[0]
when: migration_completed.stat.exists == False
- name: Scp RGWs dirs and configs
fetch: >
src=/var/lib/ceph/{{ ansible_hostname }}.tar
dest={{ backup_dir }}/rgws-backups/
flat=yes
when: migration_completed.stat.exists == False
- name: Gracefully stop the rados gateway and apache
service: >
name={{ item }}
state=stopped
with_items:
- apache2
- radosgw
when: migration_completed.stat.exists == False
- name: Wait for radosgw to be down
local_action: >
wait_for
host={{ ansible_ssh_host | default(inventory_hostname) }}
path=/tmp/radosgw.sock
state=absent
timeout=30
when: migration_completed.stat.exists == False
- name: Reboot the server
command: reboot
when: migration_completed.stat.exists == False
- name: Wait for the server to come up
local_action: >
wait_for
port=22
delay=10
timeout=3600
when: migration_completed.stat.exists == False
- name: Wait a bit to be sure that the server is ready for scp
pause: seconds=20
when: migration_completed.stat.exists == False
# NOTE (leseb): 'creates' was added in Ansible 1.6
- name: Copy and unarchive the OSD configs
unarchive: >
src={{ backup_dir }}/rgws-backups/{{ ansible_hostname }}.tar
dest=/var/lib/ceph/
copy=yes
mode=0600
creates=etc/ceph/ceph.conf
when: migration_completed.stat.exists == False
- name: Copy keys and configs
shell: {{ item }} chdir=/var/lib/ceph/
with_items:
- cp etc/ceph/* /etc/ceph/
- cp -r etc/apache2/* /etc/httpd/
when: migration_completed.stat.exists == False
- name: Start rados gateway and httpd
service: >
name={{ item }}
state=started
with_items:
- httpd
- radosgw
when: migration_completed.stat.exists == False
- name: Wait for radosgw to be up again
local_action: >
wait_for
host={{ ansible_ssh_host | default(inventory_hostname) }}
path=/tmp/radosgw.sock
state=present
timeout=30
when: migration_completed.stat.exists == False
- name: Done moving to the next rados gateway
file: >
path=/var/lib/ceph/radosgw/migration_completed
state=touch
owner=root
group=root
mode=0600
when: migration_completed.stat.exists == False