Skip to content

Commit b21c588

Browse files
jfpanissetmrtwnklr
authored andcommitted
Support for adding authentication realms to domains.cfg
Signed-off-by: Jean-Francois Panisset <[email protected]>
1 parent 569a203 commit b21c588

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
@@ -412,6 +412,7 @@ pve_groups: [] # List of group definitions to manage in PVE. See section on User
412412
pve_users: [] # List of user definitions to manage in PVE. See section on User Management.
413413
pve_storages: [] # List of storages to manage in PVE. See section on Storage Management.
414414
pve_datacenter_cfg: {} # Dictionary to configure the PVE datacenter.cfg config file.
415+
pve_domains_cfg: {} # List of realms to use as authentication sources in the PVE domains.cfg config file.
415416
```
416417

417418
To enable clustering with this role, configure the following variables appropriately:
@@ -462,6 +463,36 @@ In order for live reloading of network interfaces to work via the PVE web UI,
462463
you need to install the `ifupdown2` package. Note that this will remove
463464
`ifupdown`. You can specify this using the `pve_extra_packages` role variable.
464465

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

467498
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
@@ -322,6 +322,47 @@
322322
- "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == groups[pve_group][0])"
323323
- "pve_datacenter_cfg | length > 0"
324324

325+
- name: Check domains.cfg exists
326+
stat:
327+
path: "/etc/pve/domains.cfg"
328+
register: _domains_cfg
329+
when:
330+
- not pve_cluster_enabled or (pve_cluster_enabled and inventory_hostname == groups[pve_group][0])
331+
- pve_domains_cfg | length > 0
332+
333+
- name: Create domains.cfg if it does not exist
334+
file:
335+
path: "/etc/pve/domains.cfg"
336+
state: "touch"
337+
when:
338+
- not pve_cluster_enabled | bool or (pve_cluster_enabled and inventory_hostname == groups[pve_group][0])
339+
- pve_domains_cfg | length > 0
340+
- not _domains_cfg.stat.exists
341+
342+
- name: Configure domains.cfg
343+
# The parser for domains.cfg requires a blank line after each domain,
344+
# and there's a TAB character before printing each key / value pair for a domain
345+
copy:
346+
dest: "/etc/pve/domains.cfg"
347+
owner: "root"
348+
group: "www-data"
349+
mode: "0640"
350+
content: |
351+
{% for domain in pve_domains_cfg %}
352+
{{ domain.type }}: {{ domain.name }}
353+
{% for k,v in domain.items() %}
354+
{% if k != 'name' %}
355+
{% if k != 'type' %}
356+
{{ k }} {{ v }}
357+
{% endif %}
358+
{% endif %}
359+
{% endfor %}
360+
361+
{% endfor %}
362+
when:
363+
- not pve_cluster_enabled | bool or (pve_cluster_enabled and inventory_hostname == groups[pve_group][0])
364+
- pve_domains_cfg | length > 0
365+
325366
- import_tasks: ssl_config.yml
326367
when:
327368
- "pve_ssl_private_key is defined"

0 commit comments

Comments
 (0)