Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Lack of public_ip causes failure #16

Open
plombardi89 opened this issue Oct 14, 2015 · 3 comments
Open

Lack of public_ip causes failure #16

plombardi89 opened this issue Oct 14, 2015 · 3 comments

Comments

@plombardi89
Copy link

Receiving this error:

Traceback (most recent call last):
File "./terraform.py", line 562, in
main()
File "./terraform.py", line 547, in main
output = query_list(hosts)
File "./terraform.py", line 489, in query_list
for name, attrs, hostgroups in hosts:
File "./terraform.py", line 68, in iterhosts
yield parser(resource, module_name)
File "./terraform.py", line 84, in inner
name, attrs, groups = func(_args, *_kwargs)
File "./terraform.py", line 330, in aws_host
'ansible_ssh_host': raw_attrs['public_ip'],
KeyError: u'public_ip'

Which is I believe due to the fact I have an instance without a public_ip (living in a private network):

"attributes": {
    "ami": "ami-96a818fe",
    "availability_zone": "us-east-1a",
    "ebs_block_device.#": "0",
    "ebs_optimized": "false",
    "ephemeral_block_device.#": "0",
    "id": "i-57efa6f7",
    "instance_type": "t2.micro",
    "key_name": "REDACTED",
    "monitoring": "false",
    "private_dns": "ip-10-0-10-213.ec2.internal",
    "private_ip": "10.0.10.213",
    "public_dns": "",
    "root_block_device.#": "1",
    "root_block_device.0.delete_on_termination": "false",
    "root_block_device.0.iops": "0",
    "root_block_device.0.volume_size": "8",
    "root_block_device.0.volume_type": "standard",
    "security_groups.#": "1",
    "security_groups.112399896": "sg-49b1572f",
    "source_dest_check": "true",
    "subnet_id": "subnet-53b88d0a",
    "tags.#": "3",
    "tags.Environment": "internal",
    "tags.Name": "jenkins_master",
    "tags.Owner": "rnd",
    "tenancy": "default",
    "vpc_security_group_ids.#": "1",
    "vpc_security_group_ids.112399896": "sg-49b1572f"
}

Not quite sure how you want to solve that problem, but perhaps just ignore instances in .tfstate files if there is no public_ip?

@BrianHicks
Copy link
Contributor

Yes, that's exactly what we should do. Watch for a fix for this soon. (we'll be able to get to it sometime next week; it's a slow week because of American Thanksgiving.)

@ghost
Copy link

ghost commented Dec 2, 2015

Ignoring instances with no public_ip is a bad idea, how are you going to access the private ones then?..
Ansible's ec2.py, for instance, supports this (http://docs.ansible.com/ansible/intro_dynamic_inventory.html):

For VPC instances, vpc_destination_variable in ec2.ini provides a means of using which ever boto.ec2.instance variable makes the most sense for your use case.

BrianHicks added a commit that referenced this issue Dec 10, 2015
@BrianHicks BrianHicks self-assigned this Dec 10, 2015
@Theaxiom Theaxiom changed the title Lack of public_ip causes failure Lack of public_ip causes failure Apr 21, 2017
@sean-abbott
Copy link
Collaborator

check ati --help...you should be able to set what attribute you want to use as the target host for connection (i.e public_ip, private_ip, even one of the dns entries.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants