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
|
.. code-block:: bash
|
||||||
|
|
||||||
cd /opt/openstack-ansible-ops/grafana
|
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
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# 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
|
- name: Deploy Grafana
|
||||||
hosts: grafana_all
|
hosts: grafana_all
|
||||||
become: true
|
become: true
|
||||||
@@ -80,56 +22,40 @@
|
|||||||
pre_tasks:
|
pre_tasks:
|
||||||
- name: Galera database block
|
- name: Galera database block
|
||||||
block:
|
block:
|
||||||
- name: Check for db password
|
- name: Setup installation variables
|
||||||
fail:
|
include_role:
|
||||||
msg: >-
|
name: openstack.osa.install_defaults
|
||||||
The database root login user is undefined
|
defaults_from: "{{ install_method }}"
|
||||||
when:
|
public: true
|
||||||
- galera_root_user is undefined
|
apply:
|
||||||
|
tags:
|
||||||
|
- always
|
||||||
|
tags:
|
||||||
|
- always
|
||||||
|
|
||||||
- name: Check for db password
|
- include_role:
|
||||||
fail:
|
name: openstack.osa.db_setup
|
||||||
msg: >-
|
vars:
|
||||||
The database root password is undefined
|
_oslodb_setup_host: "{{ grafana_db_setup_host }}"
|
||||||
when:
|
_oslodb_ansible_python_interpreter: "{{ grafana_db_setup_python_interpreter }}"
|
||||||
- galera_root_password is undefined
|
_oslodb_setup_endpoint: "{{ galera_address | default('127.0.0.1') }}"
|
||||||
|
_oslodb_databases:
|
||||||
- name: Install PyMySQL
|
- name: "{{ grafana_galera_database }}"
|
||||||
package:
|
users:
|
||||||
name: python3-pymysql
|
- username: "{{ grafana_galera_user }}"
|
||||||
|
password: "{{ grafana_db_password }}"
|
||||||
- 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] }}"
|
|
||||||
|
|
||||||
- name: Set grafana database fact
|
- name: Set grafana database fact
|
||||||
set_fact:
|
set_fact:
|
||||||
grafana_database:
|
grafana_ini: "{{ grafana_ini_database | ansible.builtin.combine(grafana_ini, recursive=true) }}"
|
||||||
type: mysql
|
vars:
|
||||||
host: "{{ galera_address }}:3306"
|
grafana_ini_database:
|
||||||
name: "{{ grafana_db_name }}"
|
grafana_database:
|
||||||
user: "{{ grafana_db_user }}"
|
type: mysql
|
||||||
password: "{{ grafana_db_password }}"
|
host: "{{ galera_address }}:3306"
|
||||||
|
name: "{{ grafana_galera_database }}"
|
||||||
|
user: "{{ grafana_galera_user }}"
|
||||||
|
password: "{{ grafana_db_password }}"
|
||||||
when:
|
when:
|
||||||
- (groups['galera_all'] | default([])) | length > 0
|
- (groups['galera_all'] | default([])) | length > 0
|
||||||
|
|
||||||
@@ -139,24 +65,4 @@
|
|||||||
state: "latest"
|
state: "latest"
|
||||||
|
|
||||||
roles:
|
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
|
- role: grafana.grafana.grafana
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
collections:
|
collections:
|
||||||
- name: grafana.grafana
|
- name: grafana.grafana
|
||||||
version: 5.6.0
|
version: 6.0.2
|
||||||
type: galaxy
|
type: galaxy
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
../../skydive/roles/make_traefik
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../skydive/roles/traefik_common
|
|
||||||
@@ -1,21 +1,25 @@
|
|||||||
# Grafana vars
|
# Grafana vars
|
||||||
grafana_db_name: grafana
|
grafana_db_setup_host: "{{ openstack_db_setup_host | default('localhost') }}"
|
||||||
grafana_db_user: grafana
|
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_db_password: SuperSecrete
|
grafana_galera_database: grafana
|
||||||
grafana_admin_password: admin
|
grafana_galera_user: grafana
|
||||||
|
# define the following variables ideally and encrypted in user_secrets.yml
|
||||||
|
grafana_db_password:
|
||||||
|
grafana_admin_password:
|
||||||
|
|
||||||
grafana_users:
|
grafana_ini:
|
||||||
allow_sign_up: False
|
users:
|
||||||
allow_org_create: false
|
allow_sign_up: false
|
||||||
auto_assign_org: false
|
allow_org_create: false
|
||||||
auto_assign_org_role: Viewer
|
auto_assign_org: true
|
||||||
default_theme: light
|
auto_assign_org_role: Viewer
|
||||||
|
default_theme: dark
|
||||||
grafana_security:
|
security:
|
||||||
admin_user: admin
|
admin_user: admin
|
||||||
admin_password: "{{ grafana_admin_password }}"
|
admin_password: "{{ grafana_admin_password }}"
|
||||||
|
server:
|
||||||
grafana_address: "{{ ansible_host }}"
|
http_addr: "{{ ansible_host }}"
|
||||||
|
root_url: https://{{ external_lb_vip_address }}:{{ grafana_ini_default.server.http_port }}/
|
||||||
|
|
||||||
grafana_plugins:
|
grafana_plugins:
|
||||||
- grafana-piechart-panel
|
- grafana-piechart-panel
|
||||||
|
|||||||
Reference in New Issue
Block a user