Wrong binary is uploaded when deploying to multiple architectures
The wrong nginx-prometheus-exporter binary is installed with the nginx exporter role when the target servers run under multiple processor architectures.
sample from playbook:
roles:
- prometheus.prometheus.nginx_exporter
What happens if different target processor archictectures are involved?
The role downloads the archives for each architecture (nginx-prometheus-exporter_1.1.0_linux_amd64.tar.gz, nginx-prometheus-exporter_1.1.0_linux_arm64.tar.gz etc.) and extracts them – but to the same target file (/tmp/nginx-prometheus-exporter).
The upload task picks the target file and uploads it to all servers. This means that all server get the same binary.
A possible fix could look like this:
- ensure that the extracted binaries get unique names for each processor architecture, e.g.
/tmp/nginx-prometheus-exporter-amd64,/tmp/nginx-prometheus-exporter-arm64etc. - adjust the src setting for the copy task, so that it picks up the correct file for the target machine
It also might make sense to download the file on the target machine then, because we should be able to find the arch with ansible facts.
My suggestion for now would be to group the architectures and then have different tasks in the playbook targeting the different groups.
Yep, this is a problem that can be solved by maintaining your inventory in a peculiar way. ☝️