Skip to content

Commit aac1b93

Browse files
committed
Refactor: extract realms config to task list
1 parent b21c588 commit aac1b93

File tree

2 files changed

+34
-37
lines changed

2 files changed

+34
-37
lines changed

tasks/main.yml

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -322,43 +322,7 @@
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 %}
325+
- import_tasks: realms_config.yml
362326
when:
363327
- not pve_cluster_enabled | bool or (pve_cluster_enabled and inventory_hostname == groups[pve_group][0])
364328
- pve_domains_cfg | length > 0

tasks/realms_config.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
- name: Check domains.cfg exists
3+
stat:
4+
path: "/etc/pve/domains.cfg"
5+
register: _domains_cfg
6+
7+
- name: Create domains.cfg if it does not exist
8+
file:
9+
path: "/etc/pve/domains.cfg"
10+
state: "touch"
11+
when:
12+
- not _domains_cfg.stat.exists
13+
14+
- name: Configure domains.cfg
15+
# The parser for domains.cfg requires a blank line after each domain,
16+
# and there's a TAB character before printing each key / value pair for a domain
17+
copy:
18+
dest: "/etc/pve/domains.cfg"
19+
owner: "root"
20+
group: "www-data"
21+
mode: "0640"
22+
content: |
23+
{% for domain in pve_domains_cfg %}
24+
{{ domain.type }}: {{ domain.name }}
25+
{% for k,v in domain.items() %}
26+
{% if k != 'name' %}
27+
{% if k != 'type' %}
28+
{{ k }} {{ v }}
29+
{% endif %}
30+
{% endif %}
31+
{% endfor %}
32+
33+
{% endfor %}

0 commit comments

Comments
 (0)