On 5/14/20 4:35 PM, Dumast Axel wrote:
> Hello,
>
> I search since 2 days but I don't find any solution:
>
> I have 2 yaml files :
>
> Master.yml:
>
> values.yml:
> I try to catch hostname1 and hostname2's list using command like *msg"{{ firewall.port.{{ansible_hostname}} }}"*.
>
> The problem is that {{ansible_hostname}} is a string value and "firewall.port" is a yaml_path value. It's not the same
> type of variable.
> So I can't display hostname1 and hostname2 list values using "firewall.port.{{ansible_hostname}}
You can't wrap Jinja inside Jinja, but you can try to use either vars or Python method:
{{ firewall.port[vars[ansible_hostname]] }}
{{ firewall.port.get(ansible_hostname) }}
Regards
Racke
>
> I tried to have a simple string like this :
>
> But when I run ansible, path_items return a string (firewall.port.hostname1) but not the yaml list.
>
> My question is: How can I do to display hostame1 and hostname2 values using {{ansible_hostname}} ?
>
> Thanks in advance,
>
> --
> 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-proje...@googlegroups.com <mailto:
ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/ansible-project/eb21155e-0869-47b8-8e7b-410a26b67d85%40googlegroups.com
> <
https://groups.google.com/d/msgid/ansible-project/eb21155e-0869-47b8-8e7b-410a26b67d85%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.