Closed acaz closed 1 year ago
This fixes the problem:
- import_tasks: install.yml
become: true
when:
( not __node_exporter_is_installed.stat.exists ) or
( __node_exporter_current_version_output.stdout_lines | length >0 and __node_exporter_current_version_output.stdout_lines[0].split(" ")[2] != node_exporter_version ) or
( __node_exporter_current_version_output.stderr_lines | length >0 and __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
Duplicate of #230
This role has been deprecated in favor of a the prometheus-community/ansible collection.
What happened? After updating role to version 2.0.0 and applying/upgrading node_exporter_version: 1.2.0 with success, role cannot be re-applied The role failed on checking condition :
TASK [cloudalchemy-ansible-node-exporter : Create the node_exporter group] ******************************************************************************************************************************************************************* fatal: [prod-v1-bastion-0]: 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 '/Users/arnaud/git/git.podk.io/ansible-ausha/roles/cloudalchemy-ansible-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"}
It issues while evaluating :
__node_exporter_current_version_output.stderr_lines[0].split(\" \")[2] != node_exporter_version
stderr is evaluated , should be stdout with node_exporter version 1.2.0
I have replaced with :
__node_exporter_current_version_output.stdout_lines[0].split(\" \")[2] != node_exporter_version
and it's work as expected with node_version 1.2.0tasks/main.yml :
`- import_tasks: install.yml become: true when: ( not __node_exporter_is_installed.stat.exists ) or ( __node_exporter_current_version_output.stdout_lines[0].split(" ")[2] != node_exporter_version ) or ( node_exporter_binary_local_dir | length > 0 ) tags:
Did you expect to see some different?
How to reproduce it (as minimally and precisely as possible):
every time
Environment
N/A
2.0.0
ansible 2.9.6