72 lines
2.9 KiB
YAML
72 lines
2.9 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.
|
|
|
|
# Assumes the following module is in ANSIBLE_LIBRARY=/usr/share/ansible/library/
|
|
# https://github.com/ceph/ceph-ansible/blob/master/library/ceph_pool.py
|
|
|
|
- name: Get ceph_cli
|
|
include_tasks: ceph_cli.yaml
|
|
vars:
|
|
admin_daemon: true
|
|
|
|
- name: create configured crush rules
|
|
ceph_crush_rule:
|
|
name: "{{ item.name }}"
|
|
cluster: "{{ tripleo_cephadm_cluster }}"
|
|
rule_type: replicated
|
|
bucket_root: "{{ item.root }}"
|
|
bucket_type: "{{ item.type }}"
|
|
device_class: "{{ item.class | default(omit) }}"
|
|
environment:
|
|
CEPH_CONTAINER_IMAGE: "{{ tripleo_cephadm_container_ns + '/' + tripleo_cephadm_container_image + ':' + tripleo_cephadm_container_tag }}"
|
|
CEPH_CONTAINER_BINARY: "{{ tripleo_cephadm_container_cli }}"
|
|
CEPH_FSID: "{{ tripleo_cephadm_fsid }}"
|
|
with_items: "{{ tripleo_cephadm_crush_rules | unique }}"
|
|
run_once: true
|
|
|
|
- name: get id for new default crush rule
|
|
ceph_crush_rule:
|
|
name: "{{ item.name }}"
|
|
cluster: "{{ tripleo_cephadm_cluster }}"
|
|
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 }}"
|
|
CEPH_FSID: "{{ tripleo_cephadm_fsid }}"
|
|
register: info_ceph_default_crush_rule
|
|
with_items: "{{ tripleo_cephadm_crush_rules | unique }}"
|
|
run_once: true
|
|
when: item.default | default(False) | bool
|
|
|
|
- name: set_fact info_ceph_default_crush_rule_yaml, ceph_osd_pool_default_crush_rule_name
|
|
set_fact:
|
|
info_ceph_default_crush_rule_yaml: "{{ item.stdout | from_json() }}"
|
|
ceph_osd_pool_default_crush_rule_name: "{{ (item.stdout | from_json).rule_name }}"
|
|
with_items: "{{ info_ceph_default_crush_rule.results }}"
|
|
run_once: true
|
|
when: not item.get('skipped', false)
|
|
|
|
- name: insert new default crush rule into daemon to prevent restart
|
|
command: |
|
|
{{ tripleo_cephadm_ceph_cli }} --admin-daemon /var/run/ceph/{{ tripleo_cephadm_cluster }}-mon.{{ hostvars[item].canonical_hostname }}.asok \
|
|
config set osd_pool_default_crush_rule {{ info_ceph_default_crush_rule_yaml.rule_id }}
|
|
changed_when: false
|
|
delegate_to: "{{ item }}"
|
|
with_items: "{{ groups['ceph_mon'] }}"
|
|
run_once: true
|
|
when:
|
|
- info_ceph_default_crush_rule_yaml | default('') | length > 0
|