2014-03-04 02:08:51 +08:00
|
|
|
---
|
|
|
|
# This playbook does a rolling update for all the Ceph services
|
2016-06-01 00:13:47 +08:00
|
|
|
# Change the value of 'serial:' to adjust the number of server to be updated.
|
2014-03-04 02:08:51 +08:00
|
|
|
#
|
2014-07-08 21:39:42 +08:00
|
|
|
# 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,
|
2014-03-04 02:08:51 +08:00
|
|
|
# will be applied as part of the rolling update process.
|
|
|
|
#
|
|
|
|
|
|
|
|
# /!\ DO NOT FORGET TO CHANGE THE RELEASE VERSION FIRST! /!\
|
|
|
|
|
2016-06-01 00:13:47 +08:00
|
|
|
- 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:
|
|
|
|
- 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'
|
|
|
|
|
2016-10-26 05:56:58 +08:00
|
|
|
- name: gather facts and check the init system
|
|
|
|
vars:
|
|
|
|
mon_group_name: mons
|
|
|
|
osd_group_name: osds
|
|
|
|
mds_group_name: mdss
|
|
|
|
rgw_group_name: rgws
|
2016-10-06 19:56:37 +08:00
|
|
|
|
2016-10-26 05:56:58 +08:00
|
|
|
hosts:
|
|
|
|
- "{{ mon_group_name }}"
|
|
|
|
- "{{ osd_group_name }}"
|
|
|
|
- "{{ mds_group_name }}"
|
|
|
|
- "{{ rgw_group_name }}"
|
2016-06-15 23:08:15 +08:00
|
|
|
|
|
|
|
become: True
|
2015-04-15 03:50:39 +08:00
|
|
|
tasks:
|
2016-06-15 23:08:15 +08:00
|
|
|
- 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
|
|
|
|
|
2015-04-15 03:50:39 +08:00
|
|
|
|
2016-10-06 19:56:37 +08:00
|
|
|
- name: upgrade ceph mon cluster
|
|
|
|
|
2016-01-29 23:54:59 +08:00
|
|
|
vars:
|
2016-11-01 19:39:21 +08:00
|
|
|
mon_group_name: mons
|
|
|
|
restapi_group_name: restapis
|
2016-10-03 17:24:59 +08:00
|
|
|
health_mon_check_retries: 5
|
|
|
|
health_mon_check_delay: 10
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2016-10-06 19:56:37 +08:00
|
|
|
hosts:
|
|
|
|
- "{{ mon_group_name }}"
|
|
|
|
|
|
|
|
serial: 1
|
|
|
|
become: True
|
|
|
|
|
2014-03-04 02:08:51 +08:00
|
|
|
roles:
|
2015-03-27 01:51:11 +08:00
|
|
|
- ceph-common
|
|
|
|
- ceph-mon
|
|
|
|
|
2014-03-04 02:08:51 +08:00
|
|
|
post_tasks:
|
2016-10-25 16:28:53 +08:00
|
|
|
- include_vars: roles/ceph-common/defaults/main.yml
|
|
|
|
- include_vars: roles/ceph-mon/defaults/main.yml
|
|
|
|
- include_vars: roles/ceph-restapi/defaults/main.yml
|
|
|
|
- include_vars: group_vars/all
|
2016-10-06 19:56:37 +08:00
|
|
|
failed_when: false
|
2016-11-01 19:39:21 +08:00
|
|
|
- include_vars: group_vars/{{ mon_group_name }}
|
2016-10-06 19:56:37 +08:00
|
|
|
failed_when: false
|
2016-11-01 19:39:21 +08:00
|
|
|
- include_vars: group_vars/{{ restapi_group_name }}
|
2016-10-06 19:56:37 +08:00
|
|
|
failed_when: false
|
|
|
|
|
2016-06-15 23:08:15 +08:00
|
|
|
- name: restart ceph mons with upstart
|
2016-06-01 00:13:47 +08:00
|
|
|
service:
|
|
|
|
name: ceph-mon
|
|
|
|
state: restarted
|
|
|
|
args: id={{ ansible_hostname }}
|
2016-06-15 23:08:15 +08:00
|
|
|
when: is_upstart.stat.exists == True
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2016-06-15 23:08:15 +08:00
|
|
|
- name: restart ceph mons with sysvinit
|
2016-06-01 00:13:47 +08:00
|
|
|
service:
|
|
|
|
name: ceph
|
|
|
|
state: restarted
|
2016-06-15 23:08:15 +08:00
|
|
|
when: is_sysvinit.stat.exists == True
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2016-06-15 23:08:15 +08:00
|
|
|
- name: restart ceph mons with systemd
|
2016-06-01 00:13:47 +08:00
|
|
|
service:
|
2016-06-15 23:08:15 +08:00
|
|
|
name: ceph-mon@{{ ansible_hostname }}
|
2016-06-01 00:13:47 +08:00
|
|
|
state: restarted
|
2016-06-15 23:08:15 +08:00
|
|
|
enabled: yes
|
|
|
|
when: is_systemd
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2015-04-17 10:04:52 +08:00
|
|
|
- name: select a running monitor
|
|
|
|
set_fact: mon_host={{ item }}
|
|
|
|
with_items: groups.mons
|
|
|
|
when: item != inventory_hostname
|
|
|
|
|
2016-06-01 00:13:47 +08:00
|
|
|
- name: waiting for the monitor to join the quorum...
|
|
|
|
shell: |
|
2016-09-06 22:29:00 +08:00
|
|
|
ceph -s --cluster {{ cluster }} | grep monmap | sed 's/.*quorum//' | egrep -sq {{ ansible_hostname }}
|
2015-03-27 01:51:11 +08:00
|
|
|
register: result
|
|
|
|
until: result.rc == 0
|
2016-10-03 17:24:59 +08:00
|
|
|
retries: "{{ health_mon_check_retries }}"
|
|
|
|
delay: "{{ health_mon_check_delay }}"
|
2015-04-17 10:04:52 +08:00
|
|
|
delegate_to: "{{ mon_host }}"
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2014-03-04 02:08:51 +08:00
|
|
|
|
2016-10-06 19:56:37 +08:00
|
|
|
- name: upgrade ceph osds cluster
|
|
|
|
|
2016-01-29 23:54:59 +08:00
|
|
|
vars:
|
2016-06-01 00:13:47 +08:00
|
|
|
osd_group_name: osds
|
2016-10-03 17:24:59 +08:00
|
|
|
health_osd_check_retries: 10
|
|
|
|
health_osd_check_delay: 10
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2016-10-06 19:56:37 +08:00
|
|
|
hosts:
|
|
|
|
- "{{ osd_group_name }}"
|
|
|
|
|
|
|
|
serial: 1
|
|
|
|
become: True
|
|
|
|
|
2015-03-27 01:51:11 +08:00
|
|
|
pre_tasks:
|
2016-10-25 16:28:53 +08:00
|
|
|
- include_vars: roles/ceph-common/defaults/main.yml
|
|
|
|
- include_vars: roles/ceph-osd/defaults/main.yml
|
|
|
|
- include_vars: group_vars/all
|
2016-10-06 19:56:37 +08:00
|
|
|
failed_when: false
|
2016-11-01 19:39:21 +08:00
|
|
|
- include_vars: group_vars/{{ osd_group_name }}
|
2016-10-06 19:56:37 +08:00
|
|
|
failed_when: false
|
|
|
|
|
2016-06-01 00:13:47 +08:00
|
|
|
- name: set osd flags
|
2016-09-06 22:29:00 +08:00
|
|
|
command: ceph osd set {{ item }} --cluster {{ cluster }}
|
2015-04-28 01:08:05 +08:00
|
|
|
with_items:
|
|
|
|
- noout
|
|
|
|
- noscrub
|
|
|
|
- nodeep-scrub
|
2015-04-14 21:49:53 +08:00
|
|
|
delegate_to: "{{ groups.mons[0] }}"
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2014-03-04 02:08:51 +08:00
|
|
|
roles:
|
2015-03-27 01:51:11 +08:00
|
|
|
- ceph-common
|
|
|
|
- ceph-osd
|
|
|
|
|
2014-03-04 02:08:51 +08:00
|
|
|
post_tasks:
|
2016-10-25 16:28:53 +08:00
|
|
|
- include_vars: roles/ceph-common/defaults/main.yml
|
|
|
|
- include_vars: roles/ceph-osd/defaults/main.yml
|
|
|
|
- include_vars: group_vars/all
|
2016-10-06 19:56:37 +08:00
|
|
|
failed_when: false
|
2016-11-01 19:39:21 +08:00
|
|
|
- include_vars: group_vars/{{ osd_group_name }}
|
2016-10-06 19:56:37 +08:00
|
|
|
failed_when: false
|
|
|
|
|
2016-06-15 23:08:15 +08:00
|
|
|
- name: get osd numbers
|
|
|
|
shell: "if [ -d /var/lib/ceph/osd ] ; then ls /var/lib/ceph/osd | cut -d '-' -f 2 ; fi"
|
|
|
|
register: osd_ids
|
|
|
|
changed_when: false
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2016-06-15 23:08:15 +08:00
|
|
|
- name: restart ceph osds (upstart)
|
2016-06-01 00:13:47 +08:00
|
|
|
service:
|
|
|
|
name: ceph-osd-all
|
|
|
|
state: restarted
|
2016-06-15 23:08:15 +08:00
|
|
|
when: is_upstart.stat.exists == True
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2016-06-15 23:08:15 +08:00
|
|
|
- name: restart ceph osds (sysvinit)
|
2016-06-01 00:13:47 +08:00
|
|
|
service:
|
|
|
|
name: ceph
|
|
|
|
state: restarted
|
2016-06-15 23:08:15 +08:00
|
|
|
when: is_sysvinit.stat.exists == True
|
|
|
|
|
|
|
|
- name: restart ceph osds (systemd)
|
|
|
|
service:
|
|
|
|
name: ceph-osd@{{item}}
|
|
|
|
state: restarted
|
|
|
|
enabled: yes
|
|
|
|
with_items: "{{ osd_ids.stdout_lines }}"
|
|
|
|
when: is_systemd
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2016-06-01 00:13:47 +08:00
|
|
|
- name: waiting for clean pgs...
|
|
|
|
shell: |
|
2016-09-06 22:29:00 +08:00
|
|
|
test "$(ceph pg stat --cluster {{ cluster }} | sed 's/^.*pgs://;s/active+clean.*//;s/ //')" -eq "$(ceph pg stat --cluster {{ cluster }} | sed 's/pgs.*//;s/^.*://;s/ //')" && ceph health --cluster {{ cluster }} | egrep -sq "HEALTH_OK|HEALTH_WARN"
|
2015-03-27 01:51:11 +08:00
|
|
|
register: result
|
|
|
|
until: result.rc == 0
|
2016-10-03 17:24:59 +08:00
|
|
|
retries: "{{ health_osd_check_retries }}"
|
|
|
|
delay: "{{ health_osd_check_delay }}"
|
2015-04-14 21:49:53 +08:00
|
|
|
delegate_to: "{{ groups.mons[0] }}"
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2016-06-01 00:13:47 +08:00
|
|
|
- name: unset osd flags
|
2016-09-06 22:29:00 +08:00
|
|
|
command: ceph osd unset {{ item }} --cluster {{ cluster }}
|
2015-04-28 01:08:05 +08:00
|
|
|
with_items:
|
|
|
|
- noout
|
|
|
|
- noscrub
|
|
|
|
- nodeep-scrub
|
2015-04-14 21:49:53 +08:00
|
|
|
delegate_to: "{{ groups.mons[0] }}"
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2014-03-04 02:08:51 +08:00
|
|
|
|
2016-10-06 19:56:37 +08:00
|
|
|
- name: upgrade ceph mdss cluster
|
|
|
|
|
2016-01-29 23:54:59 +08:00
|
|
|
vars:
|
2016-06-01 00:13:47 +08:00
|
|
|
mds_group_name: mdss
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2016-10-06 19:56:37 +08:00
|
|
|
hosts:
|
|
|
|
- "{{ mds_group_name }}"
|
|
|
|
|
|
|
|
serial: 1
|
|
|
|
become: True
|
|
|
|
|
2014-03-04 02:08:51 +08:00
|
|
|
roles:
|
2015-03-27 01:51:11 +08:00
|
|
|
- ceph-common
|
|
|
|
- ceph-mds
|
|
|
|
|
2014-03-04 02:08:51 +08:00
|
|
|
post_tasks:
|
2016-10-25 16:28:53 +08:00
|
|
|
- include_vars: roles/ceph-common/defaults/main.yml
|
|
|
|
- include_vars: roles/ceph-mds/defaults/main.yml
|
|
|
|
- include_vars: group_vars/all
|
2016-10-06 19:56:37 +08:00
|
|
|
failed_when: false
|
2016-11-01 19:39:21 +08:00
|
|
|
- include_vars: group_vars/{{ mds_group_name }}
|
2016-10-06 19:56:37 +08:00
|
|
|
failed_when: false
|
|
|
|
|
2016-06-15 23:08:15 +08:00
|
|
|
- name: restart ceph mdss with upstart
|
2016-06-01 00:13:47 +08:00
|
|
|
service:
|
|
|
|
name: ceph-mds
|
|
|
|
state: restarted
|
|
|
|
args: id={{ ansible_hostname }}
|
2016-06-15 23:08:15 +08:00
|
|
|
when: is_upstart.stat.exists == True
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2016-06-15 23:08:15 +08:00
|
|
|
- name: restart ceph mdss with sysvinit
|
2016-06-01 00:13:47 +08:00
|
|
|
service:
|
|
|
|
name: ceph
|
|
|
|
state: restarted
|
|
|
|
args: mds
|
2016-06-15 23:08:15 +08:00
|
|
|
when: is_sysvinit.stat.exists == True
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2016-06-15 23:08:15 +08:00
|
|
|
- name: restart ceph mdss with systemd
|
|
|
|
service:
|
|
|
|
name: ceph-mds@{{ ansible_hostname }}
|
|
|
|
state: restarted
|
|
|
|
enabled: yes
|
|
|
|
when: is_systemd
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2016-10-06 19:56:37 +08:00
|
|
|
|
|
|
|
- name: upgrade ceph rgws cluster
|
|
|
|
|
2016-01-29 23:54:59 +08:00
|
|
|
vars:
|
2016-06-01 00:13:47 +08:00
|
|
|
rgw_group_name: rgws
|
2015-03-27 01:51:11 +08:00
|
|
|
|
2016-10-06 19:56:37 +08:00
|
|
|
hosts:
|
|
|
|
- "{{ rgw_group_name }}"
|
|
|
|
|
|
|
|
serial: 1
|
|
|
|
become: True
|
|
|
|
|
2015-03-27 01:51:11 +08:00
|
|
|
roles:
|
|
|
|
- ceph-common
|
2015-07-25 00:14:59 +08:00
|
|
|
- ceph-rgw
|
2015-03-27 01:51:11 +08:00
|
|
|
|
|
|
|
post_tasks:
|
2016-10-25 16:28:53 +08:00
|
|
|
- include_vars: roles/ceph-common/defaults/main.yml
|
|
|
|
- include_vars: roles/ceph-rgw/defaults/main.yml
|
|
|
|
- include_vars: group_vars/all
|
2016-10-06 19:56:37 +08:00
|
|
|
failed_when: false
|
2016-11-01 19:39:21 +08:00
|
|
|
- include_vars: group_vars/{{ rgw_group_name }}
|
2016-10-06 19:56:37 +08:00
|
|
|
failed_when: false
|
|
|
|
|
2016-06-15 23:08:15 +08:00
|
|
|
- name: restart ceph rgws with systemd
|
2016-06-01 00:13:47 +08:00
|
|
|
service:
|
2016-06-15 23:08:15 +08:00
|
|
|
name: ceph-radosgw@rgw.{{ ansible_hostname }}
|
2016-06-01 00:13:47 +08:00
|
|
|
state: restarted
|
2016-06-15 23:08:15 +08:00
|
|
|
enabled: yes
|
|
|
|
when: is_systemd
|
|
|
|
|
|
|
|
- name: restart ceph rgws with sysvinit
|
|
|
|
service:
|
|
|
|
name: radosgw
|
|
|
|
state: restarted
|
|
|
|
when: ansible_os_family != 'RedHat'
|
2015-03-27 01:51:11 +08:00
|
|
|
|
|
|
|
- name: restart rados gateway server(s)
|
2016-06-01 00:13:47 +08:00
|
|
|
service:
|
2016-06-15 23:08:15 +08:00
|
|
|
name: ceph-radosgw
|
2016-06-01 00:13:47 +08:00
|
|
|
state: restarted
|
2016-06-15 23:08:15 +08:00
|
|
|
when: ansible_os_family != 'RedHat'
|