grafana.grafana works without ansible fact vars
Remove Traefik deployment as it is not necessary. Utilize openstack.osa.db_setup for database setup for Grafana. Change-Id: Ic76a94d9f8a3469661b1b46b577f2621f75ff449
This commit is contained in:
@@ -68,4 +68,4 @@ install grafana
|
||||
.. code-block:: bash
|
||||
|
||||
cd /opt/openstack-ansible-ops/grafana
|
||||
ANSIBLE_INJECT_FACT_VARS=True openstack-ansible installGrafana.yml
|
||||
openstack-ansible installGrafana.yml
|
@@ -13,64 +13,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Deploy traefik binaries
|
||||
hosts: grafana_all
|
||||
become: yes
|
||||
vars:
|
||||
traefik_binary_version: "v1.7.7"
|
||||
traefik_binary_url: "https://github.com/containous/traefik/releases/download/{{ traefik_binary_version }}/traefik"
|
||||
traefik_staging_node: "localhost"
|
||||
pre_tasks:
|
||||
- name: Create traefik temp path
|
||||
file:
|
||||
path: "/tmp/traefik/{{ ansible_architecture }}"
|
||||
state: directory
|
||||
delegate_to: "{{ traefik_staging_node }}"
|
||||
become: false
|
||||
tasks:
|
||||
- name: Refresh local facts
|
||||
setup:
|
||||
- name: Built traefik installation
|
||||
block:
|
||||
- name: Find traefik binaries
|
||||
find:
|
||||
paths: "/tmp/traefik/{{ ansible_architecture }}/"
|
||||
recurse: no
|
||||
patterns: "*traefik*"
|
||||
register: files_to_copy
|
||||
delegate_to: "{{ traefik_staging_node }}"
|
||||
run_once: true
|
||||
become: false
|
||||
- name: Install built traefik
|
||||
copy:
|
||||
src: "{{ item.path }}"
|
||||
dest: "/usr/local/bin/{{ item.path | basename }}"
|
||||
mode: "0755"
|
||||
with_items: "{{ files_to_copy.files }}"
|
||||
when:
|
||||
- ((groups['traefik_build_nodes'] | default([])) | length) > 0
|
||||
|
||||
- name: Upstream traefik installation
|
||||
block:
|
||||
- name: Get traefik binary
|
||||
get_url:
|
||||
url: "{{ traefik_binary_url }}"
|
||||
dest: "/tmp/traefik/{{ ansible_architecture }}/{{ traefik_binary_url | basename }}"
|
||||
mode: '0755'
|
||||
delegate_to: "{{ traefik_staging_node }}"
|
||||
run_once: true
|
||||
become: false
|
||||
- name: Install binary traefik
|
||||
copy:
|
||||
src: "/tmp/traefik/{{ ansible_architecture }}/{{ traefik_binary_url | basename }}"
|
||||
dest: "/usr/local/bin/traefik"
|
||||
mode: "0755"
|
||||
when:
|
||||
- ((groups['traefik_build_nodes'] | default([])) | length) < 1
|
||||
tags:
|
||||
- traefik-install
|
||||
|
||||
|
||||
- name: Deploy Grafana
|
||||
hosts: grafana_all
|
||||
become: true
|
||||
@@ -80,56 +22,40 @@
|
||||
pre_tasks:
|
||||
- name: Galera database block
|
||||
block:
|
||||
- name: Check for db password
|
||||
fail:
|
||||
msg: >-
|
||||
The database root login user is undefined
|
||||
when:
|
||||
- galera_root_user is undefined
|
||||
- name: Setup installation variables
|
||||
include_role:
|
||||
name: openstack.osa.install_defaults
|
||||
defaults_from: "{{ install_method }}"
|
||||
public: true
|
||||
apply:
|
||||
tags:
|
||||
- always
|
||||
tags:
|
||||
- always
|
||||
|
||||
- name: Check for db password
|
||||
fail:
|
||||
msg: >-
|
||||
The database root password is undefined
|
||||
when:
|
||||
- galera_root_password is undefined
|
||||
|
||||
- name: Install PyMySQL
|
||||
package:
|
||||
name: python3-pymysql
|
||||
|
||||
- name: Create DB for service
|
||||
mysql_db:
|
||||
login_user: "{{ galera_root_user }}"
|
||||
login_password: "{{ galera_root_password }}"
|
||||
login_host: "{{ galera_address | default('127.0.0.1') }}"
|
||||
name: "{{ grafana_db_name }}"
|
||||
state: "present"
|
||||
delegate_to: "{{ groups['galera_all'][0] }}"
|
||||
|
||||
- name: Grant access to the DB for the service
|
||||
mysql_user:
|
||||
login_user: "{{ galera_root_user }}"
|
||||
login_password: "{{ galera_root_password }}"
|
||||
login_host: "{{ galera_address | default('127.0.0.1') }}"
|
||||
name: "{{ grafana_db_user }}"
|
||||
password: "{{ grafana_db_password }}"
|
||||
host: "{{ item }}"
|
||||
state: "present"
|
||||
priv: "{{ grafana_db_name }}.*:ALL"
|
||||
with_items:
|
||||
- "localhost"
|
||||
- "%"
|
||||
delegate_to: "{{ groups['galera_all'][0] }}"
|
||||
- include_role:
|
||||
name: openstack.osa.db_setup
|
||||
vars:
|
||||
_oslodb_setup_host: "{{ grafana_db_setup_host }}"
|
||||
_oslodb_ansible_python_interpreter: "{{ grafana_db_setup_python_interpreter }}"
|
||||
_oslodb_setup_endpoint: "{{ galera_address | default('127.0.0.1') }}"
|
||||
_oslodb_databases:
|
||||
- name: "{{ grafana_galera_database }}"
|
||||
users:
|
||||
- username: "{{ grafana_galera_user }}"
|
||||
password: "{{ grafana_db_password }}"
|
||||
|
||||
- name: Set grafana database fact
|
||||
set_fact:
|
||||
grafana_database:
|
||||
type: mysql
|
||||
host: "{{ galera_address }}:3306"
|
||||
name: "{{ grafana_db_name }}"
|
||||
user: "{{ grafana_db_user }}"
|
||||
password: "{{ grafana_db_password }}"
|
||||
grafana_ini: "{{ grafana_ini_database | ansible.builtin.combine(grafana_ini, recursive=true) }}"
|
||||
vars:
|
||||
grafana_ini_database:
|
||||
grafana_database:
|
||||
type: mysql
|
||||
host: "{{ galera_address }}:3306"
|
||||
name: "{{ grafana_galera_database }}"
|
||||
user: "{{ grafana_galera_user }}"
|
||||
password: "{{ grafana_db_password }}"
|
||||
when:
|
||||
- (groups['galera_all'] | default([])) | length > 0
|
||||
|
||||
@@ -139,24 +65,4 @@
|
||||
state: "latest"
|
||||
|
||||
roles:
|
||||
- role: traefik_common
|
||||
environment: "{{ deployment_environment_variables | default({}) }}"
|
||||
traffic_dashboard_bind: "{{ hostvars[inventory_hostname]['ansible_' ~ (ansible_default_ipv4['interface'] | replace('-', '_') | string)]['ipv4']['address'] }}"
|
||||
traefik_dashboard_enabled: true
|
||||
traefik_destinations:
|
||||
elasticsearch:
|
||||
proto: "http"
|
||||
port: "19200"
|
||||
bind: "127.0.0.1"
|
||||
servers: |-
|
||||
{% set nodes = [] %}
|
||||
{% for target in groups['kibana'] %}
|
||||
{% set node = {} %}
|
||||
{% set _ = node.__setitem__('name', 'elasticsearch' ~ loop.index) %}
|
||||
{% set _ = node.__setitem__('address', hostvars[target]['ansible_host']) %}
|
||||
{% set _ = node.__setitem__('weight', (100 - loop.index)) %}
|
||||
{% set _ = node.__setitem__('port', "9200") %}
|
||||
{% set _ = nodes.append(node) %}
|
||||
{% endfor %}
|
||||
{{ nodes }}
|
||||
- role: grafana.grafana.grafana
|
||||
|
@@ -2,5 +2,5 @@
|
||||
|
||||
collections:
|
||||
- name: grafana.grafana
|
||||
version: 5.6.0
|
||||
version: 6.0.2
|
||||
type: galaxy
|
||||
|
@@ -1 +0,0 @@
|
||||
../../skydive/roles/make_traefik
|
@@ -1 +0,0 @@
|
||||
../../skydive/roles/traefik_common
|
@@ -1,21 +1,25 @@
|
||||
# Grafana vars
|
||||
grafana_db_name: grafana
|
||||
grafana_db_user: grafana
|
||||
grafana_db_password: SuperSecrete
|
||||
grafana_admin_password: admin
|
||||
grafana_db_setup_host: "{{ openstack_db_setup_host | default('localhost') }}"
|
||||
grafana_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((grafana_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable'])) }}"
|
||||
grafana_galera_database: grafana
|
||||
grafana_galera_user: grafana
|
||||
# define the following variables ideally and encrypted in user_secrets.yml
|
||||
grafana_db_password:
|
||||
grafana_admin_password:
|
||||
|
||||
grafana_users:
|
||||
allow_sign_up: False
|
||||
allow_org_create: false
|
||||
auto_assign_org: false
|
||||
auto_assign_org_role: Viewer
|
||||
default_theme: light
|
||||
|
||||
grafana_security:
|
||||
admin_user: admin
|
||||
admin_password: "{{ grafana_admin_password }}"
|
||||
|
||||
grafana_address: "{{ ansible_host }}"
|
||||
grafana_ini:
|
||||
users:
|
||||
allow_sign_up: false
|
||||
allow_org_create: false
|
||||
auto_assign_org: true
|
||||
auto_assign_org_role: Viewer
|
||||
default_theme: dark
|
||||
security:
|
||||
admin_user: admin
|
||||
admin_password: "{{ grafana_admin_password }}"
|
||||
server:
|
||||
http_addr: "{{ ansible_host }}"
|
||||
root_url: https://{{ external_lb_vip_address }}:{{ grafana_ini_default.server.http_port }}/
|
||||
|
||||
grafana_plugins:
|
||||
- grafana-piechart-panel
|
||||
|
Reference in New Issue
Block a user