---
- hosts: overcloud
  vars:
    metadata:
      name: Rabbitmq limits
      description: >
        Make sure the rabbitmq file descriptor limits are set to reasonable values.
    min_fd_limit: 10000
  tasks:
  - name: Get file_descriptors total_limit
    register: actual_fd_limit
    shell: "rabbitmqctl report | grep file_descriptors -A4 | grep total_limit"
    failed_when: "actual_fd_limit.rc != 0"
  - name: Verify the actual limit exceeds the minimal value
    fail:
      # TODO(shadower): kinda ugly having the huge regex here. Maybe add a
      # module that extracts the rabbitmq facts?
      msg: "{{ actual_fd_limit.stdout|regex_replace('^.*\\{total_limit,([0-9]+)\\}.*$', '\\\\1') }} must be greater than {{ min_fd_limit }}"
    failed_when: "{{ actual_fd_limit.stdout|regex_replace('^.*\\{total_limit,([0-9]+)\\}.*$', '\\\\1')|int }} < {{ min_fd_limit }}"

Add validation for the rabbitmq fd limit
Add validation for the rabbitmq fd limit

This checks to see whether the `file_descriptors` limit for rabbitmq exists and
is set to a sane value.
