Skip to content

Commit

Permalink
ceph-config: make rgw config to be in file
Browse files Browse the repository at this point in the history
Signed-off-by: Seena Fallah <[email protected]>
  • Loading branch information
clwluvw committed Feb 14, 2024
1 parent d0971e8 commit e67925c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 47 deletions.
44 changes: 40 additions & 4 deletions roles/ceph-config/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,52 @@
- _osd_memory_target is undefined
- num_osds | default(0) | int > 0
- ((ansible_facts['memtotal_mb'] * 1048576 * safety_factor | float) / num_osds | float) > (osd_memory_target | float)
- ceph_conf_overrides.get('osd', {}).get('osd_memory_target', '') == ''

- name: Set osd_memory_target to cluster host config
ceph_config:
action: set
who: "osd.*/{{ ansible_hostname }}:host"
who: "osd.*/{{ ansible_facts['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', '') == ''
when: _osd_memory_target is defined

- name: Set rgw configs
when: inventory_hostname in groups.get(rgw_group_name, [])
block:
- name: Render rgw configs
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 '' }}"
ansible.builtin.set_fact:
_ceph_ansible_rgw_conf: >-
{{ _ceph_ansible_rgw_conf | default({}) | combine({
'client.rgw.' + ansible_facts['hostname'] + '.' + item.instance_name: {
'log_file': '/var/log/ceph/' + cluster + '-rgw-' + ansible_facts['hostname'] + '.' + item.instance_name + '.log',
'rgw_frontends': 'beast ' + _rgw_beast_endpoint + _rgw_beast_ssl_option,
}
}, recursive=true) }}
loop: "{{ rgw_instances }}"

- name: Set config to cluster
ceph_config:
action: set
who: "{{ item.0.key }}"
option: "{{ item.1.key }}"
value: "{{ item.1.value }}"
loop: "{{ _ceph_ansible_rgw_conf | dict2dict }}"
when: rgw_conf_to_cluster | default(true) | bool
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 }}"
delegate_to: "{{ groups.get(mon_group_name, [])[0] }}"
notify: restart ceph rgws

- name: Set rgw configs to file
ansible.builtin.set_fact:
ceph_conf_overrides: "{{ ceph_conf_overrides | default({}) | combine(_ceph_ansible_rgw_conf, recursive=true) }}"
when: not rgw_conf_to_cluster | default(true) | bool

- name: create ceph conf directory
file:
Expand Down
33 changes: 0 additions & 33 deletions roles/ceph-rgw/tasks/pre_requisite.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,4 @@
---
- name: set_fact _rgw_hostname
set_fact:
_rgw_hostname: "{{ hostvars[inventory_hostname]['ansible_facts']['hostname'] }}"

- name: set rgw parameter (log file)
ceph_config:
action: set
who: "client.rgw.{{ _rgw_hostname + '.' + item.instance_name }}"
option: "log file"
value: "/var/log/ceph/{{ cluster }}-rgw-{{ hostvars[inventory_hostname]['ansible_facts']['hostname'] + '.' + item.instance_name }}.log"
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 }}"
delegate_to: "{{ groups.get(mon_group_name, [])[0] }}"
loop: "{{ hostvars[inventory_hostname]['rgw_instances'] }}"

- 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:
action: set
who: "client.rgw.{{ _rgw_hostname + '.' + item.instance_name }}"
option: "rgw_frontends"
value: "beast {{ _rgw_beast_endpoint }}{{ _rgw_beast_ssl_option }}"
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 }}"
delegate_to: "{{ groups.get(mon_group_name, [])[0] }}"
loop: "{{ hostvars[inventory_hostname]['rgw_instances'] }}"
notify: restart ceph rgws

- name: create rados gateway directories
file:
path: "/var/lib/ceph/radosgw/{{ cluster }}-rgw.{{ ansible_facts['hostname'] }}.{{ item.instance_name }}"
Expand Down
6 changes: 1 addition & 5 deletions site-container.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,7 @@
ansible.builtin.import_role:
name: ceph-defaults

- name: Import config role
ansible.builtin.import_role:
name: ceph-config

- name: Set clsuter configs
- name: Set cluster configs
ceph_config:
action: set
who: "{{ item.0.key }}"
Expand Down
6 changes: 1 addition & 5 deletions site.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,7 @@
ansible.builtin.import_role:
name: ceph-defaults

- name: Import config role
ansible.builtin.import_role:
name: ceph-config

- name: Set clsuter configs
- name: Set cluster configs
ceph_config:
action: set
who: "{{ item.0.key }}"
Expand Down

0 comments on commit e67925c

Please sign in to comment.