<div dir="ltr">Hi, <div>Thanks for your helpful comment.</div><div><br></div><div>I didn’t know about the pattern you suggested.</div><div>We often want to “if” or “for” etc…</div><div><br></div><div>For example,</div><div>* if private network is supplied as parameter, disable creating network resource.</div><div>* if https parameter is enable, tcp 6443 port should be opened instead of 8080 at“OS::Neutron::SecurityGroup".</div><div>* if https parameter is enable, loadbalancing protocol should be TCP instead of HTTP</div><div><br></div><div>and so on.</div><div>So, I want to Jinja2 template to manage it.</div><div><br></div><div>I’ll try to use the composition model above,</div><div>and also test the limited use of jinja2 templating.</div><div><br></div><div><br></div><div>Thanks</div><div>- OTSUKA, Yuanying</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">2016年5月12日(木) 17:46 Steven Hardy <<a href="mailto:shardy@redhat.com">shardy@redhat.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, May 12, 2016 at 11:08:02AM +0300, Pavlo Shchelokovskyy wrote:<br>
> Hi,<br>
><br>
> not sure why 3 will bring chaos when implemented properly.<br>
<br>
I agree - heat is designed with composition in mind, and e.g in TripleO<br>
we're making heavy use of it for optional configurations and it works<br>
pretty well:<br>
<br>
<a href="http://docs.openstack.org/developer/heat/template_guide/composition.html" rel="noreferrer" target="_blank">http://docs.openstack.org/developer/heat/template_guide/composition.html</a><br>
<br>
<a href="https://www.youtube.com/watch?v=fw0JhywwA1E" rel="noreferrer" target="_blank">https://www.youtube.com/watch?v=fw0JhywwA1E</a><br>
<br>
<a href="http://hardysteven.blogspot.co.uk/2015/05/tripleo-heat-templates-part-1-roles-and.html" rel="noreferrer" target="_blank">http://hardysteven.blogspot.co.uk/2015/05/tripleo-heat-templates-part-1-roles-and.html</a><br>
<br>
<a href="https://github.com/openstack/tripleo-heat-templates/tree/master/environments" rel="noreferrer" target="_blank">https://github.com/openstack/tripleo-heat-templates/tree/master/environments</a><br>
<br>
> Can you abstract the "thing" (sorry, not quite familiar with Magnum) that<br>
> needs FP + FP itself into a custom resource/nested stack? Then you could<br>
> use single master template plus two environments (one with FP, one<br>
> without), and choose which one to use right where you have this logic<br>
> split in your code.<br>
<br>
Yes, this is exactly the model we make heavy use of in TripleO, it works<br>
pretty well.<br>
<br>
Note there's now an OS::Heat::None resource in heat, which makes it easy to<br>
conditionally disable things (without the need for a noop.yaml template<br>
that contains matching parameters):<br>
<br>
<a href="http://docs.openstack.org/developer/heat/template_guide/openstack.html#OS::Heat::None" rel="noreferrer" target="_blank">http://docs.openstack.org/developer/heat/template_guide/openstack.html#OS::Heat::None</a><br>
<br>
So you'd have two environment files like:<br>
<br>
cat enable_floating.yaml:<br>
resource_registry:<br>
OS::Magnum::FloatingIP: templates/the_floating_config.yaml<br>
<br>
cat disable_floating.yaml:<br>
resource_registry:<br>
OS::Magnum::FloatingIP: OS::Heat::None<br>
<br>
Again, this pattern is well proven and works pretty well.<br>
<br>
Conditionals may provide an alternative way to do this, but at the expense<br>
of some additional complexity inside the templates.<br>
<br>
> Option 2 is not so bad either IMO (AFAIK Trove was doing that at sometime,<br>
> not sure of current status), but the above would be nicer.<br>
<br>
Yes, in the past[1] I've commented that the composition model above may be<br>
preferable to jinja templating, but recently I've realized there are pros<br>
and cons to each approach.<br>
<br>
The heat composition model works pretty well when you want to combine<br>
multiple pieces (nested stacks) which contain some mixture of different<br>
resources, but it doesn't work so well when you want to iterate over a<br>
common pattern and build a template (e.g based on a loop).<br>
<br>
You can use ResourceGroups in some cases, but that adds to the stack depth<br>
(number of nested stacks), and may not be workable for upgrades, so TripleO<br>
is now looking at some limited use of jinja2 templating also, I agree it's<br>
not so bad provided the interfaces presented to the user are carefully<br>
constrained.<br>
<br>
Steve<br>
<br>
[1] <a href="https://review.openstack.org/#/c/211771/" rel="noreferrer" target="_blank">https://review.openstack.org/#/c/211771/</a><br>
<br>
__________________________________________________________________________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
</blockquote></div>