---
#
# Ceilometer tasks for browbeat
# * Change backend between database and gnocchi
#

- name:  Get current backend(s)
  become: true
  command: crudini --get /etc/ceilometer/ceilometer.conf DEFAULT meter_dispatchers
  register: current_backend

- debug: msg="Current Backend={{current_backend.stdout}}"

- name: Configure Ceilometer Backend
  become: true
  ini_file:
    dest: /etc/ceilometer/ceilometer.conf
    mode: 0640
    section: DEFAULT
    option: meter_dispatchers
    value: "{{ ceilometer_backend }}"
    backup: yes
  notify:
    - pacemaker default unmanaged
    - restart ceilometer services
    - restart gnocchi services
    - pacemaker default managed
    - pacemaker cleanup ceilometer
    - pacemaker cleanup gnocchi

- name: Configure for gnocchi
  become: true
  when: ("'{{ ceilometer_backend }}' == 'gnocchi'") and (inventory_hostname == groups['controller'][0])
  shell:  gnocchi-upgrade --create-legacy-resource-types

---
#
# Ceilometer tasks for browbeat
# * Change backend between database and gnocchi
#

- name:  Get current backend(s)
  become: true
  command: crudini --get /etc/ceilometer/ceilometer.conf DEFAULT meter_dispatchers
  register: current_backend

- debug: msg="Current Backend={{current_backend.stdout}}"

- name: Configure Ceilometer Backend
  become: true
  ini_file:
    dest: /etc/ceilometer/ceilometer.conf
    mode: 0640
    section: DEFAULT
    option: meter_dispatchers
    value: "{{ ceilometer_backend }}"
    backup: yes
  notify:
    - pacemaker default unmanaged
    - restart ceilometer services
    - restart gnocchi services
    - pacemaker default managed
    - pacemaker cleanup ceilometer
    - pacemaker cleanup gnocchi

- name: Configure for gnocchi
  become: true
  when: "('{{ceilometer_backend}}' == 'gnocchi') and (inventory_hostname == groups['controller'][0])"
  shell:  gnocchi-upgrade --create-legacy-resource-types

Fix bug in Ceilometer backend role
Fix bug in Ceilometer backend role

Fix bug, last task always runs regardless of what
ceilometer_backend is set to

Change-Id: I81be126b2e789cf4d614b2530577c8bcb7285b9c
