81 lines
2.7 KiB
YAML
81 lines
2.7 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.
|
|
|
|
# Creates a file which tripleo_ceph_client role can pass to include_vars
|
|
# The file will be saved in the path "{{ tripleo_ceph_client_vars }}"
|
|
# Assumes the following module is in ANSIBLE_LIBRARY=/usr/share/ansible/library/
|
|
# https://github.com/ceph/ceph-ansible/blob/master/library/ceph_key.py
|
|
|
|
- name: Get ceph_cli
|
|
include_tasks: ceph_cli.yaml
|
|
|
|
- name: Wait for the expected number of monitors to be running
|
|
include_tasks: wait_for_expected_num_mons.yaml
|
|
when: tripleo_cephadm_wait_for_mons
|
|
|
|
- name: Run ceph mon dump to get all monitors
|
|
command: "{{ tripleo_cephadm_ceph_cli }} mon dump --format json"
|
|
register: ceph_mon_dump
|
|
become: true
|
|
tags:
|
|
- cephadm_mon_dump
|
|
|
|
- name: Extract mons_json
|
|
set_fact:
|
|
tripleo_cephadm_mons_json: "{{ (ceph_mon_dump.stdout | from_json).mons |
|
|
map(attribute='public_addrs') |
|
|
map(attribute='addrvec') |
|
|
list }}"
|
|
|
|
- name: Build mons_list
|
|
set_fact:
|
|
tripleo_cephadm_mons_list: "{{ tripleo_cephadm_mons_list | default([]) +
|
|
[ '[' ~
|
|
item[0].type ~ ':' ~ item[0].addr ~ '/' ~ item[0].nonce
|
|
~ ',' ~
|
|
item[1].type ~ ':' ~ item[1].addr ~ '/' ~ item[1].nonce
|
|
~ ']'
|
|
] }}"
|
|
loop: "{{ tripleo_cephadm_mons_json }}"
|
|
|
|
- name: Set external_cluster_mon_ips from mons_list
|
|
set_fact:
|
|
external_cluster_mon_ips: "{{ tripleo_cephadm_mons_list | join(',') }}"
|
|
|
|
- name: Extract keys
|
|
ceph_key:
|
|
name: "{{ item.name }}"
|
|
state: info
|
|
environment:
|
|
CEPH_CONTAINER_IMAGE: "{{ tripleo_cephadm_container_ns + '/' + tripleo_cephadm_container_image + ':' + tripleo_cephadm_container_tag }}"
|
|
CEPH_CONTAINER_BINARY: "{{ tripleo_cephadm_container_cli }}"
|
|
register: tripleo_cephadm_client_keys
|
|
become: true
|
|
loop: "{{ tripleo_cephadm_keys }}"
|
|
when:
|
|
- tripleo_cephadm_keys is defined
|
|
- tripleo_cephadm_keys | length > 0
|
|
tags:
|
|
- cephadm_extract_keys
|
|
|
|
- name: Save tripleo_ceph_client_vars file
|
|
template:
|
|
src: templates/ceph_client.yaml.j2
|
|
dest: "{{ tripleo_ceph_client_vars }}"
|
|
mode: 0644
|
|
force: true
|
|
delegate_to: localhost
|