Skip to content

Commit 8412688

Browse files
committed
Support storing password for ldap-based realms
1 parent 8ab30b4 commit 8412688

File tree

2 files changed

+61
-19
lines changed

2 files changed

+61
-19
lines changed

README.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -472,25 +472,32 @@ One realm should have the `default: 1` property to mark it as the default:
472472
pve_domains_cfg:
473473
- name: pam
474474
type: pam
475-
comment: Linux PAM standard authentication
475+
attributes:
476+
comment: Linux PAM standard authentication
476477
- name: pve
477478
type: pve
478-
comment: Proxmox VE authentication server
479-
- name: AD
479+
attributes:
480+
comment: Proxmox VE authentication server
481+
- name: ad
480482
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
483+
attributes:
484+
comment: Active Directory authentication
485+
domain: yourdomain.com
486+
server1: dc01.yourdomain.com
487+
default: 1
488+
secure: 1
489+
server2: dc02.yourdomain.com
490+
- name: ldap
488491
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
492+
attributes:
493+
comment: LDAP authentication
494+
base_dn: CN=Users,dc=yourdomain,dc=com
495+
bind_dn: "uid=svc-reader,CN=Users,dc=yourdomain,dc=com"
496+
bind_password: "{{ secret_ldap_svc_reader_password }}"
497+
server1: ldap1.yourdomain.com
498+
user_attr: uid
499+
secure: 1
500+
server2: ldap2.yourdomain.com
494501
```
495502

496503
## Dependencies

tasks/realms_config.yml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,47 @@
2222
content: |
2323
{% for domain in pve_domains_cfg %}
2424
{{ domain.type }}: {{ domain.name }}
25-
{% for k,v in domain.items() %}
26-
{% if k != 'name' %}
27-
{% if k != 'type' %}
25+
{% if domain.attributes %}
26+
{% for k,v in domain.attributes.items() %}
27+
{% if k != 'bind_password' %}
2828
{{ k }} {{ v }}
2929
{% endif %}
30-
{% endif %}
3130
{% endfor %}
31+
{% endif %}
3232
3333
{% endfor %}
34+
35+
- name: Select ldap-based realms with bind_password
36+
set_fact:
37+
pve_ldap_realms_with_bind_pw: |
38+
{{ pve_domains_cfg | selectattr('type', 'in', ['ad', 'ldap'])
39+
| selectattr('attributes.bind_password', 'defined') }}
40+
41+
- name: Ensure /etc/pve/priv/realm/ exists
42+
ansible.builtin.file:
43+
path: /etc/pve/priv/realm
44+
state: directory
45+
owner: root
46+
group: www-data
47+
mode: 0700
48+
when: pve_ldap_realms_with_bind_pw | length
49+
50+
- name: Ensure ldap-based realm secret files exists
51+
ansible.builtin.file:
52+
path: "/etc/pve/priv/realm/{{ item.name }}.pw"
53+
access_time: preserve
54+
modification_time: preserve
55+
state: touch
56+
mode: 0600
57+
with_items:
58+
- "{{ pve_ldap_realms_with_bind_pw }}"
59+
60+
- name: Update ldap-based realm secret files
61+
ansible.builtin.copy:
62+
content: "{{ item.attributes.bind_password }}"
63+
dest: "/etc/pve/priv/realm/{{ item.name }}.pw"
64+
owner: root
65+
group: www-data
66+
mode: 0600
67+
with_items:
68+
- "{{ pve_ldap_realms_with_bind_pw }}"

0 commit comments

Comments
 (0)