Skip to content

Commit f4a4e34

Browse files
committed
gen_hosts: Add missing generic workflow template
When no specific workflow is configured in kdevops (CONFIG_WORKFLOWS=y but no specific workflow like fstests, blktests, etc. selected), the gen_hosts role would fail with: Error rendering template: 'workflows/generic.j2' not found This occurs because the hosts.j2 template tries to include 'workflows/generic.j2' when kdevops_workflow_name is undefined, but this template file didn't exist. The solution adds a new generic.j2 template that handles the case where no specific workflow is configured. It creates a simple hosts inventory using the kdevops_host_prefix as the node name. The template also properly handles the case where all_generic_nodes might not be defined, which can happen with certain cloud providers like Lambda Labs when using Terraform without a dedicated workflow. This fix allows users to: - Use kdevops with cloud providers without selecting a specific workflow - Get started with basic infrastructure provisioning before choosing a testing workflow - Avoid build failures during initial configuration Fixes: 40df5ef ("gen_hosts: use kdevops_workflow_name directly for template selection") Generated-by: Claude AI Signed-off-by: Luis Chamberlain <[email protected]>
1 parent 2dc55c8 commit f4a4e34

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

playbooks/roles/gen_hosts/templates/hosts.j2

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ its own jinja2 template file and define its own ansible task for its generation.
88
{% if kdevops_declared_hosts is defined and kdevops_declared_hosts %}
99
{# Use declared hosts that skip bringup process - for bare metal or pre-existing infrastructure #}
1010
{% include 'workflows/declared-hosts.j2' %}
11-
{% else %}
11+
{% elif kdevops_workflow_name is defined and kdevops_workflow_name %}
1212
{# Include workflow-specific template dynamically based on workflow name #}
1313
{% include 'workflows/' + kdevops_workflow_name + '.j2' %}
14+
{% else %}
15+
{# No workflow defined - use generic template #}
16+
{% include 'workflows/generic.j2' %}
1417
{% endif %}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{# Generic hosts template for when no specific workflow is configured #}
2+
{% if all_generic_nodes is defined %}
3+
{% set nodes = all_generic_nodes %}
4+
{% else %}
5+
{# Default to using the host prefix as the node name #}
6+
{% set nodes = [kdevops_host_prefix] %}
7+
{% endif %}
8+
[all]
9+
{% for node in nodes %}
10+
{{ node }}
11+
{% endfor %}
12+
13+
[all:vars]
14+
ansible_python_interpreter = "{{ kdevops_python_interpreter }}"
15+
16+
[{{ kdevops_host_prefix | regex_replace('-$', '') }}]
17+
{% for node in nodes %}
18+
{{ node }}
19+
{% endfor %}
20+
21+
[{{ kdevops_host_prefix | regex_replace('-$', '') }}:vars]
22+
ansible_python_interpreter = "{{ kdevops_python_interpreter }}"

0 commit comments

Comments
 (0)