How to append a conditional value in template section in repeat section of yaml?

asked 2019-04-15 00:41:51 -0500

I'm having a heat template for openstack, and in that allowed_address_pairs property is there. Recently i upgraded to openstack flavor rocky and i started getting issue for allowed_address_pairs asking for cidr notation i.e. 172.27.44.32/32. In my YAML document I am taking IP addresses as a comma separated list and the parsing it using following code

allowed_address_pairs:
          repeat:
            for_each:
                <%ipaddr%>: {get_param: mrfp_bearer_ips }
            template:
                ip_address: <%ipaddr%>
        replacement_policy: AUTO

where mrfp_bearer_ips is a comma delimited list.

I want to append cidr to each ip-address in that list like 172.27.44.32/32 . I tried with following code

allowed_address_pairs:
          repeat:
            for_each:
                <%ipaddr%>: {get_param: mrfp_bearer_ips }
            template:
                ip_address: 
                     str_replace:   
                          template:<%ipaddr%>/$cidr
                          params:
                              $cidr: { if: [ "mode","32","128" ] }
        replacement_policy: AUTO

where mode is condition which evaluates to true or false. But this is giving issue related to map.

The error I am getting is :

WorkflowHeatOperationError: Stack operation error! Stack id: 412a908d-2a63-46d8-b790-a8e341d8feca, expected status: COMPLETE, actual status: FAILED, reason: Resource CREATE failed: resources1: resources.mrfp_group.Property error: resources.sig_port.properties.allowed_address_pairs[0]: "[{u'ip_address': u'10.204.9.178/32'}]" is not a map

How to add cidr to each element in the list generated from repeat section. I am new to YAML. I also found one link regarding which may be helpful but I was unable to understand it:

edit retag flag offensive close merge delete