cloudalchemy / ansible-node-exporter

Provision basic metrics exporter for prometheus monitoring tool
MIT License
500 stars 272 forks source link

With recent release of node_exporter (1.2.2) the role fails to detect version installed. #243

Closed sgargel closed 1 year ago

sgargel commented 2 years ago

What happened?

Now node_exporter --version evaluated with the above task uses stdout :

- name: Gather currently installed node_exporter version (if any)
  command: "{{ _node_exporter_binary_install_dir }}/node_exporter --version"
  args:
    warn: false
  changed_when: false
  register: __node_exporter_current_version_output
  check_mode: false
  when: __node_exporter_is_installed.stat.exists
  tags:
    - node_exporter_install
    - skip_ansible_lint

So this task should be modfied accordignly, evaluating stdout instead stderr.

- import_tasks: install.yml
  become: true
  when:
    ( not __node_exporter_is_installed.stat.exists ) or
    ( __node_exporter_current_version_output.stderr_lines[0].split(" ")[2] != node_exporter_version ) or
    ( node_exporter_binary_local_dir | length > 0 )
  tags:
    - node_exporter_install    

Did you expect to see some different?

How to reproduce it (as minimally and precisely as possible):

Environment

fatal: [xxxx]: FAILED! => {"msg": "The conditional check '( not __node_exporter_is_installed.stat.exists ) or ( __node_exporter_current_version_output.stderr_lines[0].split(\" \")[2] != node_exporter_version ) or ( node_exporter_binary_local_dir | length > 0 )' failed. 

The error was: error while evaluating conditional 
(   ( not __node_exporter_is_installed.stat.exists ) or 
    ( __node_exporter_current_version_output.stderr_lines[0].split(\" \")[2] != node_exporter_version ) or 
    ( node_exporter_binary_local_dir | length > 0 )
)

: list object has no element 0\n\nThe error appears to be in '/galaxy_roles/cloudalchemy.node-exporter/tasks/install.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: Create the node_exporter group\n  ^ here\n"}

Anything else we need to know?:

dleborgne commented 2 years ago

This looks like a duplicate of #230

kennethjor commented 2 years ago

I had the same issue. I copied the contents of main.yml into my local Ansible Galaxy install and it fixed the issue. Any chance of a release?

rcousens commented 2 years ago

This was merged in #233 but needs a release to be fixed. Currently I'm using the commit hash of latest master to workaround:

roles:
  - name: cloudalchemy.node_exporter # commit hash fixes bug in install detection issue #230
    src: https://github.com/cloudalchemy/ansible-node-exporter
    version: c2401cfed554906843520cbac7ae2a3a132c590e
davidlukac commented 2 years ago

Same issue with

ansible [core 2.13.3]
  config file = /opt/app/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /root/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /opt/app/collections
  executable location = /root/.local/bin/ansible
  python version = 3.10.6 (main, Aug  3 2022, 10:13:24) [GCC 10.2.1 20210110]
  jinja version = 3.1.2
  libyaml = True

and node_exporter version 1.3.1

Workaround by @rcousens worked, thanks man! 👍

antonr-p2p commented 1 year ago

Please release a new version!

antonr-p2p commented 1 year ago

You can find fixed version in https://github.com/prometheus-community/ansible/tree/main/roles/node_exporter

SuperQ commented 1 year ago

This role has been deprecated in favor of a the prometheus-community/ansible collection.