Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for adding authentication realms to domains.cfg #95

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ pve_groups: [] # List of group definitions to manage in PVE. See section on User
pve_users: [] # List of user definitions to manage in PVE. See section on User Management.
pve_storages: [] # List of storages to manage in PVE. See section on Storage Management.
pve_datacenter_cfg: {} # Dictionary to configure the PVE datacenter.cfg config file.
pve_domains_cfg: {} # List of realms to use as authentication sources in the PVE domains.cfg config file.
```

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

You can set realms / domains as authentication sources in the `domains.cfg` configuration file.
If this file is not present, only the `Linux PAM` and `Proxmox VE authentication server` realms
are available. Supported types are `pam`, `pve`, `ad` and `ldap`.
One realm should have the `default: 1` property to mark it as the default:

```
pve_domains_cfg:
- name: pam
type: pam
comment: Linux PAM standard authentication
- name: pve
type: pve
comment: Proxmox VE authentication server
- name: AD
type: ad
comment: Active Directory authentication
domain: yourdomain.com
server1: dc01.yourdomain.com
default: 1
secure: 1
server2: dc02.yourdomain.com
- name: LDAP
type: ldap
base_dn: CN=Users,dc=yourdomain,dc=com
server1: ldap1.yourdomain.com
user_attr: uid
secure: 1
server2: ldap2.yourdomain.com
```

## Dependencies

This role does not install NTP, so you should configure NTP yourself, e.g. with
Expand Down
41 changes: 41 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,47 @@
- not pve_cluster_enabled | bool or (pve_cluster_enabled and inventory_hostname == groups[pve_group][0])
- pve_datacenter_cfg | length > 0

- name: Check domains.cfg exists
stat:
path: "/etc/pve/domains.cfg"
register: _domains_cfg
when:
- not pve_cluster_enabled or (pve_cluster_enabled and inventory_hostname == groups[pve_group][0])
- pve_domains_cfg | length > 0

- name: Create domains.cfg if it does not exist
file:
path: "/etc/pve/domains.cfg"
state: "touch"
when:
- not pve_cluster_enabled | bool or (pve_cluster_enabled and inventory_hostname == groups[pve_group][0])
- pve_domains_cfg | length > 0
- not _domains_cfg.stat.exists

- name: Configure domains.cfg
# The parser for domains.cfg requires a blank line after each domain,
# and there's a TAB character before printing each key / value pair for a domain
copy:
dest: "/etc/pve/domains.cfg"
owner: "root"
group: "www-data"
mode: "0640"
content: |
{% for domain in pve_domains_cfg %}
{{ domain.type }}: {{ domain.name }}
{% for k,v in domain.items() %}
{% if k != 'name' %}
{% if k != 'type' %}
{{ k }} {{ v }}
{% endif %}
{% endif %}
{% endfor %}

{% endfor %}
when:
- not pve_cluster_enabled | bool or (pve_cluster_enabled and inventory_hostname == groups[pve_group][0])
- pve_domains_cfg | length > 0

- import_tasks: ssl_config.yml
when:
- pve_ssl_private_key is defined
Expand Down