Skip to content

feature: Add Remote Download for _common and node_exporter#683

Open
c1rc0le wants to merge 1 commit intoprometheus-community:mainfrom
c1rc0le:fix/645
Open

feature: Add Remote Download for _common and node_exporter#683
c1rc0le wants to merge 1 commit intoprometheus-community:mainfrom
c1rc0le:fix/645

Conversation

@c1rc0le
Copy link
Copy Markdown
Contributor

@c1rc0le c1rc0le commented Nov 18, 2025

Following PR-499 which has not been merged due to some conflict.

Currently, the node_exporter installation process always downloads the package to the localhost, unpacks it there, and then uploads it to the remote host.

This change introduces an optional behavior to _common/install, enabling direct download to the remote host. It's now wired for use by node_exporter through the node_exporter_localhost_download variable. The default behavior for node_exporter and other binaries remains unchanged: delegate to localhost. Additionally, these updates allow for customizing the remote cache directory where the binary can be downloaded.

Issues linked :

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 18, 2025

Docs Build 📝

Thank you for contributing!✨

The docs for this PR have been published here:
https://prometheus-community.github.io/ansible/pr/683

You can compare to the docs for the main branch here:
https://prometheus-community.github.io/ansible/branch/main

The docsite for this PR is also available for download as an artifact from this run:
https://github.com/prometheus-community/ansible/actions/runs/19468365695

File changes:

Click to see the diff comparison.

NOTE: only file modifications are shown here. New and deleted files are excluded.
See the file list and check the published docs to see those files.

diff --git a/home/runner/work/ansible/ansible/docsbuild/base/_common_role.html b/home/runner/work/ansible/ansible/docsbuild/head/_common_role.html
index 6f365d7..3e15ca1 100644
--- a/home/runner/work/ansible/ansible/docsbuild/base/_common_role.html
+++ b/home/runner/work/ansible/ansible/docsbuild/head/_common_role.html
@@ -365,6 +365,22 @@ To check whether it is installed, run <code class="code docutils literal notrans
 </div></td>
 </tr>
 <tr class="row-even"><td><div class="ansible-option-cell">
+<div class="ansibleOptionAnchor" id="parameter-install--_common_remote_cache_path"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-common-role-parameter-install-common-remote-cache-path"><strong>_common_remote_cache_path</strong></p>
+<a class="ansibleOptionLink" href="#parameter-install--_common_remote_cache_path" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
+</div></td>
+<td><div class="ansible-option-cell"><p>Remote path to stash the archive and its extraction</p>
+<p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">&quot;&quot;</span></code></p>
+</div></td>
+</tr>
+<tr class="row-odd"><td><div class="ansible-option-cell">
+<div class="ansibleOptionAnchor" id="parameter-install--_common_remote_download"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-common-role-parameter-install-common-remote-download"><strong>_common_remote_download</strong></p>
+<a class="ansibleOptionLink" href="#parameter-install--_common_remote_download" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
+</div></td>
+<td><div class="ansible-option-cell"><p>Determines if the package archive is downloaded and extracted on local (false) or remote host (true)”</p>
+<p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">&quot;false&quot;</span></code></p>
+</div></td>
+</tr>
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-install--_common_system_group"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-common-role-parameter-install-common-system-group"><strong>_common_system_group</strong></p>
 <a class="ansibleOptionLink" href="#parameter-install--_common_system_group" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
diff --git a/home/runner/work/ansible/ansible/docsbuild/base/node_exporter_role.html b/home/runner/work/ansible/ansible/docsbuild/head/node_exporter_role.html
index a841aa5..8b7b06a 100644
--- a/home/runner/work/ansible/ansible/docsbuild/base/node_exporter_role.html
+++ b/home/runner/work/ansible/ansible/docsbuild/head/node_exporter_role.html
@@ -251,6 +251,22 @@ To check whether it is installed, run <code class="code docutils literal notrans
 </div></td>
 </tr>
 <tr class="row-odd"><td><div class="ansible-option-cell">
