cloudalchemy / ansible-node-exporter

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

Refactor: Unnecessary call to github if node_exporter already installed #262

Closed cdrice closed 1 year ago

cdrice commented 2 years ago

Current logic implemented in the final block of tasks/preflight.yml (Get checksum list from github and Get checksum for {{ go_arch }} architecture) are unnecessary to execute if node_exporter is already installed and at the desired version.

Potential refactoring solutions:

1 - Move block to tasks/install.yml. Since the inclusion of this task list is dependent on "is node_exporter already at the correct version" logic in tasks/main.yml, they would only be run if installation is required.

2 - Replicate logic for calling block to only call if installation will be required. Seems smelly and not DRY, as it would require duplication of logic already present in tasks/main.yml.

3 - Further refactor "is node_exporter already at the correct version" logic currently in tasks/main.yml and use this logic to set a Boolean value which could then be inspected elsewhere (in the current preflight logic to pull the checksum list as well as the logic to include the install tasks).

Option 1 is arguably easiest. Option 2 is smelly and only mentioned for the sake of discussion. Option 3 may be most flexible, at the cost of some additional complexity. It is attractive, however, as it decouples logic from main.yml, leaving an arguably more elegant main task list for the role.

The logic for "is node_exporter already the correct version" appears to be in flux related to some other issues and PRs I see open, so I have not authored any specific update for this request.

I would happy to author a PR for whichever option (or another solution) the project maintainer prefers, if desired.

SuperQ commented 1 year ago

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