ansible icon indicating copy to clipboard operation
ansible copied to clipboard

Wrong binary is uploaded when deploying to multiple architectures

Open mjaschen opened this issue 1 year ago • 3 comments

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-arm64 etc.
  • adjust the src setting for the copy task, so that it picks up the correct file for the target machine

mjaschen avatar May 22 '24 10:05 mjaschen

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.

gitperr avatar May 29 '24 19:05 gitperr

My suggestion for now would be to group the architectures and then have different tasks in the playbook targeting the different groups.

gardar avatar May 29 '24 20:05 gardar

Yep, this is a problem that can be solved by maintaining your inventory in a peculiar way. ☝️

gitperr avatar May 29 '24 23:05 gitperr