On Wed, Sep 3, 2014 at 1:47 AM, Michael DeHaan <[email protected]> wrote:
> These are separate questions really.
>
> In your case, you don't want to template the file with_items because that
> will result in the file being written more than once.

I don't get it. There is a variable in template dest attribute, which changes
on every iteration. Why file will be written more than once?

> You probably want to reference a variable *inside* that template instead.

Embedding all needed variables inside the template looks wrong, or
I don't get something again.

> You can't do include+with_items, as that's not a thing :)

Although it answers the question, it still doesn't resolve the problem. )
Why it can not be implemented?


> On Tue, Sep 2, 2014 at 8:41 AM, Akos Vandra <[email protected]> wrote:
>>
>> This is related to my last email (subject: support passing new
>> variables directly to the template module, but not only), and issues
>> #8733 and #4546
>>
>> On 2 September 2014 07:27, anatoly techtonik <[email protected]> wrote:
>> > Hi,
>> >
>> > I need to set values for variable per task. Is it possible at all in
>> > Ansible?
>> > I have this template:
>> >
>> > <VirtualHost *:80>
>> >     DocumentRoot /var/www/{{name}}
>> >     ServerName {{name}}{{domain}}
>> > </VirtualHost>
>> >
>> > And I want to call it with specific name and domain parameter without
>> > modifying the template.
>> > I tried this:
>> >
>> > - template: dest=/etc/apache2/sites-available/{{ item }}
>> >             src=templates/virtualhost.j2
>> >   with_items:
>> >     - sitename
>> >
>> > But this syntax is not good, because it requires to rewrite template to
>> > use
>> > {{ item }}.
>> > Is it possible to avoid that?
>> >
>> > I tried moving the task into separate playbook and invoke it as
>> > parametrized
>> > include.
>> >
>> > - include: roles/web/tasks/virtualhost-add.yml name=sitename
>> > domain=example.com
>> >
>> > This works until I add a loop with_items.
>> >
>> > - include: roles/web/tasks/virtualhost-add.yml name={{item}}
>> > domain=example.com
>> >   with_items:
>> >     - sitename
>> >
>> > Now Ansible fails with:
>> >
>> > ERROR: [DEPRECATED]: include + with_items is a removed deprecated
>> > feature.
>> > Please update your playbooks.
>> >
>> > So, is that at all possible and what is the current best practice for
>> > templating files in a loop? I thought that the most simple way is to add
>> > some variables_override parameter to template module.
>> >
>> > --
>> > 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/dcb5622e-dfd2-4d8d-888c-7dc4b673ed6e%40googlegroups.com.
>> > 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/CAHHcNodO3BKzUzZ53h6yFMtFG2wqcP7GDQLOgnsD0Gsnhz86tQ%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/SulFWHwt_OI/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CA%2BnsWgyyQCmxyXBL-ifscAshtR-%2Bh%3DQ5OVDK%3DE%2BGHCHQuRBc4Q%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 
anatoly t.

-- 
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/CAPkN8x%2B9dK_SzJfjThnO5oktVx5dA7_0xn56X52hJfwXakpJRw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to