- name: Install packages
  apt:
    name: rabbitmq-server
    state: present

- name: Create rabbitmq-env.conf
  copy:
    src: evolinux-rabbitmq-env.conf
    dest: /etc/rabbitmq/rabbitmq-env.conf
    owner: rabbitmq
    group: rabbitmq
    mode: "0600"
    force: no

- name: Create rabbitmq.config
  copy:
    src: evolinux-rabbitmq.config
    dest: /etc/rabbitmq/rabbitmq.config
    owner: rabbitmq
    group: rabbitmq
    mode: "0600"
    force: no

- name: Adjust ulimit
  lineinfile:
    dest: /etc/default/rabbitmq-server
    line: ulimit -n 2048

- name: is NRPE present ?
  stat:
    path: /etc/nagios/nrpe.d/evolix.cfg
  check_mode: no
  register: nrpe_evolix_config
  tags:
    - nrpe

- include: nrpe.yml
  when: nrpe_evolix_config.stat.exists

- name: is Munin present ?
  stat:
    path: /etc/munin
  check_mode: no
  register: etc_munin_directory
  tags:
    - nrpe

- include: munin.yml
  when: etc_munin_directory.stat.exists
