Skip to content

Commit 9be613c

Browse files
committed
gen_nodes/gen_hosts: fix recursive loop and template errors in sysbench
The sysbench workflow had multiple template resolution issues: 1. "Collect dynamically supported filesystems" task was causing a recursive loop due to using 'vars' which includes all variables in the current context, including 'sysbench_enabled_filesystems' that the task is trying to set. 2. Subsequent tasks using 'vars' in template loops were getting "CapturedExceptionMarker" errors when trying to concatenate lists, due to template resolution failures. 3. Missing | list filters in map() chains were causing template evaluation errors. Fix this by: - Using 'hostvars[inventory_hostname]' instead of 'vars' to avoid circular references in all sysbench-related tasks - Adding | list filters to ensure all map() operations return lists - Renaming local variables consistently across both roles This affects both gen_nodes and gen_hosts roles that have identical problematic task patterns. Fixes: 8da9287 ("workflows: add new sysbench workflow with MySQL support with fs support") Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]>
1 parent 1d49e8c commit 9be613c

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

playbooks/roles/gen_hosts/tasks/main.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,10 @@
285285

286286
- name: Collect dynamically supported filesystems
287287
vars:
288-
supported_filesystems_variables: "{{ vars | dict2items | selectattr('key', 'search', '^sysbench_supported_filesystem_') }}"
289-
supported_filesystems: "{{ supported_filesystems_variables | selectattr('value', 'eq', True) | map(attribute='key') | map('regex_replace', '^sysbench_supported_filesystem_', '') | list }}"
288+
supported_filesystems_variables: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'search', '^sysbench_supported_filesystem_') }}"
289+
local_supported_filesystems: "{{ supported_filesystems_variables | selectattr('value', 'eq', True) | map(attribute='key') | map('regex_replace', '^sysbench_supported_filesystem_', '') | list }}"
290290
set_fact:
291-
sysbench_enabled_filesystems: "{{ supported_filesystems }}"
291+
sysbench_enabled_filesystems: "{{ local_supported_filesystems }}"
292292
enabled_sysbench_tests: "{{ [] }}"
293293
when:
294294
- kdevops_workflows_dedicated_workflow
@@ -300,11 +300,11 @@
300300
loop_var: fs
301301
vars:
302302
fs_section_prefix: "sysbench_{{ fs }}_section_"
303-
fs_section_variables: "{{ vars | dict2items | selectattr('key', 'search', '^' + fs_section_prefix) }}"
303+
fs_section_variables: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'search', '^' + fs_section_prefix) }}"
304304
enabled_fs_sysbench: "{{ fs_section_variables | selectattr('value', 'eq', True) | map(attribute='key') | list }}"
305-
enabled_fs_sections: "{{ enabled_fs_sysbench | map('regex_replace', 'sysbench_', '') }}"
306-
enabled_fs: "{{ enabled_fs_sections | map('regex_replace', 'section_', '') }}"
307-
enabled_fs_node: "{{ enabled_fs | map('regex_replace', '_', '-') }}"
305+
enabled_fs_sections: "{{ enabled_fs_sysbench | map('regex_replace', '^sysbench_', '') | list }}"
306+
enabled_fs: "{{ enabled_fs_sections | map('regex_replace', 'section_', '') | list }}"
307+
enabled_fs_node: "{{ enabled_fs | map('regex_replace', '_', '-') | list }}"
308308
set_fact:
309309
enabled_sysbench_tests: "{{ enabled_sysbench_tests + enabled_fs_node }}"
310310
when:

playbooks/roles/gen_nodes/tasks/main.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,10 @@
438438

