Hello everyone!
I was asked to bring this up in the email list as well. Please see
issues #8733 and #4546 for the origins of this email.
Just encountered the problem reported in #4546
Due to openSSL not being able to accept extendedusagetypes from the
command line, only from config files, I need to generate a temporary
configuration file, so I would need to do something similar to this:
- template: src=openssl_config.j2 dest=/tmp/openssl.cnf
vars:
usage: serverAuth
- name: sign client csrs
shell: openssl req -in {{item}} -config /tmp/openssl.cnf..... [sign items]
with_items: server_certs
- template: src=openssl_config.j2 dest=/tmp/openssl.cnf
vars:
usage: clientAuth
- name: sign server csrs
shell: openssl req -in {{item}} -config /tmp/openssl.cnf .....
with_items: client_certs
Without being able to manipulate the usage variable passed to the
template, one can not reuse the config template.
Of course this could be worked around by putting the two tasks into a
different file, and then including it with parameters (which is
supported btw), but it seems silly that one needs to do that if one
wants to reuse the template.
I'd like to see the ability to pass in extra variables not implemented
in the template module, but globally, so that one could include extra
variables to *any* module, just like the when, or changed_when, etc.
work.
Regards,
Akos Vandra
There was another comment to about 3 weeks ago from @iraksdale
""
Have to agree with @claco here. I'm using a template to output
multiple files based on a with_dict loop, and semantically it kind of
sucks to use item.key or item.value all over the template - doesn't
make them very reusable.
It would be nice to define "service_name" or "hostname" variables or
whatever in the playbook where it's easy to see their relationship to
the variable being looped, and have the templates use {{service_name}}
instead of having to put "whatever_{{item.key}}" in the templates.
It really hinders the reuse of templates, because it marries them to a
particular playbook structure, and the passthrough to the file module
could be preserved if you just added a template_vars argument that
would make its contents available to the template.
As a new user to ansible, I'd say the lack of this is really
counterintuitive. Is it possible to reconsider this decision? I think
it adds a lot to the reusability & understandability of templates.
""
Regards,
Akos Vandra