Merge "Added grafana role"

This commit is contained in:
Jenkins 2016-09-14 18:14:58 +00:00 committed by Gerrit Code Review
commit d438e1ca13
19 changed files with 239 additions and 0 deletions

View File

@ -246,6 +246,7 @@ enable_cinder_backend_lvm: "no"
enable_cloudkitty: "no" enable_cloudkitty: "no"
enable_congress: "no" enable_congress: "no"
enable_gnocchi: "no" enable_gnocchi: "no"
enable_grafana: "no"
enable_heat: "yes" enable_heat: "yes"
enable_horizon: "yes" enable_horizon: "yes"
enable_influxdb: "no" enable_influxdb: "no"

View File

@ -20,6 +20,9 @@ localhost ansible_connection=local
[collectd:children] [collectd:children]
compute compute
[grafana:children]
monitoring
[kibana:children] [kibana:children]
control control

View File

@ -38,6 +38,9 @@ storage
[collectd:children] [collectd:children]
compute compute
[grafana:children]
monitoring
[influxdb:children] [influxdb:children]
monitoring monitoring

View File

@ -0,0 +1,16 @@
---
project_name: "grafana"
####################
# Database
####################
grafana_database_name: "grafana"
grafana_database_user: "grafana"
grafana_database_address: "{{ kolla_internal_fqdn }}:{{ database_port }}"
##########
# Grafana
##########
grafana_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-grafana"
grafana_tag: "{{ openstack_release }}"
grafana_image_full: "{{ grafana_image }}:{{ grafana_tag }}"

View File

@ -0,0 +1,3 @@
---
dependencies:
- { role: common }

View File

@ -0,0 +1,38 @@
---
- name: Creating grafana 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='{{ grafana_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['grafana'][0] }}"
- name: Reading json from variable
set_fact:
database_created: "{{ (database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
- name: Creating grafana 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='{{ grafana_database_name }}'
password='{{ grafana_database_password }}'
host='%'
priv='{{ grafana_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['grafana'][0] }}"

View File

@ -0,0 +1,27 @@
---
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item }}"
state: "directory"
recurse: yes
with_items:
- "grafana"
- name: Copying over config.json files
template:
src: "{{ item }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json"
with_items:
- "grafana"
- name: Copying over grafana.ini
merge_configs:
vars:
service_name: "{{ item }}"
sources:
- "{{ role_path }}/templates/grafana.ini.j2"
- "{{ node_custom_config }}/{{ item }}.ini"
- "{{ node_custom_config }}/grafana/{{ inventory_hostname }}/{{ item }}.ini"
dest: "{{ node_config_directory }}/grafana/grafana.ini"
with_items:
- "grafana"

View File

@ -0,0 +1,9 @@
---
- include: config.yml
when: inventory_hostname in groups['grafana']
- include: bootstrap.yml
when: inventory_hostname in groups['grafana']
- include: start.yml
when: inventory_hostname in groups['grafana']

View File

@ -0,0 +1,47 @@
---
- name: Ensuring the containers up
kolla_docker:
name: "grafana"
action: "get_container_state"
register: container_state
failed_when: container_state.Running == false
when: inventory_hostname in groups['grafana']
- include: config.yml
- name: Check the configs
command: docker exec grafana /usr/local/bin/kolla_set_configs --check
changed_when: false
failed_when: false
register: check_results
when: inventory_hostname in groups['grafana']
# NOTE(jeffrey4l): when config_strategy == 'COPY_ALWAYS'
# and container env['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE',
# just remove the container and start again
- name: Containers config strategy
kolla_docker:
name: "grafana"
action: "get_container_env"
register: container_envs
when: inventory_hostname in groups['grafana']
- name: Remove the containers
kolla_docker:
name: "grafana"
action: "remove_container"
register: remove_containers
when:
- config_strategy == "COPY_ONCE"
- inventory_hostname in groups['grafana']
- include: start.yml
when: remove_containers.changed
- name: Restart containers
kolla_docker:
name: "grafana"
action: "restart_container"
when:
- config_strategy == 'COPY_ALWAYS'
- inventory_hostname in groups['grafana']

View File

@ -0,0 +1,2 @@
---
- include: "{{ action }}.yml"

View File

@ -0,0 +1,7 @@
---
- name: Pulling grafana image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ grafana_image_full }}"
when: inventory_hostname in groups['grafana']

View File

@ -0,0 +1,3 @@
---
- include: do_reconfigure.yml
when: inventory_hostname in groups['grafana']

View File

@ -0,0 +1,13 @@
---
- name: Starting grafana container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ grafana_image_full }}"
name: "grafana"
volumes:
- "{{ node_config_directory }}/grafana/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "grafana:/var/lib/grafana/"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['grafana']

View File

@ -0,0 +1,6 @@
---
- include: config.yml
- include: bootstrap.yml
- include: start.yml

View File

@ -0,0 +1,38 @@
[paths]
data = /var/lib/grafana
logs = /var/log/kolla/grafana
plugins = /var/lib/grafana/plugins
[server]
protocol = http
http_addr = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}
http_port = 3000
router_logging = true
static_root_path = public
enable_gzip = false
[database]
type = mysql
host = {{ grafana_database_address }}
name = {{ grafana_database_name }}
user = {{ grafana_database_user }}
password = {{ grafana_database_password }}
ssl_mode = disable
[session]
provider = memcache
provider_config = {% for host in groups['memcached'] %}{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ memcached_port }}{% if not loop.last %},{% endif %}{% endfor %}
cookie_name = grafana_sess
cookie_secure = false
session_life_time = 86400
[analytics]
reporting_enabled = false
check_for_updates = false
[security]
admin_user = admin
admin_password = {{ grafana_admin_password }}

View File

@ -0,0 +1,11 @@
{
"command": "/usr/sbin/grafana-server --config=/etc/grafana/grafana.ini",
"config_files": [
{
"source": "{{ container_config_directory }}/grafana.ini",
"dest": "/etc/grafana/grafana.ini",
"owner": "grafana",
"perm": "0600"
}
]
}

View File

@ -314,6 +314,14 @@
tags: watcher, tags: watcher,
when: enable_watcher | bool } when: enable_watcher | bool }
- hosts:
- grafana
serial: '{{ "30%" if action == "upgrade" else "0" }}'
roles:
- { role: grafana,
tags: grafana,
when: enable_grafana | bool }
- hosts: - hosts:
- cloudkitty-api - cloudkitty-api
- cloudkitty-processor - cloudkitty-processor

View File

@ -121,6 +121,7 @@ kolla_internal_vip_address: "10.10.10.254"
#enable_cinder_backend_lvm: "no" #enable_cinder_backend_lvm: "no"
#enable_cloudkitty: "no" #enable_cloudkitty: "no"
#enable_congress: "no" #enable_congress: "no"
#enable_grafana: "no"
#enable_heat: "yes" #enable_heat: "yes"
#enable_horizon: "yes" #enable_horizon: "yes"
#enable_influxdb: "no" #enable_influxdb: "no"

View File

@ -30,6 +30,9 @@ barbican_keystone_password:
keystone_admin_password: keystone_admin_password:
keystone_database_password: keystone_database_password:
grafana_database_password:
grafana_admin_password:
glance_database_password: glance_database_password:
glance_keystone_password: glance_keystone_password: