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', 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',
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", "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",
"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
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/71876e29-7239-4ed0-817a-f3d4f1d83a07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.