Found it.
It is an extra "space" at lineinfile:
..... {{item}} " state=present
should it be
..... {{item}}" state=present


El miércoles, 18 de febrero de 2015, 11:46:57 (UTC-3), Diego Rucci escribió:
>
> Hi, I'm just starting with ansible.
> I'm running a proxmox server with 12 containers.
> I made some playbooks that actually works (like setting tzdata and 
> apt-update)
>
> I was trying to automate etc/hosts file update. I'm using this playbook, 
> taken from here 
> <http://xmeblog.blogspot.com/2013/06/ansible-dynamicaly-update-et+chosts.html>
> :
> ---
> - hosts: wordpress
>   gather_facts: True
>   tasks:
>   - name: update hosts
>     lineinfile: dest=/etc/hosts1 regexp='.*{{ item }}$' line="{{ 
> hostvars[item].
> ansible_default_ipv4.address }} {{item}}.mydomain {{item}} " state=present
>     when: hostvars[item].ansible_default_ipv4.address is defined
>     with_items: groups['all']
> Note I'm using *etc/hosts1* file and just 1 host for testing! When I get 
> running will change to correct values.
>
> This works, but duplicate lines every time I run playbook, like this:
> 192.168.0.30 wordpress.mydomain wordpress
> 192.168.0.30 wordpress.mydomain wordpress
> 192.168.0.30 wordpress.mydomain wordpress
>
> Is there something I'm missing?
> Thanks
>

-- 
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/de841b1f-11d3-431d-9f9f-a9e68ed8a08c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to