2016-05-01 22:46:28 +08:00
---
# NOTE (leseb):
2018-08-20 20:41:06 +08:00
# The playbook aims to takeover a cluster that was not configured with
2016-05-16 11:51:12 +08:00
# ceph-ansible.
2016-05-01 22:46:28 +08:00
#
2016-05-16 11:51:12 +08:00
# The procedure is as follows:
2016-05-01 22:46:28 +08:00
#
# 1. Install Ansible and add your monitors and osds hosts in it. For more detailed information you can read the [Ceph Ansible Wiki](https://github.com/ceph/ceph-ansible/wiki)
# 2. Set `generate_fsid: false` in `group_vars`
2016-07-18 23:06:20 +08:00
# 3. Get your current cluster fsid with `ceph fsid` and set `fsid` accordingly in `group_vars`
2016-05-01 22:46:28 +08:00
# 4. Run the playbook called: `take-over-existing-cluster.yml` like this `ansible-playbook take-over-existing-cluster.yml`.
# 5. Eventually run Ceph Ansible to validate everything by doing: `ansible-playbook site.yml`.
2016-07-18 23:06:20 +08:00
- hosts : mons
become : True
2018-10-01 23:43:24 +08:00
tasks :
- import_role :
name : ceph-defaults
- import_role :
name : ceph-fetch-keys
2016-07-18 23:06:20 +08:00
2017-11-04 00:54:54 +08:00
- hosts :
- mons
- osds
- mdss
- rgws
- nfss
- rbdmirrors
- clients
- mgrs
- iscsi-gw
2016-05-01 22:46:28 +08:00
become : true
2018-10-01 23:43:24 +08:00
tasks :
- import_role :
name : ceph-defaults
2016-05-01 22:46:28 +08:00
2018-11-12 20:21:26 +08:00
post_tasks :
2016-05-01 22:46:28 +08:00
- name : get the name of the existing ceph cluster
2016-12-06 22:02:49 +08:00
shell : |
2020-10-02 17:23:42 +08:00
set -o pipefail;
2018-10-01 23:43:24 +08:00
basename $(grep --exclude '*.bak' -R fsid /etc/ceph/ | egrep -o '^[^.]*' | head -n 1)
2016-05-01 22:46:28 +08:00
changed_when : false
2017-06-21 00:34:46 +08:00
register : cluster_name
2016-05-01 22:46:28 +08:00
2017-06-21 00:34:46 +08:00
- name : "stat {{ cluster_name.stdout }}.conf"
2016-05-01 22:46:28 +08:00
stat :
2017-06-21 00:34:46 +08:00
path : "/etc/ceph/{{ cluster_name.stdout }}.conf"
2016-05-01 22:46:28 +08:00
register : ceph_conf_stat
2018-10-01 23:43:24 +08:00
# Creates a backup of original ceph conf file in 'cluster_name-YYYYMMDDTHHMMSS.conf.bak' format
2017-06-21 01:49:31 +08:00
- name : "make a backup of original {{ cluster_name.stdout }}.conf"
copy :
src : "/etc/ceph/{{ cluster_name.stdout }}.conf"
dest : "/etc/ceph/{{ cluster_name.stdout }}-{{ ansible_date_time.iso8601_basic_short }}.conf.bak"
remote_src : true
owner : "{{ ceph_conf_stat.stat.pw_name }}"
group : "{{ ceph_conf_stat.stat.gr_name }}"
mode : "{{ ceph_conf_stat.stat.mode }}"
2016-05-01 22:46:28 +08:00
- name : generate ceph configuration file
action : config_template
args :
2017-11-04 00:54:54 +08:00
src : "roles/ceph-config/templates/ceph.conf.j2"
2017-06-21 00:34:46 +08:00
dest : "/etc/ceph/{{ cluster_name.stdout }}.conf"
2016-05-01 22:46:28 +08:00
owner : "{{ ceph_conf_stat.stat.pw_name }}"
group : "{{ ceph_conf_stat.stat.gr_name }}"
mode : "{{ ceph_conf_stat.stat.mode }}"
config_overrides : "{{ ceph_conf_overrides }}"
config_type : ini