Skip to content

Commit 2990d76

Browse files
committed
Support for adding authentication realms to domains.cfg
Signed-off-by: Jean-Francois Panisset <[email protected]>
1 parent 6948116 commit 2990d76

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ pve_groups: [] # List of group definitions to manage in PVE. See section on User
415415
pve_users: [] # List of user definitions to manage in PVE. See section on User Management.
416416
pve_storages: [] # List of storages to manage in PVE. See section on Storage Management.
417417
pve_datacenter_cfg: {} # Dictionary to configure the PVE datacenter.cfg config file.
418+
pve_domains_cfg: {} # List of realms to use as authentication sources in the PVE domains.cfg config file.
418419
```
419420

420421
To enable clustering with this role, configure the following variables appropriately:
@@ -460,6 +461,36 @@ pve_cluster_ha_groups:
460461
All configuration options supported in the datacenter.cfg file are documented in the
461462
[Proxmox manual datacenter.cfg section][datacenter-cfg].
462463

464+
You can set realms / domains as authentication sources in the `domains.cfg` configuration file.
465+
If this file is not present, only the `Linux PAM` and `Proxmox VE authentication server` realms
466+
are available. Supported types are `pam`, `pve`, `ad` and `ldap`.
467+
One realm should have the `default: 1` property to mark it as the default:
468+
469+
```
470+
pve_domains_cfg:
471+
- name: pam
472+
type: pam
473+
comment: Linux PAM standard authentication
474+
- name: pve
475+
type: pve
476+
comment: Proxmox VE authentication server
477+
- name: AD
478+
type: ad
479+
comment: Active Directory authentication
480+
domain: yourdomain.com
481+
server1: dc01.yourdomain.com
482+
default: 1
483+
secure: 1
484+
server2: dc02.yourdomain.com
485+
- name: LDAP
486+
type: ldap
487+
base_dn: CN=Users,dc=yourdomain,dc=com
488+
server1: ldap1.yourdomain.com
489+
user_attr: uid
490+
secure: 1
491+
server2: ldap2.yourdomain.com
492+
```
493+
463494
## Dependencies
464495

465496
This role does not install NTP, so you should configure NTP yourself, e.g. with

tasks/main.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,47 @@
262262
- not pve_cluster_enabled | bool or (pve_cluster_enabled and inventory_hostname == groups[pve_group][0])
263263
- pve_datacenter_cfg | length > 0
264264

265+
- name: Check domains.cfg exists
266+
stat:
267+
path: "/etc/pve/domains.cfg"
268+
register: _domains_cfg
269+
when:
270+
- not pve_cluster_enabled or (pve_cluster_enabled and inventory_hostname == groups[pve_group][0])
271+
- pve_domains_cfg | length > 0
272+
273+
- name: Create domains.cfg if it does not exist
274+
file:
275+
path: "/etc/pve/domains.cfg"
276+
state: "touch"
277+
when:
278+
- not pve_cluster_enabled | bool or (pve_cluster_enabled and inventory_hostname == groups[pve_group][0])
279+
- pve_domains_cfg | length > 0
280+
- not _domains_cfg.stat.exists
281+
282+
- name: Configure domains.cfg
283+
# The parser for domains.cfg requires a blank line after each domain,
284+
# and there's a TAB character before printing each key / value pair for a domain
285+
copy:
286+
dest: "/etc/pve/domains.cfg"
287+
owner: "root"
288+
group: "www-data"
289+
mode: "0640"
290+
content: |
291+
{% for domain in pve_domains_cfg %}
292+
{{ domain.type }}: {{ domain.name }}
293+
{% for k,v in domain.items() %}
294+
{% if k != 'name' %}
295+
{% if k != 'type' %}
296+
{{ k }} {{ v }}
297+
{% endif %}
298+
{% endif %}
299+
{% endfor %}
300+
301+
{% endfor %}
302+
when:
303+
- not pve_cluster_enabled | bool or (pve_cluster_enabled and inventory_hostname == groups[pve_group][0])
304+
- pve_domains_cfg | length > 0
305+
265306
- import_tasks: ssl_config.yml
266307
when:
267308
- pve_ssl_private_key is defined

0 commit comments

Comments
 (0)