Add ceph config overrides support

This change adds ceph config overrides support by
moving the logic from tht to tripleo-ansible.
This allow us to avoid centralizing all the
variables in ceph-base.yml, distributing them to
the related templates.
The logic implemented here just merge the provided
structures, maintaining backward compatibility with
the old used "key:value" pattern without a specific
section (which use global by default).

Closes-Bug: #1867006
Change-Id: Idbe0a6526fa262121bbb424f8705a3664ea00abd
This commit is contained in:
Francesco Pantano 2020-03-09 16:51:22 +01:00
parent 23f547dc4e
commit c5ecafbddc
No known key found for this signature in database
GPG Key ID: 799868C47301D458
3 changed files with 55 additions and 21 deletions

View File

@ -17,24 +17,6 @@
# todo(fultonj): evolve this to derive more of these values from facts
ceph_ansible_group_vars_all:
ceph_conf_overrides:
global:
osd_pool_default_pg_num: 32
osd_pool_default_pgp_num: 32
osd_pool_default_size: 3
rgw_keystone_accepted_admin_roles: ResellerAdmin
rgw_keystone_accepted_roles: Member, admin
rgw_keystone_admin_domain: default
rgw_keystone_admin_password: fEoaZFe0C5ZQ1hvFo7yfxutan
rgw_keystone_admin_project: service
rgw_keystone_admin_user: swift
rgw_keystone_api_version: 3
rgw_keystone_implicit_tenants: 'true'
rgw_keystone_revocation_interval: '0'
rgw_keystone_url: http://192.168.24.18:5000
rgw_s3_auth_use_keystone: 'true'
rgw_swift_versioning_enabled: 'true'
rgw_swift_account_in_url: 'true'
ceph_container_image: ceph/daemon
ceph_container_image_tag: v4.0.1-stable-4.0-nautilus-centos-7-x86_64
ceph_container_registry: 192.168.24.1:8787
@ -113,3 +95,9 @@ ceph_keys:
key: AQBRgQ9eAAAAABAAv84zEilJYZPNuJ0Iwn9Ndg==
mode: '0600'
name: client.glance
ceph_default_overrides:
global:
osd_pool_default_pg_num: 32
osd_pool_default_pgp_num: 32
osd_pool_default_size: 1

View File

@ -0,0 +1,43 @@
---
# Copyright 2020 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: build ceph orphan set
set_fact:
ceph_orphan: |-
{% set ceph_orphan = {} %}
{% for key, value in (ceph_config_overrides | default({})).items() %}
{% if not (['global', 'mon', 'mgr', 'osd', 'mds', 'client']) | intersect([key]) %}
{% set _ = ceph_orphan.__setitem__(key, value) %}
{% endif %}
{% endfor %}
{{ ceph_orphan }}
- name: clean ceph_config_overrides list
set_fact:
config_overrides: "{{ config_overrides|default({})|combine({item.key: item.value}, recursive=True) }}"
when:
- not (ceph_orphan.keys() | intersect([item.key]))
with_dict: "{{ ceph_config_overrides|default({}) }}"
- name: ceph_config_overrides w/o orphans
set_fact:
ceph_orphan: "{{ {'global': ceph_orphan|default({}) } }}"
when: ceph_orphan.keys() | length > 0
- name: build ceph config overrides
set_fact:
ceph_overrides: "{'ceph_conf_overrides': {{ ceph_default_overrides|default({}) |combine(config_overrides|default({}), recursive=True)
|combine(ceph_rgw_config_overrides|default({}), recursive=True)|combine(ceph_orphan|default({}), recursive=True)}} }"

View File

@ -55,12 +55,15 @@
- name: build openstack keys
include_tasks: build_keys.yml
- name: build ceph config overrides
include_tasks: build_config_overrides.yml
- name: generate ceph-ansible group vars all
copy:
dest: "{{ playbook_dir }}/ceph-ansible/group_vars/all.yml"
content: "{{ ceph_ansible_group_vars_all | combine(openstack_pools|default({'openstack_pools': []}))
| combine(openstack_keys|default({'openstack_keys': []})) | combine(keys|default({'keys': []}))
| combine(cephfs_data|default({})) | combine(cephfs_metadata|default({})) | to_nice_yaml }}"
content: "{{ ceph_ansible_group_vars_all | combine(ceph_overrides|default({}))
| combine(openstack_pools|default({'openstack_pools': []})) | combine(openstack_keys|default({'openstack_keys': []}))
| combine(keys|default({'keys': []})) | combine(cephfs_data|default({})) | combine(cephfs_metadata|default({})) | to_nice_yaml }}"
- name: generate ceph-ansible extra vars
copy: