Some clarifications

23 views
Skip to first unread message

Pranav Gupta

unread,
Mar 15, 2019, 8:43:05 AM3/15/19
to kapitan-discuss
Hi all,

Just need a few clarifications,

1) In the final run script, just for confirmation, the expected behavior is to mount the compiled html folder to the one in /usr/share/nginx/html and similarly for nginx.conf file ?
2) As index.html contains inventory so just outputting it with just yaml filter in jinja2 is fine ? because it looks messy
3) As yaml, json are data serialization languages and we want a specific compile target to be executed on specific flag (bonus) then what are possible ways around it ? I mean one way is to just add an if condition in jinja2 template to check for flag but still an empty file is generated as we have specified the location and other stuff under Kapitan compile. Can somebody please guide me in some proper direction how to achieve conditional compilation of specific target ? Am I missing some feature of Kapitan ?

Thanks
Pranav

Pawel Sarbinowski

unread,
Mar 15, 2019, 8:54:22 AM3/15/19
to Pranav Gupta, kapitan-discuss
1) Yes
2) Yes, just yaml is fine. :) We're just interested in the output.
3) The target  kapitan outputs is passed on to kapitan through the inventory under "vars:". You can see an example here https://github.com/deepmind/kapitan/blob/master/examples/terraform/inventory/classes/type/terraform.yml#L6 and here https://github.com/deepmind/kapitan/blob/master/examples/kubernetes/inventory/classes/common.yml#L7 and kapitan will generate the files in the correct places. 
Equally if you only want some files to be generated only for a specific target just include the correct kapitan.compile: block in that targets' inventory.

``` 
  kapitan:
    compile:
      - output_path: a_path
        output_type: json
        input_paths:
          - templates/some_unique_template/
        input_type: jinja2
```
and it will compile that unique template only for that target.

--
You received this message because you are subscribed to the Google Groups "kapitan-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kapitan-discu...@googlegroups.com.
To post to this group, send email to kapitan...@googlegroups.com.
Visit this group at https://groups.google.com/group/kapitan-discuss.
To view this discussion on the web visit https://groups.google.com/d/msgid/kapitan-discuss/a435595f-9c05-456f-b4a9-03ff40bd8e01%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Pawel Sarbinowski | DevOps Engineer | paw...@google.com 

Pranav Gupta

unread,
Mar 15, 2019, 9:08:00 AM3/15/19
to kapitan-discuss
Thanks for the quick reply Pawel

Just as you gave the example consider list of blocks of

- output_path: a_path
        output_type: json
        input_paths:
          - templates/some_unique_template/
        input_type: jinja2

are written under compile and we want one of them to render based on some other parameter in inventory then how one can achieve this ? I mean we can't use an if condition but would like to achieve that type of functionality.

Pawel Sarbinowski

unread,
Mar 15, 2019, 9:25:19 AM3/15/19
to Pranav Gupta, kapitan-discuss
You just have to overwrite (a.k.a. redefine) the same keys in the inventory in your target. Those are the last keys added to the inventory so whichever ones overlap get overwritten. 


For more options, visit https://groups.google.com/d/optout.

Pranav Gupta

unread,
Mar 16, 2019, 6:48:09 AM3/16/19
to kapitan-discuss
Thanks Pawel,

But I am still thinking if we have say defined 4 templates to be rendered under kapitan:compile then how can we "stop" one of them to be rendered because of some other flag in our inventory.

Thanks
Pranav

PaulS

unread,
Mar 16, 2019, 9:07:36 AM3/16/19
to Pranav Gupta, kapitan-discuss
In that case, either split your template to another directory and add another compile block for that or only print some parts of your template with an if switch in jinja2. But in the second case sone files will still be output even if empty.
><https://groups.google.com/d/msgid/kapitan-discuss/a435595f-9c05-456f-b4a9-03ff40bd8e01%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> Pawel Sarbinowski | DevOps Engineer | paw...@google.com
>>>>
>>>> --
>>> You received this message because you are subscribed to the Google
>Groups
>>> "kapitan-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it,
>send an
>>> email to kapitan-discu...@googlegroups.com <javascript:>.
>>> To post to this group, send email to kapitan...@googlegroups.com
>>> <javascript:>.
>>> Visit this group at https://groups.google.com/group/kapitan-discuss.
>>> To view this discussion on the web visit
>>>
>https://groups.google.com/d/msgid/kapitan-discuss/de137263-be15-4ef3-9c41-11c492a3d544%40googlegroups.com
>
>>>
><https://groups.google.com/d/msgid/kapitan-discuss/de137263-be15-4ef3-9c41-11c492a3d544%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>>
>> Pawel Sarbinowski | DevOps Engineer | paw...@google.com
><javascript:>
>>
>>

Pranav Gupta

unread,
Mar 16, 2019, 9:11:47 AM3/16/19
to kapitan-discuss
Then what is the expected behavior for bonus part of task. Or should it be done in some other way ? Please give some input on that task about what is expected.

and thanks a lot for the help Pawel.

PaulS

unread,
Mar 16, 2019, 9:56:46 AM3/16/19
to Pranav Gupta, kapitan-discuss
For the bonus task a conditional if in jinja2 should do the trick.

On March 16, 2019 1:11:46 PM UTC, Pranav Gupta <pranavg...@gmail.com> wrote:
>Then what is the expected behavior for bonus part of task. Or should it
>be
>done in some other way ? Please give some input on that task about what
>is
>expected.
>
>and thanks a lot for the help Pawel.
>
>On Saturday, March 16, 2019 at 6:37:36 PM UTC+5:30, P S wrote:
>>
>> In that case, either split your template to another directory and add
>
>> another compile block for that or only print some parts of your
>template
>> with an if switch in jinja2. But in the second case sone files will
>still
>> be output even if empty.
>>
>> On March 16, 2019 10:48:09 AM UTC, Pranav Gupta <pranavg...@gmail.com
>

Pranav Gupta

unread,
Mar 16, 2019, 10:05:56 AM3/16/19
to kapitan-discuss
Got it.

Thanks Pawel
Reply all
Reply to author
Forward
0 new messages