diff --git a/roles/ceph-config/tasks/main.yml b/roles/ceph-config/tasks/main.yml index 54528cfc5..e7fbf8e0b 100644 --- a/roles/ceph-config/tasks/main.yml +++ b/roles/ceph-config/tasks/main.yml @@ -97,26 +97,69 @@ - name: Set osd related config facts when: inventory_hostname in groups.get(osd_group_name, []) block: - - name: set_fact _osd_memory_target - set_fact: + - 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 }}" when: - _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', '') == '' + - running_mon is defined + 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: "{{ running_mon }}" -- name: create ceph conf directory - file: +- 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 + - running_mon is defined + 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: "{{ running_mon }}" + + - 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 + ansible.builtin.file: path: "/etc/ceph" state: directory owner: "ceph" diff --git a/roles/ceph-rgw/tasks/pre_requisite.yml b/roles/ceph-rgw/tasks/pre_requisite.yml index 9d3074849..a31b88dfb 100644 --- a/roles/ceph-rgw/tasks/pre_requisite.yml +++ b/roles/ceph-rgw/tasks/pre_requisite.yml @@ -1,37 +1,4 @@ --- -- name: Set_fact _rgw_hostname - ansible.builtin.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 ansible.builtin.file: path: "/var/lib/ceph/radosgw/{{ cluster }}-rgw.{{ ansible_facts['hostname'] }}.{{ item.instance_name }}" diff --git a/site-container.yml.sample b/site-container.yml.sample index caf45645e..3935f9b20 100644 --- a/site-container.yml.sample +++ b/site-container.yml.sample @@ -182,11 +182,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 }}" diff --git a/site.yml.sample b/site.yml.sample index 211072600..e5bd9de61 100644 --- a/site.yml.sample +++ b/site.yml.sample @@ -174,11 +174,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 }}"