tagged tasks and gather_facts not friends

Hi everyone,

It seems that if you run tagged tasks which depend on facts from gather_facts, if the entire play is not tagged as well, fact collection is skipped and your variables will be unavailable.

For example:

  • name: Install packages
    hosts: webservers
    user: root
    gather_facts: True

tasks:

  • name: echo database host

tags: cfg
command: echo Database is ${hostvars.${groups.databases[0]}.ansible_default_ipv4.address}

Run once with -t cfg and once without.

  • Oren