Debian Codegraph @

ansible_collections/community/proxmox/docs/docsite/rst/guides.rst

raw
1 ..
2 Copyright (c) Ansible Project
3 GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 SPDX-License-Identifier: GPL-3.0-or-later
5
6 .. _ansible_collections.community.proxmox.docsite.authentication:
7
8 Authentication
9 ================
10
11 Modules in this collection need to authenticate to the Proxmox Virtual Environment API.
12
13 This collection supports two authentication methods:
14
15 - **API token**: recommended for production (scoped and revocable)
16 - **Username/password**: simplest, good for development and testing
17
18 Avoid hard-coding credentials in playbooks or inventory. Prefer Ansible Vault, environment variables, or a secrets manager.
19
20 .. note::
21 Some operations are not supported with API token authentication (e.g container bind-mounts configuration).
22
23 Minimal Example
24 ---------------
25
26 Examples below show authentication variables as you would typically define them in group/host vars, role defaults, or play vars.
27
28 **API Token**
29
30 .. code-block:: yaml
31
32 api_host: 10.0.0.1
33 api_token_id: username@realm!tokenid
34 api_token_secret: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
35
36 **Username/password**
37
38 .. code-block:: yaml
39
40 api_host: 10.0.0.1
41 api_user: username@realm
42 api_password: a-strong-password
43
44 Example Playbook Task
45 ---------------------
46
47 Most modules in this collection accept the same authentication parameters. A common pattern is to define them once at play level and reuse them across tasks:
48
49 .. code-block:: yaml
50
51 - name: Query VMs on Proxmox VE
52 hosts: localhost
53 gather_facts: false
54 vars:
55 api_host: 10.0.0.1
56 api_token_id: "{{ vault_proxmox_token_id }}"
57 api_token_secret: "{{ vault_proxmox_token_secret }}"
58 validate_certs: true
59 tasks:
60 - name: Get VM inventory
61 community.proxmox.proxmox_vm_info:
62 api_host: "{{ api_host }}"
63 api_token_id: "{{ api_token_id }}"
64 api_token_secret: "{{ api_token_secret }}"
65 validate_certs: "{{ validate_certs }}"
66
67 Optional Parameters
68 -------------------
69
70 Here are optional configuration parameters:
71
72 .. code-block:: yaml
73
74 api_port: 8006
75 api_timeout: 5
76 validate_certs: true
77 ca_path: ./verify-tls-connection-with-this-authority.pem
78
79 Environment Variables
80 ---------------------
81
82 Credentials can also be provided via environment variables.
83
84 .. list-table::
85 :header-rows: 1
86 :widths: 22 35
87
88 * - Parameter
89 - Environment variable
90 * - ``api_host``
91 - ``PROXMOX_HOST``
92 * - ``api_user``
93 - ``PROXMOX_USER``
94 * - ``api_password``
95 - ``PROXMOX_PASSWORD``
96 * - ``api_token_id``
97 - ``PROXMOX_TOKEN_ID``
98 * - ``api_token_secret``
99 - ``PROXMOX_TOKEN_SECRET``
100 * - ``validate_certs``
101 - ``PROXMOX_VALIDATE_CERTS``
102
103 Parameters Reference
104 --------------------
105
106 The following parameters can be used for authentication:
107
108 - ``api_host``: Proxmox VE API hostname or IP (can also be sourced from ``PROXMOX_HOST``). Do not include ``https://``, ``:8006`` or ``/api2/json``.
109 - ``api_port``: Proxmox VE API port (default: 8006).
110 - ``api_user``: Username and realm (can also be sourced from ``PROXMOX_USER``). For example, ``root@pam``.
111 - ``api_password``: Password (can also be sourced from ``PROXMOX_PASSWORD``).
112 - ``api_token_id``: Token identifier in the form ``username@realm!tokenid`` (can also be sourced from ``PROXMOX_TOKEN_ID``).
113 - ``api_token_secret``: Token secret (can also be sourced from ``PROXMOX_TOKEN_SECRET``).
114 - ``validate_certs``: Validate TLS certificates (can also be sourced from ``PROXMOX_VALIDATE_CERTS``). Defaults to false prior v2.0.0.
115 - ``ca_path``: Path to a CA certificate file used to validate the Proxmox VE TLS certificate.
116 - ``api_timeout``: Request timeout in seconds. Defaults to 5 seconds. Might need to be increased for long running queries on larger setups.