-
-
Notifications
You must be signed in to change notification settings - Fork 168
Added new dynamic-ubuntu-wait.sh #4
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks great. Now it just needs an example and test :)
Oh, also, please add it to the root |
Jim, I've added the example and the call-out in the README but I'm not entirely sure how to test this. The only test I can think of would have to be a go test of building an AMI using two different packer templates. One with the curling of this script and one without. The expectation being that the packer template that doesn't curl this script gets an error while the one that does curl this script gets no error. Is this what you are thinking of? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A Packer template built on Ubuntu that calls your script first and then apt-get update && apt-get install <something silly>
, plus a test case for the same, would prob be enough.
README.md
Outdated
|
||
|
||
`curl -Ls https://raw.githubusercontent.com/gruntwork-io/bash-commons/dynamic-ubuntu-waiter/modules/bash-commons/src/dynamic-ubuntu-wait.sh | bash` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-LsS
. Also, that URL doesn't look quite right... And it should be versioned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should come up with an official Gruntwork standard for curl
. I actually like to use the fully laid out options of:
curl --location --silent --fail --show-error ...
This will:
- Follow redirects
- Output nothing
- ...unless there's an error
- Return a non-zero exit code if anything other than a 2XX HTTP response code is returned.
The one issue is that sometimes an API will return a 2XX response but along with an error, but I haven't been able to come up with anything better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed for scripts, but with the curl | bash
one-liner, you typically prefer brevity...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jim - is this what you were thinking for the url with version?
curl -LsS https://raw.githubusercontent.com/gruntwork-io/bash-commons/[VERSION]/modules/bash-commons/src/dynamic-ubuntu-wait.sh | bash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case: done :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough on the brevity, but I'm wondering if this should be:
curl -LsSf https://raw.githubusercontent.com/gruntwork-io/bash-commons/[VERSION]/modules/bash-commons/src/dynamic-ubuntu-wait.sh | bash
Try curl
ing a URL that 404s and see if this returns a non-zero exit code (and therefore causes the entire script to exit), which is what we would want for an invalid URL. That's my goal in adding the -f
/ --fail
. Otherwise, I'm worried that the curl
call could fail (e.g. for transient reasons) and lead to confusing errors for users.
README.md
Outdated
@@ -122,7 +124,9 @@ Here's an overview of the modules available in `bash-commons`: | |||
|
|||
* `string.sh`: A collection of string manipulation functions, such as checking if a string contains specific text, | |||
stripping prefixes, and stripping suffixes. | |||
|
|||
|
|||
* `dynamic-ubuntu-wait.sh`: A script that dynamically waits for Ubuntu automatic update mechanism to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alphabetic order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Just add an example Packer template that uses this and a test for same, and this is good to go. |
…d and used in our various packer builds when we construct ubuntu AMIs.
…t of all scripts in the package
… failures when there should be none.
…script is the very first command being run on the box.
bbb2a3a
to
c580adb
Compare
I am resurrecting this PR because we are using it in our ELK AMI examples and it feels sketchy to use unreleased code. I added a go integration test for testing this (f32ccd6), but one problem is that the current circleCI build doesn't have AWS credentials, so it is failing. Is there any risk to adding the credentials? The other issue I ran into is that the checksums for the shellcheck repo is now broken. Digging in I landed on this issue which suggest that we should be sourcing them from github now, so I fixed the docker container: b6ea582 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding AWS creds to this repo is fine.
Apparently, with the new CircleCi, you do that using contexts. I added our machine user data to a context called "Gruntwork Admin," and I think you can use it by adding context: Gruntwork Admin
to a job:
workflows:
my-workflow:
jobs:
- run-tests:
context: Gruntwork Admin
Co-authored-by: Yevgeniy Brikman <brikis98@users.noreply.github.com>
Thanks! Just added in to see if it works. |
I believe I addressed all comments and the test is passing now! |
Co-authored-by: Yevgeniy Brikman <brikis98@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks for review! Going to merge and release this now. |
A utility script that can be curled and used in our various packer builds when we construct ubuntu AMIs.