From 2789a56ef78c7722b8127932bedf4045910d77e8 Mon Sep 17 00:00:00 2001 From: Will Miller Date: Fri, 7 Sep 2018 14:20:01 +0000 Subject: [PATCH] Extract Ironic node extra specs dicts It improves readability to have each dict defined separately. --- ansible/roles/nova-flavors/tasks/main.yml | 40 ++++++++++++++--------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/ansible/roles/nova-flavors/tasks/main.yml b/ansible/roles/nova-flavors/tasks/main.yml index aad5134..5dc4f5f 100644 --- a/ansible/roles/nova-flavors/tasks/main.yml +++ b/ansible/roles/nova-flavors/tasks/main.yml @@ -22,23 +22,33 @@ # * Add required and forbidden traits. # * Add any custom specs from the user. extra_specs: >- - {{ { - "resources:DISK_GB": 0, - "resources:MEMORY_MB": 0, - "resources:VCPU": 0, - "resources:CUSTOM_" ~ ( - item.resource_class | upper - | regex_replace('[^A-Za-z0-9]', '_')): 1 - } - | combine(dict(item.required_traits | default([]) - | map('regex_replace', '(.*)', 'trait:\1') - | zip_longest([], fillvalue='required'))) - | combine(dict(item.forbidden_traits | default([]) - | map('regex_replace', '(.*)', 'trait:\1') - | zip_longest([], fillvalue='forbidden'))) - | combine(item.custom_specs | default({})) + {{ hw_specs + | combine(resource_class) + | combine(required_traits) + | combine(forbidden_traits) + | combine(item.custom_specs | default({})) }} vars: + hw_specs: + "resources:DISK_GB": 0 + "resources:MEMORY_MB": 0 + "resources:VCPU": 0 + resource_class: >- + {{ { + "resources:CUSTOM_" ~ ( + item.resource_class | upper + | regex_replace('[^A-Z0-9]', '_')): 1 + } }} + required_traits: >- + {{ dict(item.required_traits + | default([]) + | map('regex_replace', '(.*)', 'trait:\1') + | zip_longest([], fillvalue='required')) }} + forbidden_traits: >- + {{ dict(item.forbidden_traits + | default([]) + | map('regex_replace', '(.*)', 'trait:\1') + | zip_longest([], fillvalue='forbidden')) }} ansible_python_interpreter: >- {{ '/'.join([flavors_virtualenv_path, 'bin', 'python']) }} loop: "{{ flavors }}"