From 077e0003d41746a0052564ee1487d981f125cec9 Mon Sep 17 00:00:00 2001 From: Dawud Date: Thu, 14 Mar 2024 13:21:57 +0000 Subject: [PATCH] Change logic for plugins in grafana image build Co-authored-by: Will Szumski Change-Id: I2b1c95395aeefb2ccb1d8edf415eee0f98c52190 --- doc/source/admin/image-building.rst | 18 ++++++++++++++++++ docker/grafana/Dockerfile.j2 | 7 +++++-- ...merge-grafana-plugins-b9a837b9fccff691.yaml | 8 ++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/merge-grafana-plugins-b9a837b9fccff691.yaml diff --git a/doc/source/admin/image-building.rst b/doc/source/admin/image-building.rst index f0c0e84c11..9f47d47015 100644 --- a/doc/source/admin/image-building.rst +++ b/doc/source/admin/image-building.rst @@ -298,6 +298,23 @@ To remove a package from that list, say ``locales``, one would do: # Horizon {% set horizon_packages_remove = ['locales'] %} +An example of this is the Grafana plugins, which are mentioned in the next +section. + +Grafana plugins +^^^^^^^^^^^^^^^ + +Additional Grafana plugins can be installed by adding the plugin name to the +``grafana_plugins_append`` list. Plugins can also be removed by adding the +plugin name to the ``grafana_plugins_remove`` list. Additionally the entire +list can be overridden by setting the ``grafana_plugins_override`` variable. + +.. code-block:: ini + + grafana_plugins_append: + - grafana-piechart-panel + - vonage-status-panel + Python packages build options ----------------------------- @@ -401,6 +418,7 @@ Some of these plugins used to be enabled by default but, due to their release characteristic, have been excluded from the default builds. Please read the included ``README.rst`` to learn how to apply them. + Additions functionality ----------------------- diff --git a/docker/grafana/Dockerfile.j2 b/docker/grafana/Dockerfile.j2 index cd4e945402..a769945e4c 100644 --- a/docker/grafana/Dockerfile.j2 +++ b/docker/grafana/Dockerfile.j2 @@ -22,9 +22,12 @@ COPY extend_start.sh /usr/local/bin/kolla_extend_start {% block grafana_plugins_install %} -RUN grafana-cli plugins install gnocchixyz-gnocchi-datasource \ - && grafana-cli plugins install grafana-opensearch-datasource +{% set grafana_default_plugins = ['gnocchixyz-gnocchi-datasource', 'grafana-opensearch-datasource'] %} +{% set grafana_plugins = grafana_default_plugins | customizable("plugins") %} +{% if grafana_plugins | length > 0 %} +RUN {{ (['grafana-cli plugins install %s'] * grafana_plugins | length ) | join(' && ') | format(*grafana_plugins) }} +{% endif %} {% endblock %} RUN chmod 750 /etc/sudoers.d \ diff --git a/releasenotes/notes/merge-grafana-plugins-b9a837b9fccff691.yaml b/releasenotes/notes/merge-grafana-plugins-b9a837b9fccff691.yaml new file mode 100644 index 0000000000..db2e8279a6 --- /dev/null +++ b/releasenotes/notes/merge-grafana-plugins-b9a837b9fccff691.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + New logic for installing grafana plugins. When building you can pass a + variable ``grafana_plugins_append`` that contains a list of plugins you + want to install. This will be appended to the default list of plugins. The + existing method of overwriting the ``grafana_plugins_install`` block still + works.