2016-05-01 22:46:28 +08:00
---
# NOTE (leseb):
2016-05-16 11:51:12 +08:00
# The playbook aims to takeover a cluster that was not configured with
# 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
vars_files :
2017-08-02 17:15:05 +08:00
- roles/ceph-defaults/defaults/main.yml
2016-11-23 18:14:32 +08:00
- group_vars/all.yml
2016-07-18 23:06:20 +08:00
roles :
2017-08-02 17:15:05 +08:00
- ceph-defaults
2016-07-18 23:06:20 +08:00
- ceph-fetch-keys
2016-05-01 22:46:28 +08:00
- hosts : all
become : true
tasks :
2017-08-02 17:15:05 +08:00
- include_vars : roles/ceph-defaults/defaults/main.yml
2016-11-23 18:14:32 +08:00
- include_vars : group_vars/all.yml
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 : |
2017-06-21 01:49:31 +08:00
basename $(grep --exclude '*.bak' -R fsid /etc/ceph/ | egrep -o '^[^.]*')
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
2017-06-21 01:49:31 +08:00
# Creates a backup of original ceph conf file in 'cluster_name-YYYYMMDDTHHMMSS.conf.bak' format
- 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 :
src : "roles/ceph-common/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