mantl / terraform.py

Ansible dynamic inventory script for parsing Terraform state files
Apache License 2.0
451 stars 122 forks source link

Add support for private ips and bastion access to AWS instances #44

Closed crumley closed 3 months ago

crumley commented 8 years ago

This PR has two changes, isolated to AWS only:

  1. When an instance does not have a public ip ensure the attribute ansible_ssh_host has a value by defaulting it to private_ip. Tagging an instance with sshPrivateIp achieves the same effect in the current script however adding this tag may not be convenient because it is difficult to conditionally add a tag to an instance in terraform.
  2. Users can choose to tag their instance with sshCommonArgs which is passed to ansible and appended to ssh commands used during provisioning. This is commonly used to use a bastion/jump host for accessing private instances. Docs. By exposing this configuration as a tag on a per instance bases this allows users to use different bastion hosts per instance if needed.

NOTE: ansible_ssh_common_args is not supported in Ansible < 2.0. Mantl does not yet work with Ansible 2.0. I included this commit in the event someone uses this inventory script outside of Mantl and would like to take advantage of ssh options. Let me know if this change is better off left out until Mantl supports 2.0.

langston-barrett commented 8 years ago

Could we add unit tests to this?

langston-barrett commented 8 years ago

@crumley ping.

Also: AFAIK, Mantl works just fine with Ansible 2.0, we just can't require it yet b/c Vagrant 1.8.1's ansible_local provisioner doesn't support it. We can merge this before Vagrant 1.8.2 comes out (whenever that may be) :smile:

crumley commented 8 years ago

This has been on my todo list unfortunately lower than I would like. I plan on adding unit tests for sure, it's a question of when. Feel free to close the PR and I will recreate a new one with tests.

RE Ansible 2.0: I tried running the mantl playbook with ansible 2.0 on aws and ran into a strange error. Switching back to Ansible 1.9 caused the playbook to complete. Looking forward to Vagrant 1.8.2!

langston-barrett commented 8 years ago

@crumley Just wanted to make sure it's still on your radar! We look forward to merging this whenever you have time to complete it.

langston-barrett commented 8 years ago

@crumley Wanted to ping you again on this! We look forward to being able to merge it.

Theaxiom commented 7 years ago

@crumley Is this still something you are interested in finishing? It would be greatly appreciated! :)

Theaxiom commented 7 years ago

@siddharthist Are you interested in helping out with Mantl again now that it is a stand-alone FOSS project?

sean-abbott commented 7 years ago

I believe my fork addresses this. It addes command line switches in indicates what attribute keyname you want to use for the ssh host. I would appreciate some other folks testing it before I try and get it merged here.

https://github.com/sean-abbott/terraform.py

Theaxiom commented 7 years ago

Thanks @sean-abbott I will definitely check it out. By the looks of things you've made quite a few enhancements. Maybe you could join us on Mattermost and we can discuss some of the details?

sean-abbott commented 7 years ago

If someone wants to send me instructions for joining on mattermost, I'd be happy to! I had a few questions about process as well.

Theaxiom commented 7 years ago

@sean-abbott Certainly, just click on this link to join: https://mattermost.dynamictivity.com/signup_user_complete/?id=pjksr6h977n4zxxyto3ojp8twa

thomasvincent commented 7 years ago

Bueller?... Bueller?... Bueller? Was this solved?