Skip to content

feat(cadvisor): add support for basic auth#758

Open
pdesgarets wants to merge 1 commit intoprometheus-community:mainfrom
pdesgarets:main
Open

feat(cadvisor): add support for basic auth#758
pdesgarets wants to merge 1 commit intoprometheus-community:mainfrom
pdesgarets:main

Conversation

@pdesgarets
Copy link
Copy Markdown
Contributor

Configure basic auth for CAdvisor with appropriate runtime options

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 16, 2026

Docs Build 📝

Thank you for contributing!✨

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

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

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/cadvisor_role.html b/home/runner/work/ansible/ansible/docsbuild/head/cadvisor_role.html
index a5aba2d..689f3a2 100644
--- a/home/runner/work/ansible/ansible/docsbuild/base/cadvisor_role.html
+++ b/home/runner/work/ansible/ansible/docsbuild/head/cadvisor_role.html
@@ -178,6 +178,15 @@ To check whether it is installed, run <code class="code docutils literal notrans
 </thead>
 <tbody>
 <tr class="row-even"><td><div class="ansible-option-cell">
+<div class="ansibleOptionAnchor" id="parameter-main--cadvisor_basic_auth_users"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-cadvisor-role-parameter-main-cadvisor-basic-auth-users"><strong>cadvisor_basic_auth_users</strong></p>
+<a class="ansibleOptionLink" href="#parameter-main--cadvisor_basic_auth_users" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">dictionary</span></p>
+</div></td>
+<td><div class="ansible-option-cell"><p>Dictionary of username / password for HTTP basic authentication</p>
+<p>Warning : The endpoints `/api/*` and `/metrics` are exposed without authentication. See <a class="reference external" href="https://github.com/google/cadvisor/blob/master/docs/web.md#web-ui-authentication">https://github.com/google/cadvisor/blob/master/docs/web.md#web-ui-authentication</a> and <a class="reference external" href="https://github.com/google/cadvisor/issues/3401">https://github.com/google/cadvisor/issues/3401</a> for more details.</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">{}</span></code></p>
+</div></td>
+</tr>
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--cadvisor_binary_install_dir"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-cadvisor-role-parameter-main-cadvisor-binary-install-dir"><strong>cadvisor_binary_install_dir</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--cadvisor_binary_install_dir" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -186,7 +195,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;/usr/local/bin&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--cadvisor_binary_url"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-cadvisor-role-parameter-main-cadvisor-binary-url"><strong>cadvisor_binary_url</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--cadvisor_binary_url" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -194,6 +203,14 @@ 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;https://github.com/{{</span> <span class="pre">_cadvisor_repo</span> <span class="pre">}}/releases/download/v{{</span> <span class="pre">cadvisor_version</span> <span class="pre">}}/cadvisor-v{{</span> <span class="pre">cadvisor_version</span> <span class="pre">}}-{{</span> <span class="pre">ansible_facts['system']</span> <span class="pre">|</span> <span class="pre">lower</span> <span class="pre">}}-{{</span> <span class="pre">_cadvisor_go_ansible_arch</span> <span class="pre">}}&quot;</span></code></p>
 </div></td>
 </tr>
+<tr class="row-odd"><td><div class="ansible-option-cell">
+<div class="ansibleOptionAnchor" id="parameter-main--cadvisor_config_dir"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-cadvisor-role-parameter-main-cadvisor-config-dir"><strong>cadvisor_config_dir</strong></p>
+<a class="ansibleOptionLink" href="#parameter-main--cadvisor_config_dir" 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>Directory for cAdvisor configuration files</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;/etc/cadvisor&quot;</span></code></p>
+</div></td>
+</tr>
 <tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--cadvisor_disable_metrics"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-cadvisor-role-parameter-main-cadvisor-disable-metrics"><strong>cadvisor_disable_metrics</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--cadvisor_disable_metrics" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">list</span> / <span class="ansible-option-elements">elements=string</span></p>

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 16, 2026
Copy link
Copy Markdown
Contributor

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

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

Nice, would you mind adding a basic auth user and test to roles/cadvisor/molecule/alternative/molecule.yml and roles/cadvisor/molecule/alternative/tests/test_alternative.py?

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 16, 2026
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, looks good, just need to make sure the tasks are tagged for those that want to be able to skip or only run the config tasks.

And perhaps it would be worth noting in the argument specs that unlike the other exporters the basic auth does not secure the /metrics endpoint google/cadvisor#3401

@pdesgarets
Copy link
Copy Markdown
Contributor Author

And perhaps it would be worth noting in the argument specs that unlike the other exporters the basic auth does not secure the /metrics endpoint google/cadvisor#3401

😭
Did not see that, thanks for the heads-up @gardar
Is the following ok for you ?

        description:
          - "Dictionary of username / password for HTTP basic authentication"
          - >-
            Warning : The endpoints `/api/*` and `/metrics` are exposed without authentication. See https://github.com/google/cadvisor/blob/master/docs/web.md#web-ui-authentication and https://github.com/google/cadvisor/issues/3401 for more details.

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 16, 2026
@gardar
Copy link
Copy Markdown
Member

gardar commented Mar 16, 2026

And perhaps it would be worth noting in the argument specs that unlike the other exporters the basic auth does not secure the /metrics endpoint google/cadvisor#3401

😭 Did not see that, thanks for the heads-up @gardar Is the following ok for you ?

        description:
          - "Dictionary of username / password for HTTP basic authentication"
          - >-
            Warning : The endpoints `/api/*` and `/metrics` are exposed without authentication. See https://github.com/google/cadvisor/blob/master/docs/web.md#web-ui-authentication and https://github.com/google/cadvisor/issues/3401 for more details.

Yep, kind of defeating the purpose IMHO 😞

But yeah that looks fine.

@SuperQ SuperQ requested a review from gardar April 3, 2026 07:57
@gardar
Copy link
Copy Markdown
Member

gardar commented Apr 8, 2026

Can you please rebase ?

Signed-off-by: Paul des Garets <pdesgarets@users.noreply.github.com>
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request roles/cadvisor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants