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/4e5bec76-9c26-45bc-9b50-eef01d3bb1f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to