kolla-ansible/ansible/roles/grafana/tasks/post_config.yml
Rafael Weingärtner f425c0678f Standardize use and construction of endpoint URLs
The goal for this push request is to normalize the construction and use
 of internal, external, and admin URLs. While extending Kolla-ansible
 to enable a more flexible method to manage external URLs, we noticed
 that the same URL was constructed multiple times in different parts
 of the code. This can make it difficult for people that want to work
 with these URLs and create inconsistencies in a large code base with
 time. Therefore, we are proposing here the use of
 "single Kolla-ansible variable" per endpoint URL, which facilitates
 for people that are interested in overriding/extending these URLs.

As an example, we extended Kolla-ansible to facilitate the "override"
of public (external) URLs with the following standard
"<component/serviceName>.<companyBaseUrl>".
Therefore, the "NAT/redirect" in the SSL termination system (HAproxy,
HTTPD or some other) is done via the service name, and not by the port.
This allows operators to easily and automatically create more friendly
 URL names. To develop this feature, we first applied this patch that
 we are sending now to the community. We did that to reduce the surface
  of changes in Kolla-ansible.

Another example is the integration of Kolla-ansible and Consul, which
we also implemented internally, and also requires URLs changes.
Therefore, this PR is essential to reduce code duplicity, and to
facility users/developers to work/customize the services URLs.

Change-Id: I73d483e01476e779a5155b2e18dd5ea25f514e93
Signed-off-by: Rafael Weingärtner <rafael@apache.org>
2020-08-19 07:22:17 +00:00

51 lines
1.4 KiB
YAML

---
- name: Wait for grafana application ready
become: true
kolla_toolbox:
module_name: uri
module_args:
url: "{{ grafana_internal_endpoint }}/login"
status_code: 200
register: result
until: result.get('status') == 200
retries: 30
delay: 2
run_once: true
- name: Enable grafana datasources
become: true
kolla_toolbox:
module_name: uri
module_args:
url: "{{ grafana_internal_endpoint }}/api/datasources"
method: POST
user: "{{ grafana_admin_username }}"
password: "{{ grafana_admin_password }}"
body: "{{ item.value.data | to_json }}"
body_format: json
force_basic_auth: yes
status_code: 200, 409
register: response
run_once: True
changed_when: response.status == 200
failed_when: response.status not in [200, 409] or
response.status == 409 and ("name already exists" not in response.json.message|default(""))
with_dict: "{{ grafana_data_sources }}"
when: item.value.enabled | bool
- name: Disable Getting Started panel
become: true
kolla_toolbox:
module_name: uri
module_args:
url: "{{ grafana_internal_endpoint }}/api/user/helpflags/1"
method: PUT
user: "{{ grafana_admin_username }}"
password: "{{ grafana_admin_password }}"
force_basic_auth: yes
status_code: 200
register: grafana_response
changed_when: grafana_response.status == 200
run_once: true
when: grafana_custom_dashboard_file.stat.exists