Merge ~xavpaice/charm-grafana:lp1964725 into charm-grafana:master

Proposed by Xav Paice
Status: Merged
Approved by: James Troup
Approved revision: 503730298dc947bf296c766c8c1ab40d3d552a41
Merged at revision: 692d0fc7c732c211d40d2f705664dae93a5f5db2
Proposed branch: ~xavpaice/charm-grafana:lp1964725
Merge into: charm-grafana:master
Prerequisite: ~xavpaice/charm-grafana:reduce_functests
Diff against target: 65 lines (+22/-3)
2 files modified
src/lib/charms/layer/grafana.py (+21/-2)
src/tests/functional/tests/tests.yaml (+1/-1)
Reviewer Review Type Date Requested Status
🤖 prod-jenkaas-bootstack (community) continuous-integration Approve
BootStack Reviewers Pending
BootStack Reviewers Pending
Review via email: mp+416778@code.launchpad.net

Commit message

Render ldap config owned by daemon user

    When installed as a snap, the LDAP config needs to be owned by root as
    the grafana user does not exist.

    Fixes-bug: LP: #1964725

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Approve (continuous-integration)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 692d0fc7c732c211d40d2f705664dae93a5f5db2

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/lib/charms/layer/grafana.py b/src/lib/charms/layer/grafana.py
2index 9c0fb16..9b452cc 100644
3--- a/src/lib/charms/layer/grafana.py
4+++ b/src/lib/charms/layer/grafana.py
5@@ -419,6 +419,24 @@ def render_ldap_ca(ldap_server_ca, ldap_ca_path):
6 )
7
8
9+def get_grafana_user(config):
10+ """Return the name of the user and group for the Grafana daemon.
11+
12+ Since the config value install_method uses apt for any value not "snap", we
13+ do the same here.
14+ Returns: dict, user and group account names.
15+
16+ """
17+ daemon_account = {
18+ "snap": {"user": "root", "group": "root"},
19+ "apt": {"user": "grafana", "group": "grafana"},
20+ }
21+ if config["install_method"] == "snap":
22+ return daemon_account["snap"]
23+ else:
24+ return daemon_account["apt"]
25+
26+
27 def render_ldap_config(config, ldap_toml_path, ldap_ca_path=None):
28 """Validate and render the ldap config file."""
29 clear_flag("ldap.config.incomplete")
30@@ -440,12 +458,13 @@ def render_ldap_config(config, ldap_toml_path, ldap_ca_path=None):
31 if ldap_ca_path:
32 render_ldap_ca(config["ldap_server_ca"], ldap_ca_path)
33 settings["ldap_ca_path"] = ldap_ca_path
34+ user_info = get_grafana_user(config)
35 render(
36 source=LDAP_TOML_TMPL,
37 target=ldap_toml_path,
38 context=settings,
39- owner="grafana",
40- group="grafana",
41+ owner=user_info["user"],
42+ group=user_info["group"],
43 perms=0o600,
44 )
45 status_set("active", "Completed configuring LDAP authentication")
46diff --git a/src/tests/functional/tests/tests.yaml b/src/tests/functional/tests/tests.yaml
47index 3410cad..11d5fe9 100644
48--- a/src/tests/functional/tests/tests.yaml
49+++ b/src/tests/functional/tests/tests.yaml
50@@ -5,6 +5,7 @@ configure:
51 - tests.setup.set_certificate
52
53 gate_bundles:
54+ - model_snap_install: focal-snap-tls
55 - model_apt_install: focal-tls
56 - model_apt_install: bionic-tls
57 - self_signed_cert: focal-self-signed-cert
58@@ -13,7 +14,6 @@ smoke_bundles:
59 dev_bundles:
60 - self_signed_cert: focal-snap-self-signed-cert
61 - model_snap_install: bionic-snap-tls
62- - model_snap_install: focal-snap-tls
63 - model_snap_install: bionic-snap
64 - model_apt_install: bionic
65 - model_snap_install: bionic-snap

Subscribers

People subscribed via source and target branches

to all changes: