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

Commit

Permalink
aws: allow instances with no public_ip
Browse files Browse the repository at this point in the history
Fixes #16
  • Loading branch information
BrianHicks committed Dec 10, 2015
1 parent d970d96 commit 51a8c13
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,8 @@ def aws_host(resource, module_name):
'vpc_security_group_ids'),
# ansible-specific
'ansible_ssh_port': 22,
'ansible_ssh_host': raw_attrs['public_ip'],
# generic
'public_ipv4': raw_attrs['public_ip'],
'public_ipv4': raw_attrs.get('public_ip', raw_attrs['private_ip']),
'private_ipv4': raw_attrs['private_ip'],
'provider': 'aws',
}
Expand All @@ -333,6 +332,8 @@ def aws_host(resource, module_name):
if 'tags.sshUser' in raw_attrs:
attrs['ansible_ssh_user'] = raw_attrs['tags.sshUser']

attrs['ansible_ssh_host'] = attrs['public_ipv4']

# attrs specific to Mantl
attrs.update({
'consul_dc': _clean_dc(attrs['tags'].get('dc', module_name)),
Expand Down

1 comment on commit 51a8c13

@plombardi89
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only have a second to really glance at this and I can run a test in a little bit, but won't this fail if you're running Terraform + Ansible from outside the VPC and without a VPN which is where the situation arose in the first place. You'll get host communication failures since you're defaulting to the private_ip which is inaccessible in that situation (which is actually how I ran into this in the first place).

Please sign in to comment.