Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ENV TF_HOSTNAME_KEY_NAME to specify which hostname to return #94

Merged
merged 2 commits into from
Sep 20, 2018

Conversation

cgroschupp
Copy link
Contributor

Overwrite with the environment variable TF_HOSTNAME_KEY_NAME which attribute is to be used for the ansible inventory name.
By default, the IP address is used. The Ansible variable "ansible_host" is used to connect to the host.

Overwrite with the environment variable TF_HOSTNAME_KEY_NAME which attribute is to be used for the ansible inventory name.
By default, the IP address is used. The Ansible variable "ansible_host" is used to connect to the host.
@GeertJohan
Copy link
Contributor

@adammck Can this be merged? :)

// Hostname returns the hostname of this resource.
func (r Resource) Hostname() string {
if keyName := os.Getenv("TF_HOSTNAME_KEY_NAME"); keyName != "" {
if ip := r.State.Primary.Attributes[keyName]; ip != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

ip could be renamed to hostname...

@adammck
Copy link
Owner

adammck commented Sep 20, 2018

LGTM. Thank you!

@adammck adammck merged commit 2365c9b into adammck:master Sep 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants