{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/consul/issues/5098","repository_url":"https://api.github.com/repos/hashicorp/consul","labels_url":"https://api.github.com/repos/hashicorp/consul/issues/5098/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/consul/issues/5098/comments","events_url":"https://api.github.com/repos/hashicorp/consul/issues/5098/events","html_url":"https://github.com/hashicorp/consul/issues/5098","id":391353853,"node_id":"MDU6SXNzdWUzOTEzNTM4NTM=","number":5098,"title":"allow consul join to use cloud discovery","user":{"login":"eedwards-sk","id":34585329,"node_id":"MDQ6VXNlcjM0NTg1MzI5","avatar_url":"https://avatars1.githubusercontent.com/u/34585329?v=4","gravatar_id":"","url":"https://api.github.com/users/eedwards-sk","html_url":"https://github.com/eedwards-sk","followers_url":"https://api.github.com/users/eedwards-sk/followers","following_url":"https://api.github.com/users/eedwards-sk/following{/other_user}","gists_url":"https://api.github.com/users/eedwards-sk/gists{/gist_id}","starred_url":"https://api.github.com/users/eedwards-sk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eedwards-sk/subscriptions","organizations_url":"https://api.github.com/users/eedwards-sk/orgs","repos_url":"https://api.github.com/users/eedwards-sk/repos","events_url":"https://api.github.com/users/eedwards-sk/events{/privacy}","received_events_url":"https://api.github.com/users/eedwards-sk/received_events","type":"User","site_admin":false},"labels":[{"id":64219393,"node_id":"MDU6TGFiZWw2NDIxOTM5Mw==","url":"https://api.github.com/repos/hashicorp/consul/labels/enhancement","name":"enhancement","color":"c5def5","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-15T07:38:56Z","updated_at":"2019-01-04T00:05:49Z","closed_at":"2019-01-04T00:05:49Z","author_association":"NONE","body":"#### Feature Description\r\n\r\na command line switch for `consul join` to use cloud auto-join\r\n\r\n`consul join -auto \"provider=aws tag_key=... tag_value=...\"`\r\n\r\nor an environment variable for the same\r\n\r\n`CONSUL_JOIN=\"provider=aws tag_key=... tag_value=...\"`\r\n\r\n#### Use Case(s)\r\n\r\ncurrently the `consul join` command is vastly superior to configuring `retry_join` when trying to automate the joining of an agent to a cluster using basic orchestration for the purpose of running a command after the agent has actually joined the cluster\r\n\r\nif I spawn the agent in the background, I can [easily wait until it's running by monitoring the pid file](https://github.com/Snapkitchen/concourse-terraform/blob/master/bin/consul-wrapper#L77-L99), however I can't easily know if it has successfully finished the `retry_join` or not.\r\n\r\nI could add a `sleep` before running the command, and hope that the client has joined the cluster, but it's non-deterministic which is frustrating for automation.\r\n\r\nThis means my only option is to not use `retry_join` at all, and instead use `consul join`.\r\n\r\n`consul join` actually has a much better automation-oriented experience, as it errors if the join fails\r\n\r\nthis means wrapping it with simple shell retry logic is straightforward, and in some cases, you want to error immediately after the initial join failure anyway\r\n\r\nso I'd like to be able to use this automation-friendly way of joining a cluster while also leveraging cloud auto join\r\n\r\nthus I would expect that `consul join -auto \"provider=aws tag_key=... tag_value=...\"` would return non-zero if if failed to join, and I could retry with the shell or fail out\r\n\r\n#### Alternate Solution\r\n\r\nAnother option would be to provide a command that surfaces the auto-discovery feature as a direct command, e.g.:\r\n\r\n`consul discover \"provider=aws tag_key=... tag_value=...\"`\r\n\r\nI could then capture that output and provide it to `consul join`"},"comment":{"url":"https://api.github.com/repos/hashicorp/consul/issues/comments/451317762","html_url":"https://github.com/hashicorp/consul/issues/5098#issuecomment-451317762","issue_url":"https://api.github.com/repos/hashicorp/consul/issues/5098","id":451317762,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MTMxNzc2Mg==","user":{"login":"pearkes","id":846194,"node_id":"MDQ6VXNlcjg0NjE5NA==","avatar_url":"https://avatars0.githubusercontent.com/u/846194?v=4","gravatar_id":"","url":"https://api.github.com/users/pearkes","html_url":"https://github.com/pearkes","followers_url":"https://api.github.com/users/pearkes/followers","following_url":"https://api.github.com/users/pearkes/following{/other_user}","gists_url":"https://api.github.com/users/pearkes/gists{/gist_id}","starred_url":"https://api.github.com/users/pearkes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pearkes/subscriptions","organizations_url":"https://api.github.com/users/pearkes/orgs","repos_url":"https://api.github.com/users/pearkes/repos","events_url":"https://api.github.com/users/pearkes/events{/privacy}","received_events_url":"https://api.github.com/users/pearkes/received_events","type":"User","site_admin":false},"created_at":"2019-01-04T00:05:49Z","updated_at":"2019-01-04T00:05:49Z","author_association":"MEMBER","body":"This could be accomplished by passing the result of `go-discover` to the `consul join` command, though we do continue to recommend the configuration stanza for `retry_join`. Typically though, it is not uncommon for retry_join to _eventually_ succeed in your cluster bootstrap example, so I'd say you're better off watching for health of the cluster instead of sleeping, then executing the appropriate command.\r\n\r\nRegardless, `go-discover` can be [used as a CLI tool](https://github.com/hashicorp/go-discover#command-line-tool-usage) accomplishing what you suggest with `consul discover`. That seems like a fine solution to provide IPs with the same underlying mechanism that Consul uses if you don't want to use `retry_join`. \r\n\r\nI'm going to proactively close this in favor of that as I think it solves your use-case."}}
{"actor":{"display_login":"pearkes"}}