# add\_host

**URL:** <https://forum.ansible.com/t/add-host/22035>\
**Category:** Ansible Project\
**Created:** [July 16, 2016, 7:07pm UTC](https://forum.ansible.com/t/add-host/22035 "2016-07-16T19:07:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_van\_Haren](https://avatars.discourse-cdn.com/v4/letter/p/90db22/32.png) [@Patrick\_van\_Haren](https://forum.ansible.com/u/Patrick_van_Haren)\
**Post date:** [July 16, 2016, 7:07pm UTC](https://forum.ansible.com/t/add-host/22035/1 "2016-07-16T19:07:57Z")

</div>

I try to add a hos to my inventory with the command below:

ansible localhost -m add\_host -a “name=demo groups=containers”

This is the output:  
localhost | SUCCESS =\> {  
“add\_host”: {  
“groups”: [  
“containers”  
],  
“host\_name”: “demo”,  
“host\_vars”: {}  
},  
“changed”: true  
}

Unfortunately, Ansible doesn’t add the new host to my inventory file which is defined in /etc/ansible/ansible.cfg  
Also it doesn’t work when I add “-i /path/to/hosts” in the command.

Anyone suggestions? 🙂  
Thank you!

---

<div class="post-metadata">

**Author:** ![Dimon](https://avatars.discourse-cdn.com/v4/letter/d/eb8c5e/32.png) [@Dimon](https://forum.ansible.com/u/Dimon)\
**Post date:** [July 18, 2016, 2:49pm UTC](https://forum.ansible.com/t/add-host/22035/2 "2016-07-18T14:49:07Z")

</div>

add\_host is meant to be used **runtime** thus it does not perform any operations making change persistent. Adding hosts to the inventory could be done via one of the “file” modules.
