How to use condition for resource creation via heat template

Zane Bitter zbitter at redhat.com
Mon Oct 26 21:26:47 UTC 2020


On 21/10/20 5:31 am, Md. Hejbul Tawhid MUNNA wrote:
> ~~~
> 
> |heat_template_version: 2017-02-24 ...... ...... ...... conditions: 
> port_security_enabled: equals: - { get_param: port_security_enabled } - 
> "true" resources: port: type: OS::Neutron::Port properties: 
> admin_state_up: true network_id: { get_param: internal_net } 
> port_security_enabled: { get_param: port_security_enabled } 
> security_groups: { get_param: security_group }|
> 
> |
> 
> I want to create a condition , so if I set "port_security_enabled = 
> false" security group will not apply in port.properties . If I set 
> "port_security_enabled = true" then security group will applied.

Something like this:

     port:
         type: OS::Neutron::Port
         properties:
             admin_state_up: true
             network_id: { get_param: internal_net }
             port_security_enabled: { get_param: port_security_enabled }
             security_groups: {if: [port_security_enabled, { get_param: 
security_group }, []]}

See https://docs.openstack.org/heat/latest/template_guide/hot_spec.html#if

- ZB




More information about the openstack-discuss mailing list