Allow mysql to be used as a database for Ceilometer

MongoDB is still default.

Refer to
http://docs.openstack.org/developer/ceilometer/install/dbreco.html for
more info on Ceilometer database backends.

Closes-Bug: #1622532

Change-Id: Iaf84f9efe0537f42797f4bb7ba2a3611835cc84e
This commit is contained in:
Paul Bourke 2016-09-08 12:42:01 +01:00
parent b10e29281a
commit 82f6d3f44b
6 changed files with 66 additions and 10 deletions

View File

@ -314,13 +314,19 @@ glance_backend_file: "{{ not enable_ceph | bool }}"
glance_backend_ceph: "{{ enable_ceph }}"
#######################
# Ceilometer options
#######################
# Valid options are [ mongodb, mysql ]
ceilometer_database_type: "mongodb"
#################################
# Cinder options
#################################
cinder_backend_ceph: "{{ enable_ceph }}"
#######################
# Nova options
#######################

View File

@ -1,10 +1,5 @@
---
- name: Checking backend for ceilometer
local_action: fail msg="No backend enabled for ceilometer. Mongodb is the only supported one for now"
changed_when: false
when: enable_ceilometer | bool and not enable_mongodb | bool
- name: Creating Ceilometer database
- name: Creating Ceilometer MongoDB database
command: docker exec -t mongodb mongo --host {{ ceilometer_database_address }} --eval 'db = db.getSiblingDB("{{ ceilometer_database_name }}"); db.addUser({user':' "{{ ceilometer_database_user }}", pwd':' "{{ ceilometer_database_password}}", roles':' [ "readWrite", "dbAdmin" ]})'
register: database
run_once: true
@ -12,5 +7,45 @@
- "'already' not in database.stdout"
- database.stdout.split()[4] != 'connecting'
delegate_to: "{{ groups['mongodb'][0] }}"
when:
- ceilometer_database_type == "mongodb"
- name: Creating Ceilometer mysql database
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
-m mysql_db
-a "login_host='{{ database_address }}'
login_port='{{ database_port }}'
login_user='{{ database_user }}'
login_password='{{ database_password }}'
name='{{ ceilometer_database_name }}'"
register: database
changed_when: "{{ database.stdout.find('localhost | SUCCESS => ') != -1 and
(database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
failed_when: database.stdout.split()[2] != 'SUCCESS'
run_once: True
delegate_to: "{{ groups['ceilometer-api'][0] }}"
when:
- ceilometer_database_type == "mysql"
- name: Creating Ceilometer database user and setting permissions
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
-m mysql_user
-a "login_host='{{ database_address }}'
login_port='{{ database_port }}'
login_user='{{ database_user }}'
login_password='{{ database_password }}'
name='{{ ceilometer_database_name }}'
password='{{ ceilometer_database_password }}'
host='%'
priv='{{ ceilometer_database_name }}.*:ALL'
append_privs='yes'"
register: database_user_create
changed_when: "{{ database_user_create.stdout.find('localhost | SUCCESS => ') != -1 and
(database_user_create.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
failed_when: database_user_create.stdout.split()[2] != 'SUCCESS'
run_once: True
delegate_to: "{{ groups['ceilometer-api'][0] }}"
when:
- ceilometer_database_type == "mysql"
- include: bootstrap_service.yml

View File

@ -12,7 +12,11 @@ host = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['addr
[collector]
[database]
{% if ceilometer_database_type == "mongodb" %}
connection = mongodb://{{ ceilometer_database_user }}:{{ ceilometer_database_password }}@{{ ceilometer_database_address }}:{{ mongodb_port }}/{{ ceilometer_database_name }}
{% elif ceilometer_database_type == "mysql" %}
connection = mysql+pymysql://{{ ceilometer_database_user }}:{{ ceilometer_database_password }}@{{ ceilometer_database_address }}/{{ ceilometer_database_name }}
{% endif %}
[keystone_authtoken]
memcached_servers = {{ kolla_internal_fqdn }}:{{ memcached_port }}

View File

@ -57,7 +57,10 @@
- groups['neutron-dhcp-agent'] | length < 2
or groups['neutron-l3-agent'] | length < 2
- name: Checking backend for ceilometer
local_action: fail msg="No backend enabled for ceilometer. Mongodb is the only supported one for now"
- name: Checking mongodb backend for ceilometer
local_action: fail msg="ceilometer_database_type set to 'mongodb' but mongodb is not enabled"
changed_when: false
when: enable_ceilometer | bool and not enable_mongodb | bool
when:
- enable_ceilometer | bool
- not enable_mongodb | bool
- ceilometer_database_type == "mongodb"

View File

@ -173,6 +173,11 @@ kolla_internal_vip_address: "10.10.10.254"
#glance_backend_file: "yes"
#glance_backend_ceph: "no"
#######################
# Ceilometer options
#######################
# Valid options are [ mongodb, mysql ]
#ceilometer_database_type: "mongodb"
#######################
# Cinder options

View File

@ -0,0 +1,3 @@
---
features:
- Allow mysql to be used as a database for Ceilometer.