gathering facts problem

This is my playbook (dbmaster.yml)

  • hosts: dbmasters
    remote_user: root

roles:

  • common
  • dbmaster

if I run this. it will work fine
sudo -u test ansible-playbook dbmasters.yml

however if I run it on one specific host (host1)

sudo -u test ansible-playbook dbmasters.yml -l host2

I got error in one task

fatal: [host2] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_eth0’”, ‘failed’: True}

this is because it needs this variable from host1

I tried gather_facts=yes and it does not work
I tried serial=1. This will work one host at a time but there is no option to stop on the first host.

any idea who to run on one host and get facts from both hosts or will serial=1 stop at the first host.

I read ansible doc http://docs.ansible.com/guide_rolling_upgrade.html and also tried this option

- hosts: dbmasters
  tasks: []

- hosts: dbmasters
  remote_user: root

  roles:
    - common
    - dbmaster

with a blank task but it does not work either.

Answer in this thread:

https://groups.google.com/forum/#!topic/ansible-project/XbRcz6zCbCw