grafana / grafana-ansible-collection

grafana.grafana Ansible collection provides modules and roles for managing various resources on Grafana Cloud and roles to manage and deploy Grafana Agent and Grafana
https://docs.ansible.com/ansible/latest/collections/grafana/grafana/index.html#plugins-in-grafana-grafana
GNU General Public License v3.0
136 stars 87 forks source link

Loki role fails in check mode #252

Closed winsmith closed 2 months ago

winsmith commented 3 months ago

When running in check mode, the grafana.grafana.loki role fails to execute because a variable is not set. Here is the error message:


TASK [grafana.grafana.loki : Latest available Loki version] ********************
Friday 02 August 2024  13:07:53 +0000 (0:00:00.675)       0:00:18.734 ********* 
Friday 02 August 2024  13:07:53 +0000 (0:00:00.675)       0:00:18.733 ********* 
fatal: [172.31.28.208]: FAILED! => {}

MSG:

The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'json'. 'dict object' has no attribute 'json'

The error appears to be in '/opt/github-runner/.ansible/collections/ansible_collections/grafana/grafana/roles/loki/tasks/deploy.yml': line 17, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

    - name: Latest available Loki version
      ^ here

I believe the first task in the role, Scrape Github API endpoint to obtain latest Loki version, should always be run, even in check mode. This should fix the issue.

If requested, I'll gladly make a PR that adds check_mode: false to the task.

voidquark commented 3 months ago

Agreed, it should run in check mode. Could you please raise a PR?

voidquark commented 2 months ago

@winsmith any progress on this ?

winsmith commented 2 months ago

@voidquark whoops! Here you go: https://github.com/grafana/grafana-ansible-collection/pull/262

x4e-jonas commented 2 months ago

It is still failing but this time with

fatal: [***]: FAILED! => changed=false 
  msg: 'Could not find the requested service loki.service: host'
x4e-jonas commented 2 months ago

Added a fix for it in #266. Feel free to takeover from there.