# Adding new host and group gives error

**URL:** <https://forum.ansible.com/t/adding-new-host-and-group-gives-error/32096>\
**Category:** Ansible Project\
**Created:** [January 30, 2020, 11:30am UTC](https://forum.ansible.com/t/adding-new-host-and-group-gives-error/32096 "2020-01-30T11:30:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Punit\_Jain](https://avatars.discourse-cdn.com/v4/letter/p/e56c9b/32.png) [@Punit\_Jain](https://forum.ansible.com/u/Punit_Jain)\
**Post date:** [January 30, 2020, 11:30am UTC](https://forum.ansible.com/t/adding-new-host-and-group-gives-error/32096/1 "2020-01-30T11:30:00Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [January 30, 2020, 12:37pm UTC](https://forum.ansible.com/t/adding-new-host-and-group-gives-error/32096/2 "2020-01-30T12:37:45Z")

</div>

> 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  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Punit\_Jain](https://avatars.discourse-cdn.com/v4/letter/p/e56c9b/32.png) [@Punit\_Jain](https://forum.ansible.com/u/Punit_Jain)\
**Post date:** [January 30, 2020, 2:10pm UTC](https://forum.ansible.com/t/adding-new-host-and-group-gives-error/32096/3 "2020-01-30T14:10:29Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [January 30, 2020, 5:24pm UTC](https://forum.ansible.com/t/adding-new-host-and-group-gives-error/32096/4 "2020-01-30T17:24:29Z")

</div>

> 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  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke
