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`.
2024-02-14 18:14:02 +08:00
- name : Fetch keys
hosts : mons
become : true
2018-10-01 23:43:24 +08:00
tasks :
2024-02-14 18:14:02 +08:00
- name : Import ceph-defaults role
ansible.builtin.import_role :
2018-10-01 23:43:24 +08:00
name : ceph-defaults
2024-02-14 18:14:02 +08:00
- name : Import ceph-fetch-keys role
ansible.builtin.import_role :
2018-10-01 23:43:24 +08:00
name : ceph-fetch-keys
2016-07-18 23:06:20 +08:00
2024-02-14 18:14:02 +08:00
- name : Take over existing cluster
hosts :
- mons
- osds
- mdss
- rgws
2024-06-17 22:35:10 +08:00
- nfss
2024-02-14 18:14:02 +08:00
- rbdmirrors
- clients
- mgrs
2016-05-01 22:46:28 +08:00
become : true
2018-10-01 23:43:24 +08:00
tasks :
2024-02-14 18:14:02 +08:00
- name : Import ceph-defaults role
ansible.builtin.import_role :
2018-10-01 23:43:24 +08:00
name : ceph-defaults
2016-05-01 22:46:28 +08:00
2018-11-12 20:21:26 +08:00
post_tasks :
2024-02-14 18:14:02 +08:00
- name : Get the name of the existing ceph cluster
ansible.builtin.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
2024-02-14 18:14:02 +08:00
- name : Run stat module on Ceph configuration file
ansible.builtin.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
2024-02-14 18:14:02 +08:00
- name : Make a backup of original Ceph configuration file
ansible.builtin.copy :
2017-06-21 01:49:31 +08:00
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 }}"
2024-02-14 18:14:02 +08:00
- name : Generate ceph configuration file
2022-01-13 23:57:50 +08:00
openstack.config_template.config_template :
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