+<div class="ansibleOptionAnchor" id="parameter-main--node_exporter_remote_cache_path"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-node-exporter-role-parameter-main-node-exporter-remote-cache-path"><strong>node_exporter_remote_cache_path</strong></p>
+<a class="ansibleOptionLink" href="#parameter-main--node_exporter_remote_cache_path" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
+</div></td>
+<td><div class="ansible-option-cell"><p>Remote path to stash the archive and its extraction</p>
+<p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">&quot;/tmp/node_exporter-{{</span> <span class="pre">ansible_facts['system']</span> <span class="pre">|</span> <span class="pre">lower</span> <span class="pre">}}-{{</span> <span class="pre">_node_exporter_go_ansible_arch</span> <span class="pre">}}/{{</span> <span class="pre">node_exporter_version</span> <span class="pre">}}&quot;</span></code></p>
+</div></td>
+</tr>
+<tr class="row-even"><td><div class="ansible-option-cell">
+<div class="ansibleOptionAnchor" id="parameter-main--node_exporter_remote_download"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-node-exporter-role-parameter-main-node-exporter-remote-download"><strong>node_exporter_remote_download</strong></p>
+<a class="ansibleOptionLink" href="#parameter-main--node_exporter_remote_download" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
+</div></td>
+<td><div class="ansible-option-cell"><p>Determines if the node exporter package archive is downloaded and extracted on local (false) or remote host (true)</p>
+<p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">false</span></code></p>
+</div></td>
+</tr>
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--node_exporter_system_group"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-node-exporter-role-parameter-main-node-exporter-system-group"><strong>node_exporter_system_group</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--node_exporter_system_group" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>

@c1rc0le c1rc0le changed the title Add Remote Download for _common and node_exporter feature: Add Remote Download for _common and node_exporter Nov 18, 2025
@github-actions github-actions bot added the enhancement New feature or request label Nov 18, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 18, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 18, 2025
Signed-off-by: c1rc0le <florian@sanys.fr>
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 18, 2025
Copy link
Copy Markdown
Member

@gardar gardar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on!

Right now the PR introduces *_remote_download *_remote_cache_path variables alongside the existing *_local_cache_path ones. I don’t think we need to introduce additional cache path variables. Only one cache path is ever used for a given host, and the existing *_local_cache_path variables can already serve both cases (downloading via localhost or downloading directly on the target). Keeping the variable surface small has been a deliberate design choice in this collection to reduce complexity for users and keep long-term maintenance manageable.

We've also had previous requests for a third option: downloading on a dedicated cache host (e.g. a bastion), not just localhost vs. the target host. I think we could handle all three cases cleanly with a single variable, for example:

_common_download_host: localhost
delegate_to: "{{ _common_download_host }}"

Then users can set:

node_exporter_download_host: localhost  # (default)
node_exporter_download_host: "{{ inventory_hostname }}"  # download directly on the target
node_exporter_download_host: "cache.host"  # third-host / bastion download

Finally, this change needs to be implemented across all roles, not just node_exporter, since the logic lives in the common role and consistency across the collection is important.

@c1rc0le
Copy link
Copy Markdown
Contributor Author

c1rc0le commented Nov 18, 2025

Thanks @gardar for your comments.
I will remove _common_remote_cache_path to only keep _common_local_cache_path.

Noted for the bastion option, will change the workflow with : _common_remote_download_host.

@c1rc0le
Copy link
Copy Markdown
Contributor Author

c1rc0le commented Nov 21, 2025

I have reviewed the implementation of the bastion and noticed that it is somewhat complex, as it is not seamlessly integrated within Ansible's unarchive or copy modules. While there may be workarounds using synchronize, these might be error-prone, particularly if the bastion does not establish seamless SSH connections with the target server.

@gardar, would you agree to proceed by implementing node_exporter_download_host with localhost and the target server initially, and then explore the possibility of adding the bastion configuration as a second step?

node_exporter_download_host: localhost  # (default)
node_exporter_download_host: "{{ inventory_hostname }}"  # download directly on the target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants