Git Product home page Git Product logo

grafana / grafana-ansible-collection Goto Github PK

View Code? Open in Web Editor NEW
84.0 13.0 53.0 7.74 MB

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

Home Page: https://docs.ansible.com/ansible/latest/collections/grafana/grafana/index.html#plugins-in-grafana-grafana

License: GNU General Public License v3.0

Python 65.95% Makefile 2.80% Jinja 14.52% Shell 16.73%
ansible grafana infrastructure-as-code ansible-collection monitoring observability ansible-galaxy ansible-role development devops

grafana-ansible-collection's Introduction

Ansible Collection for Grafana

Grafana Ansible Collection GitHub tag GitHub Last Commit GitHub Contributors

This collection (grafana.grafana) contains modules and roles to assist in automating the management of resources in Grafana, Grafana Agent, and OpenTelemetry Collector with Ansible.

Ansible version compatibility

The collection is tested and supported with: ansible >= 2.9

Installing the collection

Before using the Grafana collection, you need to install it using the below command:

ansible-galaxy collection install grafana.grafana

You can also include it in a requirements.yml file and install it via ansible-galaxy collection install -r requirements.yml, using the format:

---
collections:
  - name: grafana.grafana

A specific version of the collection can be installed by using the version keyword in the requirements.yml file:

---
collections:
  - name: grafana.grafana
    version: 1.0.0

Roles included in the collection

This collection includes the following roles to help set up and manage Grafana, Grafana Agent, and OpenTelemetry Collector:

  • Grafana: Installs and configures Grafana on your target hosts.
  • Grafana Agent: Deploys and configures Grafana Agent, allowing for efficient metrics, logs, and trace data shipping to Grafana Cloud or other endpoints.
  • OpenTelemetry Collector: Sets up and configures the OpenTelemetry Collector, enabling advanced observability features through data collection and transmission.

Using this collection

You can call modules by their Fully Qualified Collection Namespace (FQCN), such as grafana.grafana.cloud_stack:

- name: Using grafana collection
  hosts: localhost
  tasks:
    - name: Create a Grafana Cloud stack
      grafana.grafana.cloud_stack:
        name: mystack
        stack_slug: mystack
        org_slug: myorg
        cloud_api_key: "{{ cloud_api_key }}"
        region: eu
        state: present

or you can add full namespace and collection name in the collections element in your playbook

- name: Using grafana collection
  hosts: localhost
  collection:
    - grafana.grafana
  tasks:
    - name: Create a Grafana Cloud stack
      cloud_stack:
        name: mystack
        stack_slug: mystack
        org_slug: myorg
        cloud_api_key: "{{ cloud_api_key }}"
        region: eu
        state: present

Contributing

We are accepting GitHub pull requests and issues. There are many ways in which you can participate in the project, for example:

  • Submit bugs and feature requests, and help us verify them
  • Submit and review source code changes in GitHub pull requests
  • Add new modules for more Grafana resources

Testing and Development

If you want to develop new content for this collection or improve what is already here, the easiest way to work on the collection is to clone it into one of the configured COLLECTIONS_PATHS, and work on it there.

Testing with ansible-test

We use ansible-test for sanity.

Commands

Command Description
make setup Checks to see if necessary tools are installed
make install Installs project dependencies
make lint Performs all linting commands
make lint-sh / make lint-shell Performs shell script linting
make lint-md / make lint-markdown Performs Markdown linting
make lint-txt / make lint-text Performs text linting
make lint-yml / make lint-yaml Performs Yaml linting
make lint-ec / make lint-editorconfig Performs EditorConfig Checks
make lint-ansible Performs Ansible linting
make clean Removes the ./node_modules and ./build directories
make reinstall Shortcut to make clean and make install

Releasing, Versioning and Deprecation

This collection follows Semantic Versioning. More details on versioning can be found in the Ansible docs.

We plan to regularly release new minor or bugfix versions once new features or bugfixes have been implemented.

Releasing the current major version on GitHub happens from the main branch by the GitHub Release Workflow. Before the GitHub Release Workflow is run, Contributors should push the new version on Ansible Galaxy Manually.

To generate changelogs for a new release, Refer Generating Changelogs

To generate the tarball to be uploaded on Ansible Galaxy, Refer Building collection tarball

Code of Conduct

This collection follows the Ansible project's Code of Conduct. Please read and familiarize yourself with this doc

More information

License

