--- - name: Generate oo_list_hosts group hosts: localhost gather_facts: no tasks: - set_fact: scratch_group=tag_env-{{ cluster_id }} when: cluster_id != '' - set_fact: scratch_group=all when: scratch_group is not defined - add_host: name={{ item }} groups=oo_list_hosts with_items: groups[scratch_group] | difference(['localhost']) | difference(groups.status_terminated) - name: List Hosts hosts: oo_list_hosts gather_facts: no tasks: - debug: msg="public:{{hostvars[inventory_hostname].gce_public_ip}} private:{{hostvars[inventory_hostname].gce_private_ip}}"