Merge pull request #826 from ceph/rolling-update

rolling-upgrade: cleanup and cosmetic
pull/871/head
Leseb 2016-07-06 11:47:11 +02:00 committed by GitHub
commit d09d331ecf
1 changed files with 130 additions and 102 deletions

View File

@ -1,6 +1,6 @@
--- ---
# This playbook does a rolling update for all the Ceph services # This playbook does a rolling update for all the Ceph services
# Change the value of serial: to adjust the number of server to be updated. # Change the value of 'serial:' to adjust the number of server to be updated.
# #
# The four roles that apply to the ceph hosts will be applied: ceph-common, # The four roles that apply to the ceph hosts will be applied: ceph-common,
# ceph-mon, ceph-osd and ceph-mds. So any changes to configuration, package updates, etc, # ceph-mon, ceph-osd and ceph-mds. So any changes to configuration, package updates, etc,
@ -9,18 +9,59 @@
# /!\ DO NOT FORGET TO CHANGE THE RELEASE VERSION FIRST! /!\ # /!\ DO NOT FORGET TO CHANGE THE RELEASE VERSION FIRST! /!\
- hosts: all - name: confirm whether user really meant to upgrade the cluster
hosts: localhost
vars_prompt:
- name: ireallymeanit
prompt: Are you sure you want to upgrade the cluster?
default: 'no'
private: no
tasks: tasks:
- debug: msg="gather facts on all hosts for following reference" - name: exit playbook, if user did not mean to upgrade cluster
fail:
msg: >
"Exiting rolling_update.yml playbook, cluster was NOT upgraded.
To upgrade the cluster, either say 'yes' on the prompt or
or use `-e ireallymeanit=yes` on the command line when
invoking the playbook"
when: ireallymeanit != 'yes'
- hosts:
- mons
- osds
- mdss
- rgws
become: True
tasks:
- debug: msg="gather facts on all Ceph hosts for following reference"
- name: check if sysvinit
stat:
path: /etc/rc?.d/S??ceph
follow: yes
register: is_sysvinit
- name: check if upstart
stat:
path: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/upstart
register: is_upstart
- name: check if systemd
command: grep -sq systemd /proc/1/comm
register: is_systemd
- hosts: mons - hosts: mons
serial: 1 serial: 1
sudo: True become: True
vars: vars:
upgrade_ceph_packages: True upgrade_ceph_packages: True
mon_group_name: mons
pre_tasks: pre_tasks:
- name: Compress the store as much as possible - name: compress the store as much as possible
command: ceph tell mon.{{ ansible_hostname }} compact command: ceph tell mon.{{ ansible_hostname }} compact
roles: roles:
@ -28,50 +69,33 @@
- ceph-mon - ceph-mon
post_tasks: post_tasks:
- name: Check if sysvinit - name: restart ceph mons with upstart
stat: > service:
path=/etc/rc?.d/S??ceph name: ceph-mon
follow=yes state: restarted
register: monsysvinit args: id={{ ansible_hostname }}
when: is_upstart.stat.exists == True
- name: Check if upstart - name: restart ceph mons with sysvinit
stat: > service:
path=/var/lib/ceph/mon/ceph-{{ ansible_hostname }}/upstart name: ceph
register: monupstart state: restarted
when: is_sysvinit.stat.exists == True
- name: Restart the monitor after compaction (Upstart) - name: restart ceph mons with systemd
service: > service:
name=ceph-mon name: ceph-mon@{{ ansible_hostname }}
state=restarted state: restarted
args=id={{ ansible_hostname }} enabled: yes
when: monupstart.stat.exists == True when: is_systemd
- name: Restart the monitor after compaction (Sysvinit)
service: >
name=ceph
state=restarted
when: monsysvinit.stat.exists == True
- name: restart monitor(s)
service: >
name=ceph
state=restarted
args=mon
when: not ansible_os_family == "RedHat"
- name: restart monitor(s)
service: >
name=ceph
state=restarted
when: ansible_os_family == "RedHat"
- name: select a running monitor - name: select a running monitor
set_fact: mon_host={{ item }} set_fact: mon_host={{ item }}
with_items: groups.mons with_items: groups.mons
when: item != inventory_hostname when: item != inventory_hostname
- name: Waiting for the monitor to join the quorum... - name: waiting for the monitor to join the quorum...
shell: > shell: |
ceph -s | grep monmap | sed 's/.*quorum//' | egrep -sq {{ ansible_hostname }} ceph -s | grep monmap | sed 's/.*quorum//' | egrep -sq {{ ansible_hostname }}
register: result register: result
until: result.rc == 0 until: result.rc == 0
@ -82,12 +106,13 @@
- hosts: osds - hosts: osds
serial: 1 serial: 1
sudo: True become: True
vars: vars:
upgrade_ceph_packages: True upgrade_ceph_packages: True
osd_group_name: osds
pre_tasks: pre_tasks:
- name: Set OSD flags - name: set osd flags
command: ceph osd set {{ item }} command: ceph osd set {{ item }}
with_items: with_items:
- noout - noout
@ -100,30 +125,33 @@
- ceph-osd - ceph-osd
post_tasks: post_tasks:
- name: Check if sysvinit - name: get osd numbers
shell: stat /var/lib/ceph/osd/ceph-*/sysvinit shell: "if [ -d /var/lib/ceph/osd ] ; then ls /var/lib/ceph/osd | cut -d '-' -f 2 ; fi"
register: osdsysvinit register: osd_ids
failed_when: false changed_when: false
- name: Check if upstart - name: restart ceph osds (upstart)
shell: stat /var/lib/ceph/osd/ceph-*/upstart service:
register: osdupstart name: ceph-osd-all
failed_when: false state: restarted
when: is_upstart.stat.exists == True
- name: Gracefully stop the OSDs (Upstart) - name: restart ceph osds (sysvinit)
service: > service:
name=ceph-osd-all name: ceph
state=restarted state: restarted
when: osdupstart.rc == 0 when: is_sysvinit.stat.exists == True
- name: Gracefully stop the OSDs (Sysvinit) - name: restart ceph osds (systemd)
service: > service:
name=ceph name: ceph-osd@{{item}}
state=restarted state: restarted
when: osdsysvinit.rc == 0 enabled: yes
with_items: "{{ osd_ids.stdout_lines }}"
when: is_systemd
- name: Waiting for clean PGs... - name: waiting for clean pgs...
shell: > shell: |
test "$(ceph pg stat | sed 's/^.*pgs://;s/active+clean.*//;s/ //')" -eq "$(ceph pg stat | sed 's/pgs.*//;s/^.*://;s/ //')" && ceph health | egrep -sq "HEALTH_OK|HEALTH_WARN" test "$(ceph pg stat | sed 's/^.*pgs://;s/active+clean.*//;s/ //')" -eq "$(ceph pg stat | sed 's/pgs.*//;s/^.*://;s/ //')" && ceph health | egrep -sq "HEALTH_OK|HEALTH_WARN"
register: result register: result
until: result.rc == 0 until: result.rc == 0
@ -131,7 +159,7 @@
delay: 10 delay: 10
delegate_to: "{{ groups.mons[0] }}" delegate_to: "{{ groups.mons[0] }}"
- name: Unset OSD flags - name: unset osd flags
command: ceph osd unset {{ item }} command: ceph osd unset {{ item }}
with_items: with_items:
- noout - noout
@ -142,64 +170,64 @@
- hosts: mdss - hosts: mdss
serial: 1 serial: 1
sudo: True become: True
vars: vars:
upgrade_ceph_packages: True upgrade_ceph_packages: True
mds_group_name: mdss
roles: roles:
- ceph-common - ceph-common
- ceph-mds - ceph-mds
post_tasks: post_tasks:
- name: Check if sysvinit - name: restart ceph mdss with upstart
stat: > service:
path=/var/lib/ceph/mon/ceph-{{ ansible_hostname }}/sysvinit name: ceph-mds
register: mdssysvinit state: restarted
args: id={{ ansible_hostname }}
when: is_upstart.stat.exists == True
- name: Check if upstart - name: restart ceph mdss with sysvinit
stat: > service:
path=/var/lib/ceph/mon/ceph-{{ ansible_hostname }}/upstart name: ceph
register: mdsupstart state: restarted
args: mds
- name: Restart the metadata server (Upstart) when: is_sysvinit.stat.exists == True
service: >
name=ceph-mds
state=restarted
args=id={{ ansible_hostname }}
when: mdsupstart.stat.exists == True
- name: Restart the metadata server (Sysvinit)
service: >
name=ceph
state=restarted
args=mds
when: mdssysvinit.stat.exists == True
- name: restart ceph mdss with systemd
service:
name: ceph-mds@{{ ansible_hostname }}
state: restarted
enabled: yes
when: is_systemd
- hosts: rgws - hosts: rgws
serial: 1 serial: 1
sudo: True become: True
vars: vars:
upgrade_ceph_packages: True upgrade_ceph_packages: True
rgw_group_name: rgws
roles: roles:
- ceph-common - ceph-common
- ceph-rgw - ceph-rgw
post_tasks: post_tasks:
- name: restart rados gateway server(s) - name: restart ceph rgws with systemd
service: > service:
name={{ item }} name: ceph-radosgw@rgw.{{ ansible_hostname }}
state=restarted state: restarted
with_items: enabled: yes
- radosgw when: is_systemd
when: radosgw_frontend == 'civetweb'
- name: restart ceph rgws with sysvinit
service:
name: radosgw
state: restarted
when: ansible_os_family != 'RedHat'
- name: restart rados gateway server(s) - name: restart rados gateway server(s)
service: > service:
name={{ item }} name: ceph-radosgw
state=restarted state: restarted
with_items: when: ansible_os_family != 'RedHat'
- apache2
- radosgw
when: radosgw_frontend == 'apache'