Adding new host and group gives error

Hi,

I have a playbook requirement where new hosts come and leave. Based on it i plan to create groups dynamically. However below playbook gives an error:

Hi,

I have a playbook requirement where new hosts come and leave. Based on it i plan to create groups dynamically. However
below playbook gives an error:

Hello Punit,

that's not an error. "newdynamicgroup" is empty so it doesn't execute the tasks in that play.

Regards
        Racke

But i was adding host in that play:

add_host:
hostname: “test1”
ansible_host: “10.1.1.3”
ansible_ipaddress: “10.1.1.3”
groups: ‘newdynamicgroup’

This should add host as well to this group isinit or am I doing something wrong here ?

But i was adding host in that play:

add_host:
hostname: "test1"
ansible_host: "10.1.1.3"
ansible_ipaddress: "10.1.1.3"
groups: 'newdynamicgroup'

This should add host as well to this group isinit or am I doing something wrong here ?

That doesn't matter as the host list (group newdynamicgroup) is empty when Ansible looks at your play. Which means it
skips all the tasks.

Regards
        Racke