Hello folks,
New to ansible, using version - 1.7.2. I am trying to write a play to launch an instance on AWS and install my packages on it. i need to automatically add the DNS name of the launched instance to my hosts file. But i am getting the error - One or more undefined variables: ‘instances’ is undefined
I am following the example here - http://docs.ansible.com/guide_aws.html
Below link to my playbook.
https://github.com/raj-andy1/macguffin/blob/master/aws-plays/aws-ec2.yaml
Please help
Below is the output i am getting
PLAY [localhost] **************************************************************
TASK: [make one instance] *****************************************************
changed: [localhost]
TASK: [debug var=ec2_info] ****************************************************
ok: [localhost] => {
“ec2_info”: {
“changed”: true,
“instance_ids”: [
“i-7e343873”
],
“instances”: [
{
“ami_launch_index”: “0”,
“architecture”: “x86_64”,
“dns_name”: “ec2-54-69-18-39.us-west-2.compute.amazonaws.com”,
“ebs_optimized”: false,
“hypervisor”: “xen”,
“id”: “i-7e343873”,
“image_id”: “ami-b6bdde86”,
“instance_type”: “t1.micro”,
“kernel”: “aki-fc37bacc”,
“key_name”: null,
“launch_time”: “2014-09-30T04:37:29.000Z”,
“placement”: “us-west-2b”,
“private_dns_name”: “ip-172-31-28-117.us-west-2.compute.internal”,
“private_ip”: “172.31.28.117”,
“public_dns_name”: “ec2-54-69-18-39.us-west-2.compute.amazonaws.com”,
“public_ip”: “54.69.18.39”,
“ramdisk”: null,
“region”: “us-west-2”,
“root_device_name”: “/dev/sda1”,
“root_device_type”: “ebs”,
“state”: “running”,
“state_code”: 16,
“virtualization_type”: “paravirtual”
}
],
“invocation”: {
“module_args”: “image=ami-b6bdde86 instance_type=t1.micro region=us-west-2 wait=true”,
“module_name”: “ec2”
},
“tagged_instances”:
}
}
TASK: [debug msg=“Assigned public DNS name is {{ instances.public_dns_name }}”] ***
fatal: [localhost] => One or more undefined variables: ‘instances’ is undefined
FATAL: all hosts have already failed – aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/Users/andyr/aws-ec2.yaml.retry
localhost : ok=2 changed=1 unreachable=1 failed=0