2016-04-27 21:17:56 +08:00
|
|
|
---
|
2017-09-15 06:48:53 +08:00
|
|
|
- name: set_fact monitor_name ansible_hostname
|
|
|
|
set_fact:
|
2017-07-29 05:02:51 +08:00
|
|
|
monitor_name: "{{ ansible_hostname }}"
|
2017-09-15 06:48:53 +08:00
|
|
|
when:
|
|
|
|
- not mon_use_fqdn
|
2017-07-29 05:02:51 +08:00
|
|
|
|
2017-09-15 06:48:53 +08:00
|
|
|
- name: set_fact monitor_name ansible_fqdn
|
|
|
|
set_fact:
|
2017-07-29 05:02:51 +08:00
|
|
|
monitor_name: "{{ ansible_fqdn }}"
|
2017-09-15 06:48:53 +08:00
|
|
|
when:
|
|
|
|
- mon_use_fqdn
|
2016-04-27 21:17:56 +08:00
|
|
|
|
2017-02-18 04:29:45 +08:00
|
|
|
# this task shouldn't run in a rolling_update situation
|
|
|
|
# because it blindly picks a mon, which may be down because
|
|
|
|
# of the rolling update
|
2016-12-06 22:59:49 +08:00
|
|
|
- name: is ceph running already?
|
2017-10-02 21:49:05 +08:00
|
|
|
command: "{{ docker_exec_cmd }} ceph --connect-timeout 3 --cluster {{ cluster }} fsid"
|
2016-12-06 22:59:49 +08:00
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
always_run: yes
|
|
|
|
register: ceph_current_fsid
|
2016-12-09 03:16:02 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2017-08-04 22:57:46 +08:00
|
|
|
when:
|
|
|
|
- not rolling_update
|
|
|
|
- groups.get(mon_group_name, []) | length > 0
|
2017-02-18 04:29:45 +08:00
|
|
|
|
2017-07-29 05:02:51 +08:00
|
|
|
# We want this check to be run only on the first node
|
|
|
|
- name: check if {{ fetch_directory }} directory exists
|
|
|
|
local_action: stat path="{{ fetch_directory }}/monitor_keyring.conf"
|
|
|
|
become: false
|
|
|
|
register: monitor_keyring_conf
|
|
|
|
run_once: true
|
|
|
|
|
2017-02-18 04:29:45 +08:00
|
|
|
# set this as a default when performing a rolling_update
|
|
|
|
# so the rest of the tasks here will succeed
|
2017-09-15 06:48:53 +08:00
|
|
|
- name: set_fact ceph_current_fsid rc 1
|
|
|
|
set_fact:
|
2017-02-18 04:29:45 +08:00
|
|
|
ceph_current_fsid:
|
|
|
|
rc: 1
|
2017-08-04 22:57:46 +08:00
|
|
|
when:
|
|
|
|
- rolling_update or groups.get(mon_group_name, []) | length == 0
|
2016-12-06 22:59:49 +08:00
|
|
|
|
2016-12-08 23:58:22 +08:00
|
|
|
- name: create a local fetch directory if it does not exist
|
|
|
|
local_action: file path={{ fetch_directory }} state=directory
|
|
|
|
changed_when: false
|
|
|
|
become: false
|
|
|
|
run_once: true
|
2017-09-15 06:48:53 +08:00
|
|
|
when:
|
|
|
|
- (cephx or generate_fsid)
|
2016-12-08 23:58:22 +08:00
|
|
|
|
2017-09-15 06:48:53 +08:00
|
|
|
- name: set_fact fsid ceph_current_fsid.stdout
|
|
|
|
set_fact:
|
2016-12-06 22:59:49 +08:00
|
|
|
fsid: "{{ ceph_current_fsid.stdout }}"
|
2017-02-18 04:29:45 +08:00
|
|
|
when:
|
|
|
|
- ceph_current_fsid.rc == 0
|
2016-12-06 22:59:49 +08:00
|
|
|
|
2017-07-29 05:02:51 +08:00
|
|
|
# Set ceph_release to ceph_stable by default
|
2017-09-15 06:48:53 +08:00
|
|
|
- name: set_fact ceph_release ceph_stable_release
|
|
|
|
set_fact:
|
2017-07-29 05:02:51 +08:00
|
|
|
ceph_release: "{{ ceph_stable_release }}"
|
2016-12-08 23:58:22 +08:00
|
|
|
|
2017-07-29 05:02:51 +08:00
|
|
|
- name: generate cluster fsid
|
|
|
|
local_action: shell python -c 'import uuid; print(str(uuid.uuid4()))' | tee {{ fetch_directory }}/ceph_cluster_uuid.conf
|
|
|
|
creates="{{ fetch_directory }}/ceph_cluster_uuid.conf"
|
|
|
|
register: cluster_uuid
|
|
|
|
become: false
|
|
|
|
when:
|
|
|
|
- generate_fsid
|
|
|
|
- ceph_current_fsid.rc != 0
|
2016-12-08 23:58:22 +08:00
|
|
|
|
2017-07-29 05:02:51 +08:00
|
|
|
- name: reuse cluster fsid when cluster is already running
|
|
|
|
local_action: shell echo {{ fsid }} | tee {{ fetch_directory }}/ceph_cluster_uuid.conf
|
|
|
|
creates="{{ fetch_directory }}/ceph_cluster_uuid.conf"
|
2016-12-16 18:36:42 +08:00
|
|
|
become: false
|
2017-09-15 06:48:53 +08:00
|
|
|
when:
|
|
|
|
- ceph_current_fsid.rc == 0
|
2016-12-08 23:58:22 +08:00
|
|
|
|
2017-07-29 05:02:51 +08:00
|
|
|
- name: read cluster fsid if it already exists
|
|
|
|
local_action: command cat {{ fetch_directory }}/ceph_cluster_uuid.conf
|
|
|
|
removes="{{ fetch_directory }}/ceph_cluster_uuid.conf"
|
|
|
|
changed_when: false
|
|
|
|
register: cluster_uuid
|
|
|
|
become: false
|
|
|
|
always_run: true
|
2017-09-15 06:48:53 +08:00
|
|
|
when:
|
|
|
|
- generate_fsid
|
2016-12-08 23:58:22 +08:00
|
|
|
|
2017-09-15 06:48:53 +08:00
|
|
|
- name: set_fact fsid
|
2017-07-29 05:02:51 +08:00
|
|
|
set_fact:
|
|
|
|
fsid: "{{ cluster_uuid.stdout }}"
|
2017-09-15 06:48:53 +08:00
|
|
|
when:
|
|
|
|
- generate_fsid
|
2017-07-29 05:02:51 +08:00
|
|
|
|
2017-09-15 06:48:53 +08:00
|
|
|
- name: set_fact mds_name ansible_hostname
|
|
|
|
set_fact:
|
2016-05-09 06:36:15 +08:00
|
|
|
mds_name: "{{ ansible_hostname }}"
|
2017-09-15 06:48:53 +08:00
|
|
|
when:
|
|
|
|
- not mds_use_fqdn
|
2016-05-09 06:36:15 +08:00
|
|
|
|
2017-09-15 06:48:53 +08:00
|
|
|
- name: set_fact mds_name ansible_fqdn
|
|
|
|
set_fact:
|
2016-05-09 06:36:15 +08:00
|
|
|
mds_name: "{{ ansible_fqdn }}"
|
2017-09-15 06:48:53 +08:00
|
|
|
when:
|
|
|
|
- mds_use_fqdn
|
2016-12-09 21:51:35 +08:00
|
|
|
|
2017-09-15 06:48:53 +08:00
|
|
|
- name: set_fact rbd_client_directory_owner ceph
|
|
|
|
set_fact:
|
2016-12-09 21:51:35 +08:00
|
|
|
rbd_client_directory_owner: ceph
|
|
|
|
when:
|
|
|
|
- rbd_client_directory_owner is not defined
|
|
|
|
or not rbd_client_directory_owner
|
|
|
|
|
2017-09-15 06:48:53 +08:00
|
|
|
- name: set_fact rbd_client_directory_group rbd_client_directory_group
|
|
|
|
set_fact:
|
2016-12-09 21:51:35 +08:00
|
|
|
rbd_client_directory_group: ceph
|
|
|
|
when:
|
|
|
|
- rbd_client_directory_group is not defined
|
|
|
|
or not rbd_client_directory_group
|
|
|
|
|
2017-09-15 06:48:53 +08:00
|
|
|
- name: set_fact rbd_client_directory_mode 0770
|
|
|
|
set_fact:
|
2016-12-09 21:51:35 +08:00
|
|
|
rbd_client_directory_mode: "0770"
|
|
|
|
when:
|
|
|
|
- rbd_client_directory_mode is not defined
|
|
|
|
or not rbd_client_directory_mode
|
2017-09-28 06:17:12 +08:00
|
|
|
|
|
|
|
- name: resolve device link(s)
|
|
|
|
command: readlink -f {{ item }}
|
|
|
|
changed_when: false
|
|
|
|
with_items: "{{ devices }}"
|
|
|
|
register: devices_prepare_canonicalize
|
|
|
|
when:
|
|
|
|
- inventory_hostname in groups.get(osd_group_name, [])
|
|
|
|
|
|
|
|
- name: set_fact build devices from resolved symlinks
|
|
|
|
set_fact:
|
|
|
|
devices: "{{ devices | default([]) + [ item.stdout ] }}"
|
|
|
|
with_items: "{{ devices_prepare_canonicalize.results }}"
|
|
|
|
when:
|
|
|
|
- inventory_hostname in groups.get(osd_group_name, [])
|
|
|
|
|
|
|
|
- name: set_fact build final devices list
|
|
|
|
set_fact:
|
|
|
|
devices: "{{ devices | reject('search','/dev/disk') | list | unique }}"
|
|
|
|
when:
|
|
|
|
- inventory_hostname in groups.get(osd_group_name, [])
|
2017-09-28 00:22:15 +08:00
|
|
|
|