mirror of https://github.com/ceph/ceph-ansible.git
ceph-config: introduce dedicated cluster config flow
Signed-off-by: Seena Fallah <seenafallah@gmail.com>pull/7482/head
parent
ebd0c6fce3
commit
4df1c1a09c
|
@ -258,6 +258,16 @@ dummy:
|
||||||
|
|
||||||
#cephx: true
|
#cephx: true
|
||||||
|
|
||||||
|
# Cluster configuration
|
||||||
|
#ceph_cluster_conf:
|
||||||
|
# global:
|
||||||
|
# public_network: "{{ public_network | default(omit) }}"
|
||||||
|
# cluster_network: "{{ cluster_network | default(omit) }}"
|
||||||
|
# osd_pool_default_crush_rule: "{{ osd_pool_default_crush_rule }}"
|
||||||
|
# ms_bind_ipv6: "{{ (ip_version == 'ipv6') | string }}"
|
||||||
|
# ms_bind_ipv4: "{{ (ip_version == 'ipv4') | string }}"
|
||||||
|
# osd_crush_chooseleaf_type: "{{ '0' if common_single_host_mode | default(false) else omit }}"
|
||||||
|
|
||||||
## Client options
|
## Client options
|
||||||
#
|
#
|
||||||
#rbd_cache: "true"
|
#rbd_cache: "true"
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
from __future__ import (absolute_import, division, print_function)
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
|
class FilterModule(object):
|
||||||
|
''' Loop over nested dictionaries '''
|
||||||
|
|
||||||
|
def dict2dict(self, nested_dict):
|
||||||
|
items = []
|
||||||
|
for key, value in nested_dict.items():
|
||||||
|
for k, v in value.items():
|
||||||
|
items.append(
|
||||||
|
(
|
||||||
|
{'key': key, 'value': value},
|
||||||
|
{'key': k, 'value': v},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
return items
|
||||||
|
|
||||||
|
def filters(self):
|
||||||
|
return {
|
||||||
|
'dict2dict': self.dict2dict
|
||||||
|
}
|
|
@ -97,24 +97,26 @@
|
||||||
- name: Set osd related config facts
|
- name: Set osd related config facts
|
||||||
when: inventory_hostname in groups.get(osd_group_name, [])
|
when: inventory_hostname in groups.get(osd_group_name, [])
|
||||||
block:
|
block:
|
||||||
- name: Set_fact _osd_memory_target, override from ceph_conf_overrides
|
- name: set_fact _osd_memory_target
|
||||||
ansible.builtin.set_fact:
|
set_fact:
|
||||||
_osd_memory_target: "{{ item }}"
|
|
||||||
loop:
|
|
||||||
- "{{ ceph_conf_overrides.get('osd', {}).get('osd memory target', '') }}"
|
|
||||||
- "{{ ceph_conf_overrides.get('osd', {}).get('osd_memory_target', '') }}"
|
|
||||||
when: item
|
|
||||||
|
|
||||||
- name: Set_fact _osd_memory_target
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
_osd_memory_target: "{{ ((ansible_facts['memtotal_mb'] * 1048576 * safety_factor | float) / num_osds | float) | int }}"
|
_osd_memory_target: "{{ ((ansible_facts['memtotal_mb'] * 1048576 * safety_factor | float) / num_osds | float) | int }}"
|
||||||
when:
|
when:
|
||||||
- _osd_memory_target is undefined
|
- _osd_memory_target is undefined
|
||||||
- num_osds | default(0) | int > 0
|
- num_osds | default(0) | int > 0
|
||||||
- ((ansible_facts['memtotal_mb'] * 1048576 * safety_factor | float) / num_osds | float) > (osd_memory_target | float)
|
- ((ansible_facts['memtotal_mb'] * 1048576 * safety_factor | float) / num_osds | float) > (osd_memory_target | float)
|
||||||
|
|
||||||
- name: Create ceph conf directory
|
- name: Set osd_memory_target to cluster host config
|
||||||
ansible.builtin.file:
|
ceph_config:
|
||||||
|
action: set
|
||||||
|
who: "osd.*/{{ ansible_hostname }}:host"
|
||||||
|
option: "osd_memory_target"
|
||||||
|
value: "{{ _osd_memory_target }}"
|
||||||
|
when:
|
||||||
|
- _osd_memory_target is defined
|
||||||
|
- ceph_conf_overrides.get('osd', {}).get('osd_memory_target', '') == ''
|
||||||
|
|
||||||
|
- name: create ceph conf directory
|
||||||
|
file:
|
||||||
path: "/etc/ceph"
|
path: "/etc/ceph"
|
||||||
state: directory
|
state: directory
|
||||||
owner: "ceph"
|
owner: "ceph"
|
||||||
|
@ -135,6 +137,7 @@
|
||||||
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
|
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
|
||||||
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
|
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
config_overrides: "{{ ceph_conf_overrides }}"
|
||||||
config_type: ini
|
config_type: ini
|
||||||
notify:
|
notify:
|
||||||
- Restart ceph mons
|
- Restart ceph mons
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
# {{ ansible_managed }}
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
[global]
|
[global]
|
||||||
#{% if not cephx | bool %}
|
{% if not cephx | bool %}
|
||||||
#auth cluster required = none
|
auth cluster required = none
|
||||||
#auth service required = none
|
auth service required = none
|
||||||
#auth client required = none
|
auth client required = none
|
||||||
#{% endif %}
|
{% endif %}
|
||||||
{# NOTE (leseb): the blank lines in-between are needed otherwise we won't get any line break #}
|
{# NOTE (leseb): the blank lines in-between are needed otherwise we won't get any line break #}
|
||||||
|
|
||||||
{% set nb_mon = groups.get(mon_group_name, []) | length | int %}
|
{% set nb_mon = groups.get(mon_group_name, []) | length | int %}
|
||||||
|
|
|
@ -250,6 +250,16 @@ ceph_keyring_permissions: '0600'
|
||||||
|
|
||||||
cephx: true
|
cephx: true
|
||||||
|
|
||||||
|
# Cluster configuration
|
||||||
|
ceph_cluster_conf:
|
||||||
|
global:
|
||||||
|
public_network: "{{ public_network | default(omit) }}"
|
||||||
|
cluster_network: "{{ cluster_network | default(omit) }}"
|
||||||
|
osd_pool_default_crush_rule: "{{ osd_pool_default_crush_rule }}"
|
||||||
|
ms_bind_ipv6: "{{ (ip_version == 'ipv6') | string }}"
|
||||||
|
ms_bind_ipv4: "{{ (ip_version == 'ipv4') | string }}"
|
||||||
|
osd_crush_chooseleaf_type: "{{ '0' if common_single_host_mode | default(false) else omit }}"
|
||||||
|
|
||||||
## Client options
|
## Client options
|
||||||
#
|
#
|
||||||
rbd_cache: "true"
|
rbd_cache: "true"
|
||||||
|
|
|
@ -16,11 +16,15 @@
|
||||||
loop: "{{ hostvars[inventory_hostname]['rgw_instances'] }}"
|
loop: "{{ hostvars[inventory_hostname]['rgw_instances'] }}"
|
||||||
|
|
||||||
- name: Set rgw parameter (rgw_frontends)
|
- name: Set rgw parameter (rgw_frontends)
|
||||||
|
vars:
|
||||||
|
_rgw_binding_socket: "{{ item.radosgw_address | default(_radosgw_address) | string + ':' + item.radosgw_frontend_port | default(radosgw_frontend_port) | string }}"
|
||||||
|
_rgw_beast_endpoint: "{{ 'ssl_' if radosgw_frontend_ssl_certificate else '' }}endpoint={{ _rgw_binding_socket }}"
|
||||||
|
_rgw_beast_ssl_option: "{{ ' ssl_certificate='+radosgw_frontend_ssl_certificate if radosgw_frontend_ssl_certificate else '' }}"
|
||||||
ceph_config:
|
ceph_config:
|
||||||
action: set
|
action: set
|
||||||
who: "client.rgw.{{ _rgw_hostname + '.' + item.instance_name }}"
|
who: "client.rgw.{{ _rgw_hostname + '.' + item.instance_name }}"
|
||||||
option: "rgw_frontends"
|
option: "rgw_frontends"
|
||||||
value: "beast port={{ item.radosgw_frontend_port | string }}"
|
value: "beast {{ _rgw_beast_endpoint }}{{ _rgw_beast_ssl_option }}"
|
||||||
environment:
|
environment:
|
||||||
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
||||||
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
||||||
|
@ -28,9 +32,6 @@
|
||||||
loop: "{{ hostvars[inventory_hostname]['rgw_instances'] }}"
|
loop: "{{ hostvars[inventory_hostname]['rgw_instances'] }}"
|
||||||
notify: Restart ceph rgws
|
notify: Restart ceph rgws
|
||||||
|
|
||||||
# rgw_frontends
|
|
||||||
# {{ 'ssl_' if radosgw_frontend_ssl_certificate else '' }}endpoint={{ _rgw_binding_socket }}{{ ' ssl_certificate='+radosgw_frontend_ssl_certificate if radosgw_frontend_ssl_certificate else '' }}
|
|
||||||
|
|
||||||
- name: Create rados gateway directories
|
- name: Create rados gateway directories
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "/var/lib/ceph/radosgw/{{ cluster }}-rgw.{{ ansible_facts['hostname'] }}.{{ item.instance_name }}"
|
path: "/var/lib/ceph/radosgw/{{ cluster }}-rgw.{{ ansible_facts['hostname'] }}.{{ item.instance_name }}"
|
||||||
|
|
|
@ -174,58 +174,29 @@
|
||||||
end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
|
end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
|
||||||
|
|
||||||
- hosts: mons[0]
|
- hosts: mons[0]
|
||||||
become: True
|
become: true
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
any_errors_fatal: true
|
any_errors_fatal: true
|
||||||
tasks:
|
tasks:
|
||||||
- import_role:
|
- name: Import default role
|
||||||
|
ansible.builtin.import_role:
|
||||||
name: ceph-defaults
|
name: ceph-defaults
|
||||||
|
|
||||||
- name: set global config
|
- name: Import config role
|
||||||
ceph_config:
|
ansible.builtin.import_role:
|
||||||
action: set
|
name: ceph-config
|
||||||
who: "global"
|
|
||||||
option: "{{ item.key }}"
|
|
||||||
value: "{{ item.value }}"
|
|
||||||
environment:
|
|
||||||
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
|
||||||
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
|
||||||
with_dict:
|
|
||||||
"{{ {
|
|
||||||
'public_network': public_network | default(False),
|
|
||||||
'cluster_network': cluster_network | default(False),
|
|
||||||
'osd pool default crush rule': osd_pool_default_crush_rule,
|
|
||||||
'ms bind ipv6': 'true' if ip_version == 'ipv6' else 'false',
|
|
||||||
'ms bind ipv4': 'false' if ip_version == 'ipv6' else 'true',
|
|
||||||
'osd crush chooseleaf type': '0' if common_single_host_mode | default(False) | bool else False,
|
|
||||||
} }}"
|
|
||||||
when:
|
|
||||||
- inventory_hostname == ansible_play_hosts_all | last
|
|
||||||
- item.value
|
|
||||||
|
|
||||||
- name: set global config overrides
|
- name: Set clsuter configs
|
||||||
ceph_config:
|
ceph_config:
|
||||||
action: set
|
action: set
|
||||||
who: "global"
|
who: "{{ item.0.key }}"
|
||||||
option: "{{ item.key }}"
|
option: "{{ item.1.key }}"
|
||||||
value: "{{ item.value }}"
|
value: "{{ item.1.value }}"
|
||||||
|
when: item.1.value != omit
|
||||||
|
loop: "{{ ceph_cluster_conf | dict2dict }}"
|
||||||
environment:
|
environment:
|
||||||
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
||||||
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
||||||
when: inventory_hostname == ansible_play_hosts_all | last
|
|
||||||
with_dict: "{{ ceph_conf_overrides['global'] }}"
|
|
||||||
|
|
||||||
- name: set osd_memory_target
|
|
||||||
ceph_config:
|
|
||||||
action: set
|
|
||||||
who: "osd.*/{{ item }}:host"
|
|
||||||
option: "osd_memory_target"
|
|
||||||
value: "{{ _osd_memory_target | default(osd_memory_target) }}"
|
|
||||||
environment:
|
|
||||||
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
|
||||||
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
|
||||||
when: inventory_hostname == ansible_play_hosts_all | last
|
|
||||||
loop: "{{ groups[osd_group_name] | default([]) }}"
|
|
||||||
|
|
||||||
- hosts: osds
|
- hosts: osds
|
||||||
become: True
|
become: True
|
||||||
|
|
|
@ -166,49 +166,26 @@
|
||||||
end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
|
end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
|
||||||
|
|
||||||
- hosts: mons[0]
|
- hosts: mons[0]
|
||||||
become: True
|
become: true
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
any_errors_fatal: true
|
any_errors_fatal: true
|
||||||
tasks:
|
tasks:
|
||||||
- import_role:
|
- name: Import default role
|
||||||
|
ansible.builtin.import_role:
|
||||||
name: ceph-defaults
|
name: ceph-defaults
|
||||||
|
|
||||||
- name: set global config
|
- name: Import config role
|
||||||
ceph_config:
|
ansible.builtin.import_role:
|
||||||
action: set
|
name: ceph-config
|
||||||
who: "global"
|
|
||||||
option: "{{ item.key }}"
|
|
||||||
value: "{{ item.value }}"
|
|
||||||
with_dict:
|
|
||||||
"{{ {
|
|
||||||
'public_network': public_network | default(False),
|
|
||||||
'cluster_network': cluster_network | default(False),
|
|
||||||
'osd pool default crush rule': osd_pool_default_crush_rule,
|
|
||||||
'ms bind ipv6': 'true' if ip_version == 'ipv6' else 'false',
|
|
||||||
'ms bind ipv4': 'false' if ip_version == 'ipv6' else 'true',
|
|
||||||
'osd crush chooseleaf type': '0' if common_single_host_mode | default(False) | bool else False,
|
|
||||||
} }}"
|
|
||||||
when:
|
|
||||||
- inventory_hostname == ansible_play_hosts_all | last
|
|
||||||
- item.value
|
|
||||||
|
|
||||||
- name: set global config overrides
|
- name: Set clsuter configs
|
||||||
ceph_config:
|
ceph_config:
|
||||||
action: set
|
action: set
|
||||||
who: "global"
|
who: "{{ item.0.key }}"
|
||||||
option: "{{ item.key }}"
|
option: "{{ item.1.key }}"
|
||||||
value: "{{ item.value }}"
|
value: "{{ item.1.value }}"
|
||||||
when: inventory_hostname == ansible_play_hosts_all | last
|
when: item.1.value != omit
|
||||||
with_dict: "{{ ceph_conf_overrides['global'] }}"
|
loop: "{{ ceph_cluster_conf | dict2dict }}"
|
||||||
|
|
||||||
- name: set osd_memory_target
|
|
||||||
ceph_config:
|
|
||||||
action: set
|
|
||||||
who: "osd.*/{{ item }}:host"
|
|
||||||
option: "osd_memory_target"
|
|
||||||
value: "{{ _osd_memory_target | default(osd_memory_target) }}"
|
|
||||||
when: inventory_hostname == ansible_play_hosts_all | last
|
|
||||||
loop: "{{ groups[osd_group_name] | default([]) }}"
|
|
||||||
|
|
||||||
- hosts: osds
|
- hosts: osds
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
|
Loading…
Reference in New Issue