Skip to content

Commit 9b16310

Browse files
committed
Add tests for PVE realms
1 parent 13f2a80 commit 9b16310

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

tests/group_vars/all

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,35 @@ pve_ssl_certificate: "{{ lookup('file', ssl_host_cert_path) }}"
1515
pve_cluster_enabled: yes
1616
pve_datacenter_cfg:
1717
console: xtermjs
18+
pve_domains_cfg:
19+
- name: pam
20+
type: pam
21+
attributes:
22+
comment: Linux PAM standard authentication
23+
- name: pve
24+
type: pve
25+
attributes:
26+
comment: Proxmox VE authentication server
27+
- name: ad
28+
type: ad
29+
attributes:
30+
comment: Active Directory authentication
31+
domain: yourdomain.com
32+
server1: dc01.yourdomain.com
33+
default: 1
34+
secure: 1
35+
server2: dc02.yourdomain.com
36+
- name: ldap
37+
type: ldap
38+
attributes:
39+
comment: LDAP authentication
40+
base_dn: CN=Users,dc=yourdomain,dc=com
41+
bind_dn: "uid=svc-reader,CN=Users,dc=yourdomain,dc=com"
42+
bind_password: "my-password"
43+
server1: ldap1.yourdomain.com
44+
user_attr: uid
45+
secure: 1
46+
server2: ldap2.yourdomain.com
1847
pve_cluster_ha_groups:
1948
- name: proxmox_5_01
2049
comment: "Resources on proxmox-5-01"

tests/test.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,34 @@
1616
vars:
1717
query: "([?type=='cluster'].quorate)[0]"
1818

19+
- name: Query PVE realms
20+
shell: "pvesh get /access/domains --output=json"
21+
register: _pve_realms
22+
changed_when: False
23+
24+
- name: Construct realm list
25+
set_fact:
26+
realm_list: "{{ realm_list | default([]) }} + [ '{{ item.type }}' ]"
27+
with_items: "{{ pve_domains_cfg }}"
28+
29+
- name: Check that PVE realms exist
30+
assert:
31+
that: "realm_list is subset(_pve_realms.stdout | from_json | json_query(query))"
32+
vars:
33+
query: "[*].type"
34+
run_once: True
35+
36+
- name: Check PVE realms configuration
37+
assert:
38+
that:
39+
- item.type == realm.type
40+
- item.name == realm.realm
41+
- item.attributes.comment == realm.comment
42+
vars:
43+
realm: '{{ _pve_realms.stdout | from_json
44+
| json_query("[?realm==''" + item.name + "'']") | first }}'
45+
with_items: "{{ pve_domains_cfg }}"
46+
1947
- name: Query PVE groups
2048
shell: "pvesh get /access/groups --output=json"
2149
register: _pve_groups

0 commit comments

Comments
 (0)