Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grafana role - dashboard import via provisioning is not idempotent #244

Open
tivoscappini opened this issue Jul 15, 2024 · 0 comments
Open

Comments

@tivoscappini
Copy link

tivoscappini commented Jul 15, 2024

When importing dashboards via provisioning (ie, grafana_use_provisioning is true and there are JSON files in grafana_dashboards_dir) the Grafana role will swap ownership of these files on the remote host between the "grafana" and root user, with the result that the role will always report some tasks as "changed", even when run twice in a row.

The "Import grafana dashboards" task's copy module sets the files owner to root (from "grafana") and then notifies "provisioned dashboards changed"; the "Set privileges on provisioned dashboards" handler will respond to that notification and use the file module to set the files' owner to "grafana" (from root). If you run the role again, it happens again.

We discovered this because we have Molecule testing of our own role (that imports this Grafana role) that asserts that the role is idempotent: that after running it once, running it again on the same host results in no tasks reporting that they made any changes.

We had been using an older version of this role which did not exhibit this problem; the difference seems to be that in the "Import grafana dashboards" task, the copy module did not set an owner: so the module would simply allow the current owner ("grafana") to persist and report "ok" instead of "changed" (and thus also not notify the handler).

It appears #167 added the additional configuration for owner: (and group:) to the copy module to fix what the PR calls a "small ownership issue" but I couldn't find any other details about what circumstances prompted the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant