ceph-ansible/roles/ceph-defaults/tasks/facts.yml

111 lines
3.0 KiB
YAML
Raw Normal View History

---
- set_fact:
monitor_name: "{{ ansible_hostname }}"
when: not mon_use_fqdn
- set_fact:
monitor_name: "{{ ansible_fqdn }}"
when: mon_use_fqdn
# 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
- name: is ceph running already?
command: ceph --connect-timeout 3 --cluster {{ cluster }} fsid
changed_when: false
failed_when: false
always_run: yes
register: ceph_current_fsid
delegate_to: "{{ groups[mon_group_name][0] }}"
when: not rolling_update
# 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
# set this as a default when performing a rolling_update
# so the rest of the tasks here will succeed
- set_fact:
ceph_current_fsid:
rc: 1
when: rolling_update
- 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
when: cephx or generate_fsid
- set_fact:
fsid: "{{ ceph_current_fsid.stdout }}"
when:
- ceph_current_fsid.rc == 0
# Set ceph_release to ceph_stable by default
- set_fact:
ceph_release: "{{ ceph_stable_release }}"
- 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
- 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"
become: false
when: ceph_current_fsid.rc == 0
- 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
when: generate_fsid
- name: set fsid fact when generate_fsid = true
set_fact:
fsid: "{{ cluster_uuid.stdout }}"
when: generate_fsid
- name: set docker_exec_cmd fact
set_fact:
docker_exec_cmd: "docker exec ceph-mon-{{ ansible_hostname }}"
when: containerized_deployment
- set_fact:
mds_name: "{{ ansible_hostname }}"
when: not mds_use_fqdn
- set_fact:
mds_name: "{{ ansible_fqdn }}"
when: mds_use_fqdn
- set_fact:
rbd_client_directory_owner: ceph
when:
- rbd_client_directory_owner is not defined
or not rbd_client_directory_owner
- set_fact:
rbd_client_directory_group: ceph
when:
- rbd_client_directory_group is not defined
or not rbd_client_directory_group
- set_fact:
rbd_client_directory_mode: "0770"
when:
- rbd_client_directory_mode is not defined
or not rbd_client_directory_mode