GPL-3.0-or-later

grafana-ansible-collection's People

Contributors

0x46616c6b avatar amandacameron avatar andrewpaglusch avatar bentonam avatar boschung-mecatronic-ag-infrastructure avatar dependabot[bot] avatar dergudzon avatar do1jlr avatar elkozmon avatar fabiiw05 avatar gardar avatar hypery2k avatar ishanjainn avatar normanjs avatar ohdearaugustin avatar pablocastellano avatar pierresebastien avatar romainmou avatar thesuess avatar v-zhuravlev avatar valiyvvv avatar vlzzz avatar zxyz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grafana-ansible-collection's Issues

Important information for collection maintainers that is going to be included in the Ansible package

Dear maintainers,
as the collection will get included very soon, could you all please:

  • Subscribe to the news-for-maintainers repo and track announcements there. The ansible-core folks publish there changes related to CI (and not only) and actions need to bee done in order to keep the runs green. Otherwise, your CI will get red one day in PRs for unclear reasons.
  • Optionally but highly recommended, subscribe to Bullhorn. Feel free to leverage it when you need community's feedback or for important announcements like new releases of this collection.
  • We have the Maintainer guidelines. Might be useful to take a look.
  • Share the above with future maintainers.
  • I would suggest putting the above info in README or reflect this another way, up to you.

Thanks!

Remove trailing slash automatically

It's documented that the grafana_url must not contain a trailing slash. Removing it automatically would be easier for users who just copy their instance URL from e.g a browser

grafana.grafana.grafana_agent downloads wrong binary

I am trying to install the grafana agent, however the following playbook installs the amd64 binary although it should probably pull the armv6 binary from Github.

ansible neon -m ansible.builtin.setup -i inventory.yaml | grep "architecture" prints the actual architecture:

"ansible_architecture": "armv6l",

Playbook:

---
- hosts: neon
  become: true
  roles:
  - grafana.grafana.grafana_agent
  vars:
    agent_config_local_path: agent-config.yml

Verbose logs show:

