--- # Copyright 2021 Red Hat, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - name: Gather distribution facts if they do not exist ansible.builtin.setup: gather_subset: distribution when: ansible_facts['distribution_major_version'] is not defined tags: - always - name: List Ceph daemon instances on this host ansible.builtin.command: cmd: "{{ cifmw_cephadm_bin }} ls --no-detail" register: cephadm_ls become: true tags: - cephadm_bootstrap - name: Ensure cifmw_cephadm_fsid variable is set if none was provided when: cifmw_cephadm_fsid is not defined or cifmw_cephadm_fsid | length == 0 block: - name: Set list of found FSIDs when: - cephadm_ls is defined - cephadm_ls.stdout is defined - cephadm_ls.stdout != '[]' ansible.builtin.set_fact: cifmw_cephadm_fsid_list: |- {{ cephadm_ls.stdout | from_json | map(attribute='fsid') | sort | unique }} - name: Fail if >1 FSID was discovered when: cifmw_cephadm_fsid_list | length > 1 ansible.builtin.fail: msg: | Multiple FSIDs were found. This Ansible role does not support management of multiple Ceph clusters on one host. - name: Set FSID to the discovered value when: cifmw_cephadm_fsid_list | length == 1 ansible.builtin.set_fact: cifmw_cephadm_fsid: "{{ cifmw_cephadm_fsid_list[0] }}" - name: Set random cifmw_cephadm_fsid if no running ceph containers were found when: cifmw_cephadm_fsid_list | length == 0 ansible.builtin.set_fact: cifmw_cephadm_fsid: "{{ 99999999 | random | to_uuid | lower }}" - name: Set first monitor IP if it was not passed ansible.builtin.set_fact: cifmw_cephadm_first_mon_ip: "{{ ansible_host }}" when: cifmw_cephadm_first_mon_ip is not defined or (cifmw_cephadm_first_mon_ip is defined and cifmw_cephadm_first_mon_ip | length == 0) - name: Ensure cifmw_cephadm_config_home (e.g. /etc/ceph) exists ansible.builtin.file: path: "{{ cifmw_cephadm_config_home }}" state: directory mode: "0755" become: true - name: Ensure specs directory exists ansible.builtin.file: path: "/home/{{ cifmw_cephadm_ssh_user }}/specs" owner: "{{ cifmw_cephadm_ssh_user }}" group: "{{ cifmw_cephadm_ssh_user }}" mode: '0755' state: directory become: true - name: Stat spec file on ansible host ansible.builtin.stat: path: "{{ cifmw_cephadm_spec_ansible_host }}" register: cifmw_cephadm_spec_stat_host delegate_to: localhost become: true - name: Push cifmw_cephadm_spec to bootstrap node if spec file exsits ansible.builtin.copy: src: "{{ cifmw_cephadm_spec_ansible_host }}" dest: "{{ cifmw_cephadm_spec }}" owner: "{{ cifmw_cephadm_ssh_user }}" group: "{{ cifmw_cephadm_ssh_user }}" mode: '0644' become: true when: cifmw_cephadm_spec_stat_host.stat.exists - name: "Was a cifmw_cephadm_bootstrap_conf passed?" when: - cifmw_cephadm_bootstrap_conf is defined - cifmw_cephadm_bootstrap_conf | length > 0 block: - name: Stat cifmw_cephadm_bootstrap_conf file ansible.builtin.stat: path: "{{ cifmw_cephadm_bootstrap_conf }}" register: stat_bootstrap_conf become: true delegate_to: localhost ignore_errors: true - name: Push it to cifmw_cephadm_assimilate_conf on bootstrap node ansible.builtin.copy: src: "{{ cifmw_cephadm_bootstrap_conf }}" dest: "{{ cifmw_cephadm_assimilate_conf }}" owner: "{{ cifmw_cephadm_ssh_user }}" group: "{{ cifmw_cephadm_ssh_user }}" mode: '0644' become: true when: stat_bootstrap_conf.stat.exists