A collection of Ansible playbooks to detect and report potential issues during TripleO deployments
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

82 lines
2.9 KiB

  1. ---
  2. - name: Check if ceph_mon is deployed
  3. become: true
  4. shell: hiera -c /etc/puppet/hiera.yaml enabled_services | egrep -sq ceph_mon
  5. ignore_errors: true
  6. register: ceph_mon_enabled
  7. changed_when: false
  8. delegate_to: "{{ tripleo_delegate_to | first | default(omit) }}"
  9. - when: "ceph_mon_enabled is succeeded"
  10. delegate_to: "{{ tripleo_delegate_to | first | default(omit) }}"
  11. block:
  12. - name: Check for docker cli
  13. stat:
  14. path: "/var/run/docker.sock"
  15. register: check_docker_cli
  16. check_mode: false
  17. - name: Set container_client fact
  18. set_fact:
  19. container_client: |-
  20. {% set container_client = 'podman' %}
  21. {% if check_docker_cli.stat.exists|bool %}
  22. {% set container_client = 'docker' %}
  23. {% endif %}
  24. {{ container_client }}
  25. - name: Set container filter format
  26. set_fact:
  27. container_filter_format: !unsafe "--format '{{ .Names }}'"
  28. - name: Set ceph_mon_container name
  29. become: true
  30. shell: "{{ container_client }} ps {{ container_filter_format }} | grep ceph-mon"
  31. register: ceph_mon_container
  32. changed_when: false
  33. - name: Set ceph cluster name
  34. become: true
  35. shell: find /etc/ceph -name '*.conf' -prune -print -quit | xargs basename -s '.conf'
  36. register: ceph_cluster_name
  37. changed_when: false
  38. - name: Get ceph health
  39. become: true
  40. shell: "{{ container_client }} exec {{ ceph_mon_container.stdout }} ceph --cluster {{ ceph_cluster_name.stdout }} health | awk '{print $1}'"
  41. register: ceph_health
  42. - name: Check ceph health
  43. warn:
  44. msg: Ceph is in {{ ceph_health.stdout }} state.
  45. when:
  46. - ceph_health.stdout != 'HEALTH_OK'
  47. - not fail_on_ceph_health_err|default(true)|bool
  48. - name: Fail if ceph health is HEALTH_ERR
  49. fail:
  50. msg: Ceph is in {{ ceph_health.stdout }} state.
  51. when:
  52. - ceph_health.stdout == 'HEALTH_ERR'
  53. - fail_on_ceph_health_err|default(true)|bool
  54. - when:
  55. - osd_percentage_min|default(0) > 0
  56. block:
  57. - name: set jq osd percentage filter
  58. set_fact:
  59. jq_osd_percentage_filter: '( (try .osdmap.num_in_osds + try .num_in_osds) / (try .osdmap.num_osds + try .num_osds)) * 100'
  60. - name: Get OSD stat percentage
  61. become: true
  62. shell: >-
  63. "{{ container_client }}" exec "{{ ceph_mon_container.stdout }}" ceph
  64. --cluster "{{ ceph_cluster_name.stdout }}" osd stat -f json | jq '{{ jq_osd_percentage_filter }}'
  65. register: ceph_osd_in_percentage
  66. - name: Fail if there is an unacceptable percentage of in OSDs
  67. fail:
  68. msg: "Only {{ ceph_osd_in_percentage.stdout|float }}% of OSDs are in, but {{ osd_percentage_min|default(0) }}% are required"
  69. when:
  70. - ceph_osd_in_percentage.stdout|float < osd_percentage_min|default(0)