Skip to content

Commit 83941db

Browse files
authored
Merge pull request #95 from jfpanisset/jf_domains_cfg_1
Support for adding authentication realms to domains.cfg
2 parents 970b7a2 + 2990d76 commit 83941db

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
@@ -336,6 +336,47 @@
336336
- "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == _init_node)"
337337
- "pve_datacenter_cfg | length > 0"
338338

339+
- name: Check domains.cfg exists
340+
stat:
341+
path: "/etc/pve/domains.cfg"
342+
register: _domains_cfg
343+
when:
344+
- not pve_cluster_enabled or (pve_cluster_enabled and inventory_hostname == groups[pve_group][0])
345+
- pve_domains_cfg | length > 0
346+
347+
- name: Create domains.cfg if it does not exist
348+
file:
349+
path: "/etc/pve/domains.cfg"
350+
state: "touch"
351+
when:
352+
- not pve_cluster_enabled | bool or (pve_cluster_enabled and inventory_hostname == groups[pve_group][0])
353+
- pve_domains_cfg | length > 0
354+
- not _domains_cfg.stat.exists
355+
356+
- name: Configure domains.cfg
357+
# The parser for domains.cfg requires a blank line after each domain,
358+
# and there's a TAB character before printing each key / value pair for a domain
359+
copy:
360+
dest: "/etc/pve/domains.cfg"
361+
owner: "root"
362+
group: "www-data"
363+
mode: "0640"
364+
content: |
365+
{% for domain in pve_domains_cfg %}
366+
{{ domain.type }}: {{ domain.name }}
367+
{% for k,v in domain.items() %}
368+
{% if k != 'name' %}
369+
{% if k != 'type' %}
370+
{{ k }} {{ v }}
371+
{% endif %}
372+
{% endif %}
373+
{% endfor %}
374+
375+
{% endfor %}
376+
when:
377+
- not pve_cluster_enabled | bool or (pve_cluster_enabled and inventory_hostname == groups[pve_group][0])
378+
- pve_domains_cfg | length > 0
379+
339380
- import_tasks: ssl_config.yml
340381
when:
341382
- "pve_ssl_private_key is defined"

0 commit comments

Comments
 (0)