--- # 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 don't exist setup: gather_subset: distribution when: ansible_facts['distribution_major_version'] is not defined tags: - always - name: Install cephadm package become: true package: name: cephadm state: latest releasever: "{{ ansible_facts['distribution_major_version'] }}" when: - tripleo_cephadm_predeployed | bool - name: Stat cephadm file stat: path: "{{ tripleo_cephadm_bin }}" register: stat_cephadm become: true ignore_errors: true - name: Fail if cephadm is not available fail: msg: "{{ tripleo_cephadm_bin }} does not exist" when: not stat_cephadm.stat.exists - name: List Ceph daemon instances on this host shell: "{{ tripleo_cephadm_bin }} ls --no-detail" register: cephadm_ls become: true tags: - cephadm_bootstrap - name: Ensure tripleo_cephadm_fsid variable is set if none was provided block: - name: Set list of found FSIDs set_fact: tripleo_cephadm_fsid_list: "{{ cephadm_ls.stdout | from_json | map(attribute='fsid') | sort | unique }}" when: - cephadm_ls is defined - cephadm_ls.stdout is defined - cephadm_ls.stdout != '[]' - name: Fail if >1 FSID was discovered fail: msg: | Multiple FSIDs were found. This Ansible role does not support management of multiple Ceph clusters on one host. when: tripleo_cephadm_fsid_list | length > 1 - name: Set FSID to the discovered value set_fact: tripleo_cephadm_fsid: "{{ tripleo_cephadm_fsid_list[0] }}" when: tripleo_cephadm_fsid_list | length == 1 - name: Set random tripleo_cephadm_fsid if no running ceph containers were found set_fact: tripleo_cephadm_fsid: "{{ 99999999 | random | to_uuid | lower }}" when: tripleo_cephadm_fsid_list | length == 0 when: tripleo_cephadm_fsid is not defined or (tripleo_cephadm_fsid is defined and tripleo_cephadm_fsid | length == 0) - name: Set first monitor IP if it was not passed set_fact: tripleo_cephadm_first_mon_ip: "{{ ansible_host }}" when: tripleo_cephadm_first_mon_ip is not defined or (tripleo_cephadm_first_mon_ip is defined and tripleo_cephadm_first_mon_ip | length == 0) - name: Ensure tripleo_cephadm_config_home (e.g. /etc/ceph) exists file: path: "{{ tripleo_cephadm_config_home }}" state: directory become: true - name: Ensure specs directory exists file: path: "/home/{{ tripleo_cephadm_ssh_user }}/specs" owner: "{{ tripleo_cephadm_ssh_user }}" group: "{{ tripleo_cephadm_ssh_user }}" mode: '0755' state: directory become: true - name: Stat spec file on ansible host stat: path: "{{ tripleo_cephadm_spec_ansible_host }}" register: tripleo_cephadm_spec_stat_host delegate_to: localhost - name: push tripleo_cephadm_spec to bootstrap node if spec file exsits copy: src: "{{ tripleo_cephadm_spec_ansible_host }}" dest: "{{ tripleo_cephadm_spec }}" owner: "{{ tripleo_cephadm_ssh_user }}" group: "{{ tripleo_cephadm_ssh_user }}" mode: '0644' become: true when: tripleo_cephadm_spec_stat_host.stat.exists - name: was a tripleo_cephadm_bootstrap_conf passed? when: - tripleo_cephadm_bootstrap_conf is defined - tripleo_cephadm_bootstrap_conf | length > 0 block: - name: stat tripleo_cephadm_bootstrap_conf file stat: path: "{{ tripleo_cephadm_bootstrap_conf }}" register: stat_bootstrap_conf become: true delegate_to: localhost ignore_errors: true - name: push it to tripleo_cephadm_assimilate_conf on bootstrap node copy: src: "{{ tripleo_cephadm_bootstrap_conf }}" dest: "{{ tripleo_cephadm_assimilate_conf }}" owner: "{{ tripleo_cephadm_ssh_user }}" group: "{{ tripleo_cephadm_ssh_user }}" mode: '0644' become: true when: stat_bootstrap_conf.stat.exists - name: generate tripleo_cephadm_assimilate_conf on bootstrap node action: config_template args: src: "ceph.conf.j2" dest: "{{ tripleo_cephadm_assimilate_conf }}" owner: "{{ tripleo_cephadm_uid }}" group: "{{ tripleo_cephadm_uid }}" mode: "0644" config_overrides: "{{ tripleo_cephadm_conf_overrides }}" config_type: ini become: true when: - tripleo_cephadm_bootstrap_conf is not defined or tripleo_cephadm_bootstrap_conf | length == 0