-
Notifications
You must be signed in to change notification settings - Fork 77
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 initial support for packer #242
base: master
Are you sure you want to change the base?
Changes from 1 commit
1662f19
3f245eb
3ee6f80
0f74683
2af0d77
177fad6
0973037
95fd311
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,36 @@ | |
|
||
This directory contains configuration for running packer to build AMIs. | ||
|
||
## Dependencies | ||
|
||
Running these packer scripts requires the following software: | ||
|
||
- python3 | ||
- [packer](https://developer.hashicorp.com/packer/downloads) | ||
- [aws-cli](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) | ||
|
||
## The `packer` wrapper | ||
|
||
This directory contains a python script named `packer` which wraps the system `packer`. The script creates an ansible virtual environment and moves the correct ansible configuration in place. | ||
|
||
### Running `packer` | ||
|
||
To run the wrapper pass the environment and playbook: | ||
Before running the packer script, you will need to initialize packer: | ||
|
||
```bash | ||
packer init ./docs-rs-builder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be run from within the |
||
``` | ||
|
||
You will also need to make sure that you are logged into the correct AWS account in the AWS cli. First, ensure you have the configuration needed to log into the appropriate AWS account in your "~/.aws/config" file (TODO: link to detailed instructions). | ||
|
||
For example, to log into the docs-rs staging account, run: | ||
|
||
```bash | ||
aws sso login --profile docs-rs-staging | ||
``` | ||
|
||
To run the wrapper pass the environment and playbook along with the profile name of the aws account you just logged into: | ||
|
||
```bash | ||
$ ./packer staging docs-rs-build | ||
$ AWS_PROFILE=docs-rs-staging ./packer staging docs-rs-builder | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ packer { | |
|
||
data "amazon-parameterstore" "revision" { | ||
name = "/docs-rs/builder/sha" | ||
region = "us-east-1" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The formatting is broken here. We run |
||
|
||
locals { | ||
|
@@ -23,7 +24,7 @@ source "amazon-ebs" "ubuntu" { | |
region = "us-east-1" | ||
source_ami_filter { | ||
filters = { | ||
name = "ubuntu/images/*ubuntu-focal-20.04-amd64-server-*" | ||
name = "ubuntu/images/*ubuntu-jammy-22.04-amd64-server-*" | ||
root-device-type = "ebs" | ||
virtualization-type = "hvm" | ||
} | ||
|
@@ -51,5 +52,7 @@ build { | |
# The default is the user running packer | ||
user = "ubuntu" | ||
extra_arguments = ["--extra-vars", "vars_repository_sha=${local.revision}"] | ||
# Work around for https://github.com/hashicorp/packer-plugin-ansible/issues/69 | ||
ansible_ssh_extra_args = ["-oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedKeyTypes=+ssh-rsa"] | ||
} | ||
} |
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.
This seems like an unrelated change. Was this necessary to build the AMI?