Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: allow downloading of package by remote host #499

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

travisdowns
Copy link
Contributor

Currently node_exporter install always downloads the package on the localhost and unpacks it there then uploads it to the remote host.

In the case the ansible controller is at the other end of a thin network pipe, or if it may not even have access to the package URL, it may be desirable to download and unpack it on the remote host instead.

This change adds that ability as an optional behavior to _common/install and wires it up for use by node_exporter, using the node_exporter_localhost_download variable. The default for node exporter and any other binaries remains the same as before: delegate to localhost.

Fixes #389.

Copy link
Contributor

github-actions bot commented Dec 21, 2024

Docs Build 📝

Thank you for contribution!✨

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

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/12649957040

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/node_exporter_role.html b/home/runner/work/ansible/ansible/docsbuild/head/node_exporter_role.html
index 11c04c2..dd9dbd1 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
@@ -249,6 +249,14 @@ 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_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">true</span></code></p>
+</div></td>
+</tr>
+<tr class="row-even"><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>
@@ -257,7 +265,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <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;node-exp&quot;</span></code></p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--node_exporter_system_user"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-node-exporter-role-parameter-main-node-exporter-system-user"><strong>node_exporter_system_user</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--node_exporter_system_user" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -266,7 +274,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <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;node-exp&quot;</span></code></p>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--node_exporter_textfile_dir"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-node-exporter-role-parameter-main-node-exporter-textfile-dir"><strong>node_exporter_textfile_dir</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--node_exporter_textfile_dir" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -276,7 +284,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <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;/var/lib/node_exporter&quot;</span></code></p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--node_exporter_tls_server_config"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-node-exporter-role-parameter-main-node-exporter-tls-server-config"><strong>node_exporter_tls_server_config</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--node_exporter_tls_server_config" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">dictionary</span></p>
 </div></td>
@@ -284,7 +292,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <p>Keys and values are the same as in <a class="reference external" href="https://prometheus.io/docs/prometheus/latest/configuration/https/">node_exporter docs</a>.</p>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--node_exporter_version"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-node-exporter-role-parameter-main-node-exporter-version"><strong>node_exporter_version</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--node_exporter_version" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -292,7 +300,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <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;1.8.2&quot;</span></code></p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--node_exporter_web_disable_exporter_metrics"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-node-exporter-role-parameter-main-node-exporter-web-disable-exporter-metrics"><strong>node_exporter_web_disable_exporter_metrics</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--node_exporter_web_disable_exporter_metrics" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
 </div></td>
@@ -304,7 +312,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 </ul>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--node_exporter_web_listen_address"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-node-exporter-role-parameter-main-node-exporter-web-listen-address"><strong>node_exporter_web_listen_address</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--node_exporter_web_listen_address" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -312,7 +320,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <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;0.0.0.0:9100&quot;</span></code></p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--node_exporter_web_telemetry_path"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-node-exporter-role-parameter-main-node-exporter-web-telemetry-path"><strong>node_exporter_web_telemetry_path</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--node_exporter_web_telemetry_path" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>

Copy link
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!
I think the _common_delegate_to_localhost variable name is a bit too generic, how about _common_remote_download and node_exporter_remote_download etc. instead?
Also I think we should implement this in all the roles at once rather than just for the node_exporter.

@travisdowns
Copy link
Contributor Author

Also I think we should implement this in all the roles at once rather than just for the node_exporter.

Is there some efficient way to test this? I tested node_exporter (by hand, locally) but I don't think I'll be able to test all 20+ roles which rely on _common.

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 7, 2025
@travisdowns
Copy link
Contributor Author

travisdowns commented Jan 7, 2025

I think the _common_delegate_to_localhost variable name is a bit too generic, how about _common_remote_download and node_exporter_remote_download etc. instead?

Good call, I've applied your suggestion in push 19cb70e.

Subsequent pushes b793b2b and 5acb13c and f686f1b are only lint fixes (lol).

@travisdowns travisdowns requested a review from gardar January 7, 2025 10:18
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 7, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 7, 2025
Currently node_exporter install always downloads the package on the
localhost and unpacks it there then uploads it to the remote host.

In the case the ansible controller is at the other end of a thin
network pipe, or if it may not even have access to the package URL,
it may be desirable to download and unpack it on the remote host
instead.

This change adds that ability as an optional behavior to _common/install
and wires it up for use by node_exporter, using the
node_exporter_remote_download variable. The default for node exporter
and the behavior for any other roles remains the same as before:
delegate to localhost.

Fixes prometheus-community#389.

Signed-off-by: Travis Downs <[email protected]>
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 7, 2025
@zhan9san
Copy link
Contributor

zhan9san commented Jan 8, 2025

@travisdowns

Awesome. LGTM

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