288 lines
9.4 KiB
YAML
288 lines
9.4 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: Create Ceph Spec
|
|
hosts: undercloud
|
|
gather_facts: false
|
|
vars:
|
|
osd_spec:
|
|
data_devices:
|
|
all: true
|
|
tripleo_roles_path: "/usr/share/openstack-tripleo-heat-templates/roles_data.yaml"
|
|
dynamic_ceph_spec: true
|
|
cephadm_admin_hosts: []
|
|
cephadm_non_admin_hosts: []
|
|
pre_tasks:
|
|
- name: Ensure required inputs if using dynamic_ceph_spec
|
|
when:
|
|
- dynamic_ceph_spec | bool
|
|
block:
|
|
- fail:
|
|
msg: baremetal_deployed_path is a required input
|
|
when:
|
|
- baremetal_deployed_path is undefined
|
|
- fail:
|
|
msg: deployed_ceph_tht_path is a required input
|
|
when:
|
|
- deployed_ceph_tht_path is undefined
|
|
|
|
- name: Ensure working_dir is provided
|
|
fail:
|
|
msg: working_dir is a required input
|
|
when:
|
|
- working_dir is undefined
|
|
tasks:
|
|
- name: ensure ceph_spec_path is defined
|
|
set_fact:
|
|
ceph_spec_path: "{{ working_dir }}/generated_ceph_spec.yaml"
|
|
when:
|
|
- ceph_spec_path is undefined
|
|
|
|
- name: Override osd_spec if osd_spec_path is provided
|
|
set_fact:
|
|
osd_spec: "{{ osd_spec_path_content | from_yaml }}"
|
|
vars:
|
|
osd_spec_path_content: "{{ lookup('file', osd_spec_path) }}"
|
|
when:
|
|
- osd_spec_path is defined
|
|
- osd_spec_path | length > 0
|
|
tags:
|
|
- ceph_spec
|
|
|
|
- name: Override crush hierarchy if a custom crush path is provided
|
|
set_fact:
|
|
crush_hierarchy: "{{ crush_spec_content | from_yaml }}"
|
|
vars:
|
|
crush_spec_content: "{{ lookup('file', crush_hierarchy_path) }}"
|
|
when:
|
|
- crush_hierarchy_path is defined
|
|
- crush_hierarchy_path | length > 0
|
|
tags:
|
|
- ceph_spec
|
|
|
|
- name: Create Ceph spec based on baremetal_deployed_path and tripleo_roles
|
|
ceph_spec_bootstrap:
|
|
new_ceph_spec: "{{ ceph_spec_path }}"
|
|
tripleo_roles: "{{ tripleo_roles_path }}"
|
|
osd_spec: "{{ osd_spec }}"
|
|
crush_hierarchy: "{{ crush_hierarchy | default({}) }}"
|
|
deployed_metalsmith: "{{ baremetal_deployed_path }}"
|
|
tripleo_ansible_inventory: "{{ inventory_file }}"
|
|
method: 'both'
|
|
when:
|
|
- dynamic_ceph_spec | bool
|
|
tags:
|
|
- ceph_spec
|
|
|
|
- name: Get list of hosts which need ceph-admin user
|
|
vars:
|
|
cephadm_spec_content: "{{ lookup('file', ceph_spec_path) }}"
|
|
block:
|
|
- name: Add hosts with mon label to the cephadm_admin_hosts list
|
|
set_fact:
|
|
cephadm_admin_hosts: "{{ cephadm_admin_hosts + [ item.hostname ] }}"
|
|
loop: "{{ cephadm_spec_content | from_yaml_all | list }}"
|
|
when:
|
|
- item | length > 0
|
|
- item.hostname is defined
|
|
- item.service_type is defined
|
|
- item.service_type == 'host'
|
|
- item.labels is defined
|
|
- '"mon" in item.labels | list'
|
|
|
|
- name: Add hosts with osd label to the cephadm_non_admin_hosts list
|
|
set_fact:
|
|
cephadm_non_admin_hosts: "{{ cephadm_non_admin_hosts + [ item.hostname ] }}"
|
|
loop: "{{ cephadm_spec_content | from_yaml_all | list }}"
|
|
when:
|
|
- item | length > 0
|
|
- item.hostname is defined
|
|
- item.service_type is defined
|
|
- item.service_type == 'host'
|
|
- item.labels is defined
|
|
- '"osd" in item.labels | list'
|
|
|
|
- name: Ensure there is at least one monitor in the spec file
|
|
fail:
|
|
msg: "No hosts with the mon label were in the spec {{ ceph_spec_path }}"
|
|
when:
|
|
- not cephadm_admin_hosts | length > 0
|
|
|
|
- name: Add hosts with mon label to ceph_mon inventory group for next play
|
|
add_host:
|
|
name: "{{ item }}"
|
|
groups: ceph_mon
|
|
loop: "{{ cephadm_admin_hosts }}"
|
|
|
|
- name: Add mds and nfs labels
|
|
block:
|
|
- name: Add hosts with mds label to ceph_mds inventory group for next play
|
|
add_host:
|
|
name: "{{ item }}"
|
|
groups: ceph_mds
|
|
loop: "{{ cephadm_admin_hosts }}"
|
|
|
|
- name: Add hosts with nfs label to ceph_nfs inventory group for next play
|
|
add_host:
|
|
name: "{{ item }}"
|
|
groups: ceph_nfs
|
|
loop: "{{ cephadm_admin_hosts }}"
|
|
when: tripleo_cephadm_daemon_ceph_nfs | default(False)
|
|
|
|
- name: Prepare cephadm user and keys
|
|
include_role:
|
|
name: tripleo_run_cephadm
|
|
tasks_from: enable_ceph_admin_user.yml
|
|
vars:
|
|
ceph_working_dir: "{{ working_dir }}"
|
|
tags:
|
|
- cephadm_ssh_user
|
|
|
|
|
|
- name: Bootstrap Ceph and apply spec
|
|
hosts: ceph_mon[0]
|
|
gather_facts: false
|
|
vars:
|
|
tripleo_cephadm_spec_on_bootstrap: false
|
|
tripleo_cephadm_spec_ansible_host: "{{ ceph_spec_path }}"
|
|
tripleo_cephadm_bootstrap_host: "{{ inventory_hostname_short }}"
|
|
pre_tasks:
|
|
- name: Ensure ceph_spec_path is defined
|
|
set_fact:
|
|
ceph_spec_path: "{{ working_dir }}/generated_ceph_spec.yaml"
|
|
when:
|
|
- ceph_spec_path is undefined
|
|
|
|
- name: Ensure public_network and cluster_network are defined
|
|
fail:
|
|
msg: >
|
|
The following four variables must be passed to this playbook
|
|
public_network ({{ public_network }}) |
|
|
public_network_name ({{ public_network_name }}) |
|
|
cluster_network ({{ cluster_network }}) |
|
|
cluster_network_name ({{ cluster_network_name }})
|
|
when:
|
|
- (public_network is undefined or public_network | length == 0) or
|
|
(public_network_name is undefined or public_network_name | length == 0) or
|
|
(cluster_network is undefined or cluster_network | length == 0) or
|
|
(cluster_network_name is undefined or cluster_network_name | length == 0)
|
|
|
|
- name: Set IP address of first monitor
|
|
set_fact:
|
|
tripleo_cephadm_first_mon_ip: "{{ hv[public_network_name + '_ip'] }}"
|
|
vars:
|
|
hv: "{{ hostvars[inventory_hostname_short] }}"
|
|
when:
|
|
- tripleo_cephadm_first_mon_ip is undefined
|
|
|
|
tasks:
|
|
- name: Satisfy Ceph prerequisites
|
|
import_role:
|
|
name: tripleo_cephadm
|
|
tasks_from: pre
|
|
|
|
- name: Bootstrap Ceph
|
|
import_role:
|
|
name: tripleo_cephadm
|
|
tasks_from: bootstrap
|
|
|
|
- name: Configure public/private network and ms_bind ipv4/v6
|
|
import_role:
|
|
name: tripleo_cephadm
|
|
tasks_from: network_config_set
|
|
|
|
- name: Prepare Ceph VIPs
|
|
import_role:
|
|
name: tripleo_cephadm
|
|
tasks_from: ceph_vip
|
|
delegate_to: localhost
|
|
when:
|
|
- tripleo_cephadm_ha_services_path is defined
|
|
- tripleo_cephadm_ingress | default(true)
|
|
|
|
- name: Apply Ceph spec
|
|
import_role:
|
|
name: tripleo_cephadm
|
|
tasks_from: apply_spec
|
|
when:
|
|
- not tripleo_cephadm_spec_on_bootstrap
|
|
|
|
- name: Create ceph pools if tripleo_cephadm_pools was set
|
|
import_role:
|
|
name: tripleo_cephadm
|
|
tasks_from: pools
|
|
when:
|
|
- tripleo_cephadm_pools is defined
|
|
- tripleo_cephadm_pools | length > 0
|
|
|
|
- name: Create Keys if tripleo_cephadm_keys was set
|
|
import_role:
|
|
name: tripleo_cephadm
|
|
tasks_from: keys
|
|
when:
|
|
- tripleo_cephadm_keys is defined
|
|
- tripleo_cephadm_keys | length > 0
|
|
|
|
- name: Export configuration for tripleo_ceph_client
|
|
import_role:
|
|
name: tripleo_cephadm
|
|
tasks_from: export
|
|
when:
|
|
- tripleo_cephadm_pools is defined
|
|
- tripleo_cephadm_pools | length > 0
|
|
- tripleo_cephadm_keys is defined
|
|
- tripleo_cephadm_keys | length > 0
|
|
|
|
- name: Config MDS and Ganesha daemons
|
|
when: tripleo_cephadm_daemon_ceph_nfs | default(False)
|
|
block:
|
|
- fail:
|
|
msg: Vips are required to configure HA services
|
|
when:
|
|
- tripleo_cephadm_ha_services_path is not defined
|
|
- tripleo_cephadm_ingress | default(true)
|
|
- name: Config MDS
|
|
import_role:
|
|
name: tripleo_cephadm
|
|
tasks_from: mds
|
|
vars:
|
|
cephfs_data_pool:
|
|
name: "{{ cephfs_data | default('manila_data') }}"
|
|
application: cephfs
|
|
cephfs_metadata_pool:
|
|
application: cephfs
|
|
name: "{{ cephfs_metadata | default('manila_metadata') }}"
|
|
- name: Config Ganesha
|
|
include_role:
|
|
name: tripleo_cephadm
|
|
tasks_from: ceph_nfs
|
|
vars:
|
|
tripleo_cephadm_ceph_nfs_address_block: "{{ public_network }}"
|
|
when:
|
|
- groups['ceph_nfs'] | default([]) | length > 0
|
|
|
|
- name: Show the Ceph cluster status
|
|
import_role:
|
|
name: tripleo_cephadm
|
|
tasks_from: post
|
|
|
|
- name: Create Deployed Ceph environment file for overcloud deployment
|
|
import_role:
|
|
name: tripleo_cephadm
|
|
tasks_from: make_deployed_ceph_tht
|
|
vars:
|
|
tripleo_cephadm_deployed_ceph_tht_path: "{{ deployed_ceph_tht_path }}"
|