439439
- name: Collect dynamically supported filesystems
440440
vars:
441-
supported_filesystems_variables: "{{ vars | dict2items | selectattr('key', 'search', '^sysbench_supported_filesystem_') }}"
442-
supported_filesystems: "{{ supported_filesystems_variables | selectattr('value', 'eq', True) | map(attribute='key') | map('regex_replace', '^sysbench_supported_filesystem_', '') | list }}"
441+
supported_filesystems_variables: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'search', '^sysbench_supported_filesystem_') }}"
442+
local_supported_filesystems: "{{ supported_filesystems_variables | selectattr('value', 'eq', True) | map(attribute='key') | map('regex_replace', '^sysbench_supported_filesystem_', '') | list }}"
443443
set_fact:
444-
sysbench_enabled_filesystems: "{{ supported_filesystems }}"
444+
sysbench_enabled_filesystems: "{{ local_supported_filesystems }}"
445445
enabled_sysbench_tests: "{{ [] }}"
446446
when:
447447
- kdevops_workflows_dedicated_workflow
@@ -453,12 +453,12 @@
453453
loop_var: fs
454454
vars:
455455
fs_section_prefix: "sysbench_{{ fs }}_section_"
456-
fs_section_variables: "{{ vars | dict2items | selectattr('key', 'search', '^' + fs_section_prefix) }}"
456+
fs_section_variables: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'search', '^' + fs_section_prefix) }}"
457457
enabled_fs_sysbench: "{{ fs_section_variables | selectattr('value', 'eq', True) | map(attribute='key') | list }}"
458-
enabled_fs_sections: "{{ enabled_fs_sysbench | map('regex_replace', '^sysbench_', '') }}"
459-
enabled_fs: "{{ enabled_fs_sections | map('regex_replace', 'section_', '') }}"
460-
prefixed_fs: "{{ enabled_fs | map('regex_replace', '^', kdevops_host_prefix + '-') }}"
461-
enabled_fs_node: "{{ prefixed_fs | map('regex_replace', '_', '-') }}"
458+
enabled_fs_sections: "{{ enabled_fs_sysbench | map('regex_replace', '^sysbench_', '') | list }}"
459+
enabled_fs: "{{ enabled_fs_sections | map('regex_replace', 'section_', '') | list }}"
460+
prefixed_fs: "{{ enabled_fs | map('regex_replace', '^', kdevops_host_prefix + '-') | list }}"
461+
enabled_fs_node: "{{ prefixed_fs | map('regex_replace', '_', '-') | list }}"
462462
set_fact:
463463
enabled_sysbench_tests: "{{ enabled_sysbench_tests + enabled_fs_node }}"
464464
when:
@@ -471,12 +471,12 @@
471471
loop_var: fs
472472
vars:
473473
fs_section_prefix: "sysbench_{{ fs }}_section_"
474-
fs_section_variables: "{{ vars | dict2items | selectattr('key', 'search', '^' + fs_section_prefix) }}"
474+
fs_section_variables: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'search', '^' + fs_section_prefix) }}"
475475
enabled_fs_sysbench: "{{ fs_section_variables | selectattr('value', 'eq', True) | map(attribute='key') | list }}"
476-
enabled_fs_sections: "{{ enabled_fs_sysbench | map('regex_replace', '^sysbench_', '') }}"
477-
enabled_fs: "{{ enabled_fs_sections | map('regex_replace', 'section_', '') }}"
478-
prefixed_and_postfixed_fs: "{{ enabled_fs | map('regex_replace', '^', kdevops_host_prefix + '-') | map('regex_replace', '$', '-dev') }}"
479-
enabled_fs_node: "{{ prefixed_and_postfixed_fs | map('regex_replace', '_', '-') }}"
476+
enabled_fs_sections: "{{ enabled_fs_sysbench | map('regex_replace', '^sysbench_', '') | list }}"
477+
enabled_fs: "{{ enabled_fs_sections | map('regex_replace', 'section_', '') | list }}"
478+
prefixed_and_postfixed_fs: "{{ enabled_fs | map('regex_replace', '^', kdevops_host_prefix + '-') | map('regex_replace', '$', '-dev') | list }}"
479+
enabled_fs_node: "{{ prefixed_and_postfixed_fs | map('regex_replace', '_', '-') | list }}"
480480
set_fact:
481481
enabled_sysbench_tests: "{{ enabled_sysbench_tests + enabled_fs_node }}"
482482
when:

0 commit comments

Comments
 (0)