mirror of https://github.com/ceph/ceph-ansible.git
66 lines
2.4 KiB
Django/Jinja
66 lines
2.4 KiB
Django/Jinja
#!/bin/bash
|
|
|
|
RETRIES="{{ handler_health_rgw_check_retries }}"
|
|
DELAY="{{ handler_health_rgw_check_delay }}"
|
|
RGW_NAME="{{ ansible_hostname }}"
|
|
RGW_PORT="{{ radosgw_civetweb_port }}"
|
|
SOCKET=/var/run/ceph/{{ cluster }}-client.rgw.${RGW_NAME}.asok
|
|
|
|
{% if radosgw_address_block | length > 0 %}
|
|
{% if ip_version == 'ipv4' -%}
|
|
RGW_IP={{ hostvars[inventory_hostname]['ansible_all_' + ip_version + '_addresses'] | ipaddr(radosgw_address_block) | first }}
|
|
{%- elif ip_version == 'ipv6' -%}
|
|
RGW_IP=[{{ hostvars[inventory_hostname]['ansible_all_' + ip_version + '_addresses'] | ipaddr(radosgw_address_block) | first }}]
|
|
{%- endif %}
|
|
{% elif hostvars[inventory_hostname]['radosgw_address'] is defined and hostvars[inventory_hostname]['radosgw_address'] != '0.0.0.0' -%}
|
|
{% if ip_version == 'ipv4' -%}
|
|
RGW_IP={{ hostvars[inventory_hostname]['radosgw_address'] }}
|
|
{%- elif ip_version == 'ipv6' -%}
|
|
RGW_IP=[{{ hostvars[inventory_hostname]['radosgw_address'] }}]
|
|
{% endif %}
|
|
{%- else -%}
|
|
{% set interface = ["ansible_",radosgw_interface]|join %}
|
|
{% if ip_version == 'ipv6' -%}
|
|
RGW_IP=[{{ hostvars[inventory_hostname][interface][ip_version][0]['address'] }}]
|
|
{%- elif ip_version == 'ipv4' -%}
|
|
RGW_IP={{ hostvars[inventory_hostname][interface][ip_version]['address'] }}
|
|
{% endif %}
|
|
{%- endif %}
|
|
|
|
check_for_curl_or_wget() {
|
|
if {{ docker_exec_cmd }} command -v wget &>/dev/null; then
|
|
rgw_test_command="wget --quiet"
|
|
elif {{ docker_exec_cmd }} command -v curl &>/dev/null; then
|
|
rgw_test_command="curl --fail --silent --output /dev/null"
|
|
else
|
|
echo "It seems that neither curl or wget are available on your system."
|
|
echo "Cannot test rgw connection."
|
|
exit 0
|
|
fi
|
|
}
|
|
|
|
check_rest() {
|
|
check_for_curl_or_wget
|
|
while [ $RETRIES -ne 0 ]; do
|
|
test "$rgw_test_command http://$RGW_IP:$RGW_PORT" && exit 0
|
|
sleep $DELAY
|
|
let RETRIES=RETRIES-1
|
|
done
|
|
# If we reach this point, it means there is a problem with the connection to rgw
|
|
echo "Error connecting locally to Rados Gateway service: http://$rgw_listen"
|
|
exit 1
|
|
}
|
|
|
|
# First, restart the daemon
|
|
systemctl restart ceph-radosgw@rgw.${RGW_NAME}
|
|
|
|
COUNT=10
|
|
# Wait and ensure the socket exists after restarting the daemon
|
|
while [ $COUNT -ne 0 ]; do
|
|
{{ docker_exec_cmd }} test -S $SOCKET && check_rest
|
|
sleep 1
|
|
let COUNT=COUNT-1
|
|
done
|
|
echo "Socket file ${SOCKET} could not be found, which means Rados Gateway is not running."
|
|
exit 1
|