Skip to content

Commit 902d1dc

Browse files
lkuchlanclaude
andcommitted
[manila_create_default_resources] Fix extra_specs string vs dict handling
When extra_specs is passed via extra_vars on the command line (e.g. -e 'extra_specs={}'), Ansible receives it as a string instead of a dict. The original task-level vars: block evaluated extra_specs.items() before the when: condition was checked, causing the play to fail with 'str object has no attribute items'. Split into a set_fact task guarded by 'extra_specs is mapping' and a separate command task guarded by 'extra_spec_opt is defined' to handle both dict and string inputs safely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 00f43d7 commit 902d1dc

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

hooks/playbooks/manila_create_default_resources.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@
2121
( ( _manila_share_creation.rc | int ) != 0 )
2222
and not ( "HTTP 409" in _manila_share_creation.stderr )
2323
24+
- name: Prepare extra spec options string
25+
when: extra_specs is mapping and extra_specs | length > 0
26+
ansible.builtin.set_fact:
27+
# convert dict to 'k=v ...' format; guard against extra_specs being passed as a string
28+
extra_spec_opt: "{%- for k, v in extra_specs.items() -%}{{ k }}={{ v }} {% endfor -%}"
29+
2430
- name: Update default share type properties
31+
when: extra_spec_opt is defined
2532
environment:
2633
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
2734
PATH: "{{ cifmw_path }}"
28-
vars:
29-
# convert dict to 'k=v ...' format
30-
extra_spec_opt: "{%- for k, v in extra_specs.items() -%}{{ k }}={{ v }} {% endfor -%}"
31-
when: extra_spec_opt | length > 0
3235
ansible.builtin.command: |
3336
oc -n {{ namespace }} exec -it pod/openstackclient \
3437
-- openstack share type set {{ share_type_name }} --extra-specs {{ extra_spec_opt }}

0 commit comments

Comments
 (0)