"url": "https://github.com/grafana/agent/releases/download/v0.29.0/agent-linux-amd64.zip",`

Accordingly sudo journalctl -u grafana-agent shows:

systemd[1]: Started Grafana Agent.
systemd[15197]: grafana-agent.service: Failed to execute /usr/local/bin/agent-linux-amd64: Exec format error
systemd[15197]: grafana-agent.service: Failed at step EXEC spawning /usr/local/bin/agent-linux-amd64: Exec format error
systemd[1]: grafana-agent.service: Main process exited, code=exited, status=203/EXEC
systemd[1]: grafana-agent.service: Failed with result 'exit-code'.

Provisioning errors in YAML

When using grafana_alert_notifications the resulting YAMLs are looking like this, e.g. /etc/grafana/provisioning/notification/ansible.yml :

apiVersion: 1
"
...
"

But it should be:

apiVersion: 1

...

Deleting datasources does not work reliably

The following snippet works to create a datasource, but by changing the state to absent, the datasource is not deleted and it returns an error:

  - name: Create/Update Data sources
    grafana.grafana.datasource:
        dataSource: 
          {
            "name": "Prometheus",
            "type": "prometheus",
            "access": "proxy",
            "url": "http://localhost:9090",
            "jsonData": {
              "httpMethod": "POST",
              "manageAlerts": true,
              "prometheusType": "Prometheus",
              "cacheLevel": "High"
            }
          }
        grafana_url: "http://localhost:3001"
        grafana_api_key: "..."
        state: absent
TASK [Create/Update Data sources] *********
fatal: [localhost]: FAILED! => {"changed": false, "msg": {"response": "id is invalid", "status": 400}}

Outdated APT setup steps for grafana role

The current Grafana role provides bad/outdated APT repository setup tasks.

All steps and issues bellow were run on Ubuntu 22.04

First of all apt key is failing and it is mentioned in this issue #81

W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://packages.grafana.com/oss/deb stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 963FA27710458545
W: Failed to fetch https://packages.grafana.com/oss/deb/dists/stable/InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 963FA27710458545

The second issue is that role by default setups outdated APT repo:

grafana_apt_repo: "deb https://packages.grafana.com/oss/deb stable main"
grafana_apt_key: "https://packages.grafana.com/gpg.key"

The newest official apt instructions https://grafana.com/docs/grafana/latest/setup-grafana/installation/debian/

Fix: Manually setup key and repo from instructions and run grafana role with grafana_manage_repo: false

The third issue is:

N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://apt.grafana.com stable InRelease' doesn't support architecture 'i386'

Fix: Add arch=amd64 to /etc/apt/sources.list.d/packages_grafana_com_oss_deb.list

deb [signed-by=/usr/share/keyrings/grafana.key arch=amd64] https://apt.grafana.com stable main

Offline Installation Support

The Ansible role grafana.grafana.grafana requires the remote machine to have internet access, which is not always a given.

Other similar Ansible roles for other programs allow disabling the installation (something like grafana_skip_install), such that I can provide my own binary (grafana_binary_local_dir), or even allow download via the local machine. Example:
cloudalchemy/ansible-prometheus#296
https://github.com/cloudalchemy/ansible-prometheus/blob/master/tasks/install.yml
https://github.com/cloudalchemy/ansible-prometheus/blob/master/molecule/alternative/prepare.yml

Grafana Datasource - wrong parameter name for community.grafana.grafana_datasource

In roles/grafana/tasks/datasources.yml there is grafana_datasource module calling from community.grafana collection in which there is wrong name of parameter:
url instead of ds_url

Here is link to comunity.grafana.grafana_datasource documentation - there is no alias for ds_url.

It cause errors like this:

TASK [grafana.grafana.grafana : Ensure datasources exist (via API)] ************
Wednesday 18 October 2023  09:42:06 -0500 (0:00:00.048)       0:01:36.556 *****
failed: [server01] (item={'name': 'prometheus', 'type': 'prometheus', 'access': 'proxy', 'url': 'https://server01:9090', 'basicAuth': True, 'basicAuthUser': 'prom_user', 'basicAuthPassword': 'prom_pass'}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "item": {
        "access": "proxy",
        "basicAuth": true,
        "basicAuthPassword": "prom_pass",
        "basicAuthUser": "prom_user",
        "name": "prometheus",
        "type": "prometheus",
        "url": https://server01:9090
    }
}

MSG:

state is present but all of the following are missing: ds_url

Grafana Agent role can not run in check mode

When trying to deploy grafana-agent to my homelab with this collection, I've noticed that this task will always fail in check mode, because the local file won't exist. Adding an ignore_errors: "{{ ansible_check_mode }}" to this task will allow the task to fail, without stopping the rest of the role's run. I would be interested in opening a PR to remdey this (For the grafana-agent role anyway) if it's requested, as I'm not sure if running in check mode is even a design goal for these roles.

Agent: extra groups are not added on the next run

this block checks that user exists:

    - name: Set whether not the user exists
      ansible.builtin.set_fact:
        __grafana_agent_user_exists: "{{ ansible_facts.getent_passwd[grafana_agent_user] is not none }}"

    - name: Add user "{{ grafana_agent_user }}"
      ansible.builtin.user:
        name: "{{ grafana_agent_user }}"
        comment: "Grafana Agent Account"
        groups: "{{ [ grafana_agent_user_group ] + grafana_agent_user_groups }}"
        system: true
        shell: "{{ grafana_agent_user_shell }}"
        createhome: "{{ grafana_agent_user_createhome }}"
      when: not __grafana_agent_user_exists and grafana_agent_user != 'root'

If you want to add grafana_user to new grafana_agent_user_groups and rerun the playbook, it would not work, as user already exists, so next step would be skipped.

WDYT, about removing __grafana_agent_user_exists set fact alltogether? Ansible would skip next user module itself due to its indempotency nature.

Not working on Debian 9

Agent's role failing with

TASK [[grafana.grafana.grafana_agent](https://[grafana.grafana.grafana_agent/) : Fail when the _grafana_agent_systemd_dir directory does not exist] ***

fatal: [localhost]: FAILED! => {"changed": false, "msg": "The _grafana_agent_systemd_dir (/usr/lib/systemd/system/) does not exist"}

For Debian 9 it's actually should be _grafana_agent_systemd_dir: /lib/systemd/system/

possible incomplete example playbook

hi,

The example playbook examples/agent-send-to-grafana-cloud.yaml contains the following vars section:

+    grafana_agent_logs_config:
+      global:
+        clients:
+          - url: https://logs-<your region>.grafana.net/loki/api/v1/push
+            basic_auth:
+              username: "1234567"    # your username / instanceID
+              password: "..."   # your grafana.com token
+      scrape_configs:
+        # scrape all of the log files in /var/log on the localhost
+        - job_name: log-files

when I run the playbook I see an error

Mar 31 18:13:37 landscape grafana-agent[1540999]: 2023/03/31 18:13:37 error loading config file /etc/grafana-agent/config.yaml: yaml: unmarshal errors:
Mar 31 18:13:37 landscape grafana-agent[1540999]:   line 52: field scrape_configs not found in type logs.config
Mar 31 18:13:37 landscape systemd[1]: grafana-agent.service: Main process exited, code=exited, status=1/FAILURE
Mar 31 18:13:37 landscape systemd[1]: grafana-agent.service: Failed with result 'exit-code'.

This example needs the addition of 'configs' as a section to clear up that error and the inclusion of 'positions_directory: "{{ grafana_agent_positions_dir }}"' to match the main configuration and clear up the next error it exposes.

adding a configs section and reflowing the config has cleared up that error

grafana_agent_logs_config:
  positions_directory: "{{ grafana_agent_positions_dir }}"
  global:
    clients:
      - url: https://logs-prod-eu-west-0.grafana.net/loki/api/v1/push
        basic_auth:
          username: "123456"    
          # Cloud access token
          password: """
  configs:
    - name: local
      scrape_configs:
        # scrape all of the log files in /var/log on the localhost
        - job_name: log-files

Tasks

No tasks being tracked yet.

grafana_agent_wal_dir should be changed?

Current default is
grafana_agent_wal_dir: "{{ grafana_agent_data_dir }}/data
it is the same for positions file:

# positions directory to use, should be a sub-folder of grafana_agent_data_dir, will automatically be created when the agent starts
grafana_agent_positions_dir: "{{ grafana_agent_data_dir }}/data"

This config could give errors like:

May 29 09:02:24 cltr-1 grafana-agent[37510]: ts=2023-05-29T06:02:24.759676959Z caller=cleaner.go:203 level=warn agent=prometheus component=cleaner msg="unable to find segment mtime of WAL" name=/var/lib/grafana-agent/data/logs err="unable to open WAL: open /var/lib/grafana-agent/data/logs/wal: no such file or directory"
May 29 09:32:24 cltr-1 grafana-agent[37510]: ts=2023-05-29T06:32:24.769592232Z caller=cleaner.go:203 level=warn agent=prometheus component=cleaner msg="unable to find segment mtime of WAL" name=/var/lib/grafana-agent/data/logs err="unable to open WAL: open /var/lib/grafana-agent/data/logs/wal: no such file or directory"
May 29 10:02:24 cltr-1 grafana-agent[37510]: ts=2023-05-29T07:02:24.758554691Z caller=cleaner.go:203 level=warn agent=prometheus component=cleaner msg="unable to find segment mtime of WAL" name=/var/lib/grafana-agent/data/logs err="unable to open WAL: open /var/lib/grafana-agent/data/logs/wal: no such file or directory"
May 29 10:32:24 cltr-1 grafana-agent[37510]: ts=2023-05-29T07:32:24.760306305Z caller=cleaner.go:203 level=warn agent=prometheus component=cleaner msg="unable to find segment mtime of WAL" name=/var/lib/grafana-agent/data/logs err="unable to open WAL: open /var/lib/grafana-agent/data/logs/wal: no such file or directory"


as cleaner.go would try to search for wals in log related directories. Looks like subdirectories should be creaed for wal and logs.

grafana agent role doesn't update user groups

Updating variable grafana_agent_user_groups is ignored if grafana-agent is already installed, so it's not possible to add existing grafana-agent user to new user groups.

This happens due to this check:

in tasks/preflight.yaml:

- name: Set whether or not to do the install
  ansible.builtin.set_fact:
    __grafana_agent_do_install: >-
      {{ not __grafana_agent_is_installed.stat.exists or __grafana_agent_installed_version is version_compare(grafana_agent_version, '<') }}

- name: Do install
  ansible.builtin.debug:
    var: __grafana_agent_do_install

so user creation/update task is not run (which is a part of install procedure)

I think it's best to remove this check as well, and use ansible native idempotency feature.

Make adding grafana to log-reading group a role option

Hi,
Just a suggestion:

Following installation I'm seeing a lot of errors about file access, eg

Mar 31 18:34:24 landscape grafana-agent[1544236]: ts=2023-03-31T07:34:24.848501667Z caller=filetarget.go:335 level=error component=logs logs_config=local msg="failed to start tailer" error="open /var/log/mail.log: permission denied" filename=/var/log/mail.log

This is because those logs are readable by 'adm' group but grafana agent isn't in it. It would be nice if there was a flag to turn on adding grafana to the relevant group, either a bool or a way to specify additional groups grafana should be added to.

thanks
kk

if agent version is not defined in agent role - it fails to download

null_resource.ansible-plays (local-exec): ok: [] => {
null_resource.ansible-plays (local-exec): "_grafana_agent_download_url": "https://github.com/grafana/agent/releases/download/v/grafana-agent-linux-amd64.zip"
null_resource.ansible-plays (local-exec): }

null_resource.ansible-plays (local-exec): fatal: [-> localhost]: FAILED! => {"attempts": 5, "changed": false, "dest": "/tmp/grafana-agent/grafana-agent.zip", "elapsed": 0, "msg": "Request failed", "response": "HTTP Error 404: Not Found", "status_code": 404, "url": "https://github.com/grafana/agent/releases/download/v/grafana-agent-linux-amd64.zip"}

please disregard terraform output, it just launches ansible playbook

also i believe that defining version as latest - it constructs wrong url as well

The collections doesn't support Flow mode even though the changelog says it should

Hi!

With the 2.0.0 release Major change Support for Grafana Agent Flow was introduced.
However, this seems only to set the environment variable AGENT_MODE=flow and the passes all unsupported arguments like --config.file, --config.expand-env, etc. which makes grafana-agent.service fail.
hardcoded --config.file argument in template - https://github.com/grafana/grafana-ansible-collection/blob/main/roles/grafana_agent/templates/grafana-agent.service.j2

image

Journalctl logs example:

-- Unit grafana-agent.service has finished starting up.
--
-- The start-up result is done.
Apr 26 23:06:05 <my_hostname> grafana-agent[28467]: Error: unknown flag: --config.expand-env
Apr 26 23:06:05 <my_hostname> systemd[1]: grafana-agent.service: Main process exited, code=exited, status=1/FAILURE
Apr 26 23:06:05 <my_hostname> systemd[1]: grafana-agent.service: Unit entered failed state.
Apr 26 23:06:05 <my_hostname> systemd[1]: grafana-agent.service: Failed with result 'exit-code'.
Apr 26 23:06:05 <my_hostname> systemd[1]: grafana-agent.service: Service hold-off time over, scheduling restart.
Apr 26 23:06:05 <my_hostname> systemd[1]: Stopped Grafana Agent.
-- Subject: Unit grafana-agent.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit grafana-agent.service has finished shutting down.

May you please elaborate on how could I take the advantage of newly introduced Support for Grafana Agent Flow using this collection?

Deleting folders is not idempotent

When setting a folder state to absent, running the playbook twice results in an error as the 404 status code is interpreted as an error

Role execution continues if curl isn't installed

At this line, curl is required to collect the current latest version from the GitHub repository. However, if curl is not present on the machine this will fail silently and continue until the role attempts to download the agent from GitHub. At this point, it does not have the version number and will fail, but it's not immediately clear that it was the lack of curl that caused the failure as there is quite a lot of logging between the actual failure and failure of the role.

curl -s https://api.github.com/repos/{{ _grafana_agent_github_org }}/{{ _grafana_agent_github_repo }}/releases/latest \

Using 'grafana_dashboards_dir' not working anymore

When using grafana_dashboards_dir, the following error occurs:

TASK [grafana.grafana.grafana : Import grafana dashboards] 
fatal: [****]: FAILED! => {"msg": "'dict object' has no attribute 'path'. 'dict object' has no attribute 'path'"}

The reason is that __tmp_dashboards is not defined anymore.

The 'when' statement was around the "Download grafana dashboard...' step initially:
https://github.com/cloudalchemy/ansible-grafana/blob/b77b25607003c4cd9fd03091d03119d1dc8c2700/tasks/dashboards.yml#L27

But now you have moved it so that it covers the whole block, what destroys the functionality of "grafana_dashboards_dir" and makes predefined dashboards unusable.

when: "grafana_dashboards | length > 0"

Please fix the issue and move the 'when' back where it was :-)
Thx.

Update Release Workflow

Add the below tasks to the Release CI

  • Update Changelogs
  • Generate collection tar
  • Upload tar to Ansible Galaxy
  • Check if new version is available in Galaxy
  • Create a New GitHub Release

grafana agent role doesn't fail if version number cannot be obtained from github

We run the our ansible playbook that has the grafana agent role from a docker container. The was not able to get the latest version of the agent but the role happily kept running until it attempted to download the agent from github with an invalid url. In this case, it was because the localhost executing the playbook did not have curl installed when attempting to get the latest version number from github. However, i could see if failing for other reasons (no network access, etc).

The playbook should fail if the latest version cannot be obtained for any reason before proceeding.

Getting latest version not failing:

TASK [grafana.grafana.grafana_agent : Get the latest published Grafana Agent] ******************************************************************************************************************************************************
ok: [myhost -> localhost] => {
    "changed": false,
    "cmd": "curl -s https://api.github.com/repos/grafana/agent/releases/latest  | grep -m 1 tag_name  | cut -d '\"' -f 4 | cut -c 2-\n",
    "delta": "0:00:00.002951",
    "end": "2023-09-12 15:37:02.932180",
    "invocation": {
        "module_args": {
            "_raw_params": "curl -s https://api.github.com/repos/grafana/agent/releases/latest  | grep -m 1 tag_name  | cut -d '\"' -f 4 | cut -c 2-\n",
            "_uses_shell": true,
            "argv": null,
            "chdir": null,
            "creates": null,
            "executable": null,
            "removes": null,
            "stdin": null,
            "stdin_add_newline": true,
            "strip_empty_ends": true,
            "warn": false
        }
    },
    "msg": "",
    "rc": 0,
    "start": "2023-09-12 15:37:02.929229",
    "stderr": "/bin/sh: 1: curl: not found",
    "stderr_lines": [
        "/bin/sh: 1: curl: not found"
    ],
    "stdout": "",
    "stdout_lines": []
}

TASK [grafana.grafana.grafana_agent : Set the Grafana Agent version] ***************************************************************************************************************************************************************
ok: [myhost] => {
    "ansible_facts": {
        "grafana_agent_version": ""
    },
    "changed": false
}

TASK [grafana.grafana.grafana_agent : Grafana Agent version to download] ***********************************************************************************************************************************************************
skipping: [myhost] => {}

TASK [grafana.grafana.grafana_agent : Set the Grafana Agent download URL] **********************************************************************************************************************************************************
ok: [myhost] => {
    "ansible_facts": {
        "_grafana_agent_download_url": "https://github.com/grafana/agent/releases/download/v/grafana-agent-linux-amd64.zip"
    },
    "changed": false
}

TASK [grafana.grafana.grafana_agent : Grafana Agent download URL] ******************************************************************************************************************************************************************
ok: [myhost] => {
    "_grafana_agent_download_url": "https://github.com/grafana/agent/releases/download/v/grafana-agent-linux-amd64.zip"
}

Failing to download many steps later:

TASK [grafana.grafana.grafana_agent : Download Grafana Agent archive to local folder] **********************************************************************************************************************************************
...snip...
FAILED - RETRYING: [myhost -> localhost]: Download Grafana Agent archive to local folder (5 retries left).Result was: {
...snip...
FAILED - RETRYING: [myhost -> localhost]: Download Grafana Agent archive to local folder (4 retries left).Result was: {
...snip...
FAILED - RETRYING: [myhost -> localhost]: Download Grafana Agent archive to local folder (3 retries left).Result was: {
...snip...
FAILED - RETRYING: [myhost -> localhost]: Download Grafana Agent archive to local folder (2 retries left).Result was: {
...snip...
FAILED - RETRYING: [myhost -> localhost]: Download Grafana Agent archive to local folder (1 retries left).Result was: {
...snip...
fatal: [myhost -> localhost]: FAILED! => {
    "attempts": 5,
    "changed": false,
    "dest": "/tmp/grafana-agent/grafana-agent_amd64_.zip",
    "elapsed": 0,
    "invocation": {
        "module_args": {
            "attributes": null,
            "backup": false,
            "checksum": "",
            "client_cert": null,
            "client_key": null,
            "dest": "/tmp/grafana-agent/grafana-agent_amd64_.zip",
            "force": false,
            "force_basic_auth": false,
            "group": null,
            "headers": null,
            "http_agent": "ansible-httpget",
            "mode": 436,
            "owner": null,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "sha256sum": "",
            "timeout": 10,
            "tmp_dest": null,
            "unredirected_headers": [],
            "unsafe_writes": false,
            "url": "https://github.com/grafana/agent/releases/download/v/grafana-agent-linux-amd64.zip",
            "url_password": null,
            "url_username": null,
            "use_gssapi": false,
            "use_proxy": true,
            "validate_certs": true
        }
    },
    "msg": "Request failed",
    "response": "HTTP Error 404: Not Found",
    "status_code": 404,
    "url": "https://github.com/grafana/agent/releases/download/v/grafana-agent-linux-amd64.zip"
}

Seperate Ansible Plugin Integration tests from Role tests

Issue:
The CI Test(ci-test.yml GitHub Action) was initially build to test plugins in PRs quickly against a single linux architectures.
The integration-test.yml was instead build to do a complete test of plugins against various linux architectures.
Now that we have the grafana role(Agent role currently doesnt have any testing), The ci-test.yml takes a lot of time time complete (>40 mins). Instead it would be nice to seperate the plugin tests from role tests.

Incomplete Solution:
We can add a individual steps in action to run integration tests for particular plugin but that looks a bit manual. Is there a simpler way to separate the two tests(plugin vs role)

Tagging @gardar if you know a simpler method for separating the grafana role tests or maybe speed up the grafana role test?

Destination directory /etc/grafana/provisioning/notification does not exist

While running the grafana.grafana.grafana role, I got this error:

TASK [grafana.grafana.grafana : Create/Delete/Update alert notifications channels (provisioning)] 
*************************************************************************************************
fatal: [monitoring.example.com]: FAILED! => changed=false 
  checksum: d24df112c52fb029a4bc751e36cddd9b6dac12cb
  msg: Destination directory /etc/grafana/provisioning/notification does not exist

I assume, the directory is somehow missing in this list: https://github.com/grafana/grafana-ansible-collection/blob/main/roles/grafana/tasks/configure.yml#L10-L24

Error on dashboard rollout

When trying to rollout dashboards I'm getting this error:


TASK [grafana.grafana.grafana : Create local grafana dashboard directory] **************************************************************************************************************************************************************************************************************************************************************************************************
skipping: [share]

TASK [grafana.grafana.grafana : Download grafana dashboard from grafana.net to local directory] ****************************************************************************************************************************************************************************************************************************************************************************
fatal: [share -> localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'path'\n\nThe error appears to be in '/private/tmp/share/ansible/collections/ansible_collections/grafana/grafana/roles/grafana/tasks/dashboards.yml': line 18, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  block:\n    - name: \"Download grafana dashboard from grafana.net to local directory\"\n      ^ here\n"}

apt_key is deprecated

I'm glad to have found this collection! I have been putting band-aids on the cloudalchemy role for some time. I need to find a better way to surface community collections like this.

The apt_key module results in a deprecation error on Ubuntu 22.04:

# apt-get update
...
Reading package lists... Done
W: https://packages.grafana.com/oss/deb/dists/stable/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.

geerlingguy has an article for fixing this. Basically, save the armored key as an .asc file, cite it in the signature list and you're golden. I run this before I run the role:

  pre_tasks:
    - name: Add grafana apt repository key.
      ansible.builtin.get_url:
        url: "{{ grafana_apt_key_url }}"
        dest: /usr/share/keyrings/grafana.asc
        mode: '0644'
      tags: grafana
      become: yes

    - name: Ensure the repository is added with the relevant trusted GPG key
      ansible.builtin.lineinfile:
        path: /etc/apt/sources.list.d/grafana.list
        regexp: 'apt.grafana.org'
        line: "deb [arch=amd64 signed-by=/usr/share/keyrings/grafana.asc] https://apt.grafana.com stable main"
        create: true
      register: grafana_repo
      become: yes
      tags: grafana

I understand the challenge will be to apply such a change only to versions of distros where apt has deprecated apt_key and not the ones that came before.

It also looks like the role is using a different repository subdomain, so I don't know what's up with that. I see apt.grafana.org on the packages page.

Consider using true/false for all booleans in docs

Based on the community decision to use true/false for boolean values in documentation and examples, we ask that you evaluate booleans in this collection and consider changing any that do not use true/false (lowercase).

See documentation block format for more info (specifically, option defaults).

If you have already implemented this or decide not to, feel free to close this issue.


P.S. This is auto-generated issue, please raise any concerns here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.