I'm not even sure I'd call it a pattern :)
Writing variables to a template should be totally unneccessary if you're
just going to load it in that way, because of the way lazy-loading in
Ansible already works.
If you want dog to contain the value of cat, you can just predeclare dog:
dog: "{{ cat }}"
You don't have to write a variable file to load it.
On Wed, Mar 26, 2014 at 10:58 PM, Brice Burgess <[email protected]> wrote:
> Absolutely. I use this technique to help combat the deprecation of include
> + with_items. Something like:
>
> ```
> - name: normalize apache_sites_list into variable file
> local_action: template dest={{ apache_sites_var_file }}
> src="apache_sites_normalized.j2"
>
> - name: load normalized `apache_sites_normalized` from variable file
> include_vars: "{{ apache_sites_var_file }}"
>
> - name: remove variable file
> local_action: file path={{ apache_sites_var_file }} state=absent
> ```
>
> where apache_sites_var_file is defined as:
>
> apache_sites_var_file: /tmp/ansible.apache_sites.{{ inventory_hostname
> }}.yml
>
> NOTE that it uses {{ inventory_hostname }} to help prevent issues with
> parallel execution.
>
> May be an "anti pattern" in this establishment; but helped me write
> cleaner playbooks.
>
>
>
> On Tuesday, March 25, 2014 9:35:18 PM UTC-5, qiu jiawei wrote:
>>
>> Now,the template module woule build the template file and send to the
>> remote host.
>> Is it possible for not send to the remote host?
>>
>> I just want to see the file in local machine.
>>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/1a46e963-43c1-4959-8a83-dd7327fbe49a%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/1a46e963-43c1-4959-8a83-dd7327fbe49a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAEVJ8QM-41U0fMCu8-_q0-CQjxovbhPuh70F96%2BzgOa1%3DmOHug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.