It's actually quite easy to include or import .j2 templates into other
.j2 templates. There are some subtle and nuanced differences which you
should understand before you go much further, but in your case a simple
include will do the trick.
*# main.conf.j2****memory = {{ memory.input }}****cpu = {{ cpu.input
}}****domain = {{ domain.input }}*
and
*# extra.conf.j2****number.of.server = {{ num_of_servers.input }}****{% include
'main.conf.j2' %}*
That's it. You were within a few characters of the answer in your
original question.
On 1/22/23 1:54 AM, dudu.c...@gmail.com wrote:
I have a template file called *main.conf.j2* and this is distributed
to all of my servers. There additional server that need to have a
single configuration that should include the configuration of the
*main.conf.j2* file and additional configuration – I have named the
file *extra.conf.j2*
My question is if there is a way to import the main.conf.j2 file
inside the extra.conf.j2? the reason is that in case of a changes in
the main.conf.j2 I want to manage only a single file
*main.conf.j2* – only in example
memory = {{memory.input}}
cpu = {{cpu.input}}
domain = {{domain.input}}
*extra.conf.j2* – only in example
number.of.server = {{num_of_servers.input}}
< here I want to include the main.conf.j2>
--
You received this message because you are subscribed to the Google Groups "Ansible
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/ebcbc24f-9192-c726-14ea-43a451158b33%40gmail.com.