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 a --meta-data-ec2 flag #314

Merged
merged 5 commits into from May 16, 2016
Merged

Add a --meta-data-ec2 flag #314

merged 5 commits into from May 16, 2016

Conversation

toolmantim
Copy link
Contributor

@toolmantim toolmantim commented May 11, 2016

This adds a --meta-data-ec2 option to automatically populate the agent's meta-data with EC2 meta-data such as aws:ami-id, aws:instance-id and aws:instance-type. This will mean that buildkite/elastic-ci-stack-for-aws#67 and the like can just use --meta-data-ec2.

$ buildkite-agent start --token xxx --meta-data-ec2

  _           _ _     _ _    _ _                                _
 | |         (_) |   | | |  (_) |                              | |
 | |__  _   _ _| | __| | | ___| |_ ___    __ _  __ _  ___ _ __ | |_
 | '_ \| | | | | |/ _` | |/ / | __/ _ \  / _` |/ _` |/ _ \ '_ \| __|
 | |_) | |_| | | | (_| |   <| | ||  __/ | (_| | (_| |  __/ | | | |_
 |_.__/ \__,_|_|_|\__,_|_|\_\_|\__\___|  \__,_|\__, |\___|_| |_|\__|
                                                __/ |
 http://buildkite.com/agent                    |___/

2016-05-15 13:32:51 NOTICE Starting buildkite-agent v3.0-beta.1 with PID: 2558
2016-05-15 13:32:51 NOTICE The agent source code can be found here: https://github.com/buildkite/agent
2016-05-15 13:32:51 NOTICE For questions and support, email us at: hello@buildkite.com
2016-05-15 13:32:51 INFO   Registering agent with Buildkite...
2016-05-15 13:32:51 INFO   Successfully registered agent "ip-172-31-60-230" with meta-data [aws:instance-id=i-575f61ca aws:instance-type=t2.nano aws:ami-id=ami-f5f41398]
2016-05-15 13:32:51 INFO   Connecting to Buildkite...
2016-05-15 13:32:51 INFO   Agent successfully connected
2016-05-15 13:32:51 INFO   You can press Ctrl-C to stop the agent
2016-05-15 13:32:51 INFO   Waiting for work...

agent

If you try to use the flag on a non-EC2 machine you just get some errors in the log:

$ buildkite-agent start --token xxx --meta-data-ec2

  _           _ _     _ _    _ _                                _
 | |         (_) |   | | |  (_) |                              | |
 | |__  _   _ _| | __| | | ___| |_ ___    __ _  __ _  ___ _ __ | |_
 | '_ \| | | | | |/ _` | |/ / | __/ _ \  / _` |/ _` |/ _ \ '_ \| __|
 | |_) | |_| | | | (_| |   <| | ||  __/ | (_| | (_| |  __/ | | | |_
 |_.__/ \__,_|_|_|\__,_|_|\_\_|\__\___|  \__,_|\__, |\___|_| |_|\__|
                                                __/ |
 http://buildkite.com/agent                    |___/

2016-05-15 23:35:30 NOTICE Starting buildkite-agent v3.0-beta.1 with PID: 54918
2016-05-15 23:35:30 NOTICE The agent source code can be found here: https://github.com/buildkite/agent
2016-05-15 23:35:30 NOTICE For questions and support, email us at: hello@buildkite.com
2016-05-15 23:35:32 ERROR Failed to fetch EC2 meta-data: Get http://169.254.169.254/latest/meta-data/instance-id: dial tcp 169.254.169.254:80: i/o timeout
2016-05-15 23:35:36 INFO   Registering agent with Buildkite...
2016-05-15 23:35:38 INFO   Successfully registered agent "tim.local-1" with meta-data []
2016-05-15 23:35:38 INFO   Connecting to Buildkite...
2016-05-15 23:35:39 INFO   Agent successfully connected
2016-05-15 23:35:39 INFO   You can press Ctrl-C to stop the agent
2016-05-15 23:35:39 INFO   Waiting for work...

@toolmantim toolmantim changed the title [WIP] Add a --meta-data-ec2 flag Add a --meta-data-ec2 flag May 15, 2016
@toolmantim
Copy link
Contributor Author

This is ready to roll!

EnvVar: "BUILDKITE_AGENT_META_DATA",
},
cli.BoolFlag{
Name: "meta-data-ec2",
Usage: "Include the host's EC2 meta-data (such instance-id, instance-type, and ami-id) as meta-data",
Copy link
Member

Choose a reason for hiding this comment

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

typo

@toolmantim
Copy link
Contributor Author

@keithpitt all fixed!

@keithpitt
Copy link
Member

Perfect! 🚀

@toolmantim toolmantim merged commit 1fb4e4b into master May 16, 2016
@toolmantim toolmantim deleted the add-ec2-meta-data-flag branch May 16, 2016 01:44
This was referenced May 16, 2016
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.

None yet

2 participants