# 'name' is a required argument.

**URL:** <https://forum.ansible.com/t/name-is-a-required-argument/19100>\
**Category:** Ansible Project\
**Created:** [August 24, 2015, 7:47pm UTC](https://forum.ansible.com/t/name-is-a-required-argument/19100 "2015-08-24T19:47:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chanaka\_Samarajeewa](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@Chanaka\_Samarajeewa](https://forum.ansible.com/u/Chanaka_Samarajeewa)\
**Post date:** [August 24, 2015, 7:47pm UTC](https://forum.ansible.com/t/name-is-a-required-argument/19100/1 "2015-08-24T19:47:58Z")

</div>

I have the following tasks:

- name: Add new instance to host group  
add\_host: hostname={{ item.public\_ip }} groupname=launched  
with\_items: ec2.results[0].instances

- name: set inventory\_hostname var  
add\_host: inventory\_hostname={{ item.public\_dns\_name }} groupname=launched  
with\_items: ec2.results[0].instances

The first one works correctly but i’m getting the following error in the second one:

‘name’ is a required argument.

Play results below:

TASK: [build\_base\_instance | Add new instance to host group] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* ok: [localhost] =\> (item={u’ramdisk’: None, u’kernel’: None, u’root\_device\_type’: u’ebs’, u’private\_dns\_name’: u’ip-172-31-14-222.eu-central-1.compute.internal’, u’tags’: {}, u’key\_name’: u’—‘, u’public\_ip’: u’x.x.x.x’, u’image\_id’: u’ami-0af7ce17’, u’tenancy’: u’default’, u’private\_ip’: u’x.x.x.x’, u’groups’: {u’sg-61f05408’: u’x’}, u’public\_dns\_name’: u’[ec2-x-x-x-x.eu-central-1.compute.amazonaws.com](http://ec2-x-x-x-x.eu-central-1.compute.amazonaws.com)’, u’state\_code’: 16, u’id’: u’i-6c651dad’, u’placement’: u’eu-central-1b’, u’ami\_launch\_index’: u’0’, u’dns\_name’: u’[ec2-x-x-x-x.eu-central-1.compute.amazonaws.com](http://ec2-x-x-x-x.eu-central-1.compute.amazonaws.com)’, u’region’: u’eu-central-1’, u’ebs\_optimized’: False, u’launch\_time’: u’2015-08-24T19:35:03.000Z’, u’instance\_type’: u’m3.medium’, u’state’: u’running’, u’root\_device\_name’: u’/dev/sda1’, u’hypervisor’: u’xen’, u’virtualization\_type’: u’hvm’, u’architecture’: u’x86\_64’}) =\> {“item”: {“ami\_launch\_index”: “0”, “architecture”: “x86\_64”, “dns\_name”: “[ec2-x-x-x-x.eu-central-1.compute.amazonaws.com](http://ec2-x-x-x-x.eu-central-1.compute.amazonaws.com)”, “ebs\_optimized”: false, “groups”: {“sg-61f05408”: “x”}, “hypervisor”: “xen”, “id”: “i-6c651dad”, “image\_id”: “ami-0af7ce17”, “instance\_type”: “m3.medium”, “kernel”: null, “key\_name”: “x”, “launch\_time”: “2015-08-24T19:35:03.000Z”, “placement”: “eu-central-1b”, “private\_dns\_name”: “ip-x-x-x-x.eu-central-1.compute.internal”, “private\_ip”: “x.x.x.x”, “public\_dns\_name”: “[ec2-x-x-x-x.eu-central-1.compute.amazonaws.com](http://ec2-x-x-x-x.eu-central-1.compute.amazonaws.com)”, “public\_ip”: “x.x.x.x”, “ramdisk”: null, “region”: “eu-central-1”, “root\_device\_name”: “/dev/sda1”, “root\_device\_type”: “ebs”, “state”: “running”, “state\_code”: 16, “tags”: {}, “tenancy”: “default”, “virtualization\_type”: “hvm”}, “new\_groups”: [“launched”], “new\_host”: “x.x.x.x”} TASK: [build\_base\_instance | set inventory\_hostname var] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* fatal: [localhost] =\> ‘name’ is a required argument. FATAL: all hosts have already failed – aborting

Thanks for your help

---

<div class="post-metadata">

**Author:** ![Paul\_Markham](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@Paul\_Markham](https://forum.ansible.com/u/Paul_Markham)\
**Post date:** [August 25, 2015, 2:43am UTC](https://forum.ansible.com/t/name-is-a-required-argument/19100/2 "2015-08-25T02:43:57Z")

</div>

The add\_host module requires ‘name’ as a parameter, or aliases of ‘hostname’ or ‘host’. It doesn’t accept ‘inventory\_hostname’. See [http://docs.ansible.com/ansible/add\_host\_module.htm](http://docs.ansible.com/ansible/add_host_module.htm)
