cloudalchemy / ansible-node-exporter

Provision basic metrics exporter for prometheus monitoring tool
MIT License
501 stars 270 forks source link

node_exporter can not be updated when node_exporter_binary_local_dir is set #160

Closed appliedprivacy closed 4 years ago

appliedprivacy commented 4 years ago

What happened?

After changing

node_exporter_binary_local_dir: node_exporter-1.0.0.linux-amd64

to

node_exporter_binary_local_dir: node_exporter-1.0.1.linux-amd64

I somewhat expected the role to copy the new version to the servers, but install.yml is ignored after the first playbook run and the version on the servers is not updated.

Moving the task "propagate locally distributed node_exporter binary" from install.yml to main.yml right after the install.yml import would solve this.

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

- hosts: server
  roles:
    - ansible-node-exporter
  vars:
    node_exporter_binary_local_dir: /home/user/prometheus_bin/node_exporter-1.0.0.linux-amd64

then run this playbook:

- hosts: server
  roles:
    - ansible-node-exporter
  vars:
    node_exporter_binary_local_dir: /home/user/prometheus_bin/node_exporter-1.0.1.linux-amd64

Environment

0.21.0

Task is skipped on second run since the node_exporter file exists on the server already:

TASK [ansible-node-exporter : Propagate node_exporter binaries] ********************************************************************************************
skipping: [server]
paulfantom commented 4 years ago

I think adding or (node_exporter_binary_local_dir != "") to the list of conditions in https://github.com/cloudalchemy/ansible-node-exporter/blob/master/tasks/main.yml#L10 should solve the issue.

Could you create a PR?

appliedprivacy commented 4 years ago

thanks for proposing this solution, I tested it and it does what it should do