tripleo-ansible/tripleo_ansible/roles/tripleo_cephadm/tasks/bootstrap.yaml

82 lines
3.0 KiB
YAML

---
# 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: Add spec to necessary file list when using spec to bootstrap
set_fact:
tripleo_cephadm_bootstrap_files: "{{ tripleo_cephadm_bootstrap_files + [ tripleo_cephadm_spec ] }}"
when: tripleo_cephadm_spec_on_bootstrap
- name: Stat necessary files to bootstrap with cephadm
stat:
path: "{{ item }}"
register: tripleo_cephadm_bootstrap_files_stat
become: true
loop: "{{ tripleo_cephadm_bootstrap_files }}"
- name: Fail if necessary files are missing
fail:
msg: "{{ item.invocation.module_args.path }} does not exist"
loop: "{{ tripleo_cephadm_bootstrap_files_stat.results | list }}"
when: not item.stat.exists
- name: Stat pre ceph conf file in case we should bootrap with it
stat:
path: "{{ tripleo_cephadm_bootstrap_conf }}"
register: tripleo_cephadm_bootstrap_conf_stat
become: true
# cephadm_ls should be registered by pre.yaml
- name: Bootstrap Ceph if there are no running Ceph Daemons
block:
# items to add
# --registry-json
- name: Run cephadm bootstrap
shell: |
{{ tripleo_cephadm_bin }} \
--image {{ tripleo_cephadm_container_ns + '/' + tripleo_cephadm_container_image + ':' + tripleo_cephadm_container_tag }} \
bootstrap \
--skip-firewalld \
--ssh-private-key /home/{{ tripleo_cephadm_ssh_user }}/.ssh/id_rsa \
--ssh-public-key /home/{{ tripleo_cephadm_ssh_user }}/.ssh/id_rsa.pub \
--ssh-user {{ tripleo_cephadm_ssh_user }} \
--allow-fqdn-hostname \
--output-keyring {{ tripleo_cephadm_admin_keyring }} \
--output-config {{ tripleo_cephadm_conf }} \
--fsid {{ tripleo_cephadm_fsid }} \
{% if tripleo_cephadm_spec_on_bootstrap %}--apply-spec {{ tripleo_cephadm_spec }} \{% endif %}
{% if tripleo_cephadm_bootstrap_conf_stat.stat.exists %}--config {{ tripleo_cephadm_bootstrap_conf }} \{% endif %}
--skip-monitoring-stack --skip-dashboard \
--mon-ip {{ tripleo_cephadm_first_mon_ip }}
register: cephadm_bootstrap
become: true
- name: Show results of bootstrap
debug:
msg: "{{ cephadm_bootstrap }}"
when: tripleo_cephadm_verbose
when:
- cephadm_ls.stdout == '[]'
tags:
- cephadm_bootstrap
- name: If cephadm bootstrap was not run report the reason
debug:
msg: |
'cephadm bootstrap' was not run because 'cephadm ls'
indicates that Ceph containers are already running.
when:
- cephadm_ls.stdout != '[]'