Hello,

I am sure that I miss something obvious... but after having tried for a few 
hours, I just don't know where to look for a solution ...

I have the following playbook to create a new amazon instance and do a few 
things with it.
The instance is created correctly, but when I try to access to 
ec2_info.instances. private_ip variables, the playbook fail with an 
undefined variable error ...

Does any one have an idea?

Many thanks in advance.

Fred

** playbook:
---
- hosts: 127.0.0.1
  connection: local
  gather_facts: True
  vars:
      keypair: mykey
      dnsdomain: aws.domain.com
      fqdn: "{{ hostname }}.{{ dnsdomain }}"

  tasks:
      - name: create a vm
        local_action:
            ec2_url: https://ec2.eu-west-1.amazonaws.com
            module: ec2
            image: ami-75342c01
            count: 1
            instance_type: m1.large
            group:
                - J2EE
                - default
            key_name: "{{ keypair }}"
            vpc_subnet_id: subnet
            user_data: "{{ hostname }}.{{ dnsdomain }}"
            instance_tags: '{ "QA": "group", "Name": "{{ hostname }}" }'
            volumes:
                - device_name: /dev/sda1
                  volume_size: 10
                - device_name: /dev/sdb
                  ephemeral: ephemeral0
                - device_name: /dev/sdc
                  volume_size: 25
            wait: true
            wait_timeout: 500
            state: present
        register: ec2_info

      - name: register DNS name
        command: dnsupdate.py -s localhost -k Kddnsupdate.key -x add {{ 
fqdn }} 300 A {{ ec2_info.instances.private_ip }}
        sudo: yes
        remote_user: user
        delegate_to: dns_server

      - name: add new instance to inventory
        add_host: name={{ hostname }} groups=ci hostname={{ fqdn }} 
ansible_ssh_host={{ ec2_info.instances.private_ip }} 
ansible_ssh_private_key_file=~/.ssh/{{ keypair }}.pem

      - name: wait for instance to start
        wait_for: state=started host={{ ec2_info.instances.private_ip }} 
port=22

** error message:

TASK: [register DNS name] 
*****************************************************
fatal: [127.0.0.1] => One or more undefined variables: 'list' object has no 
attribute 'private_ip'

FATAL: all hosts have already failed -- aborting

** with a "debug=ec2_info.instances":

    "ec2_info.instances": [
        {
            "ami_launch_index": "0",
            "architecture": "x86_64",
            "dns_name": "",
            "hypervisor": "xen",
            "id": "i-d43324",
            "image_id": "ami-7",
            "instance_type": "m1.large",
            "kernel": "aki-54425520",
            "key_name": "ContinuousQA",
            "launch_time": "2014-04-07T12:30:29.000Z",
            "placement": "eu-west-1b",
            "private_dns_name": "ip-172-16-4-127.aws.domain.com",
            "private_ip": "172.16.4.127",
            "public_dns_name": "",
            "public_ip": null,
            "ramdisk": null,
            "region": "eu-west-1",
            "root_device_name": "/dev/sda1",
            "root_device_type": "ebs",
            "state": "running",
            "state_code": 16,
            "virtualization_type": "paravirtual"
        }
    ]
}

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fe90eada-d02e-467d-9220-75d89b5493a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to