-
Notifications
You must be signed in to change notification settings - Fork 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
Modernize the Packer template in this repository #835
Open
mcdonnnj
wants to merge
15
commits into
develop
Choose a base branch
from
improvement/modernize_packer_configuration
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0890f4d
Bump cisagov/pre-commit-packer from 0.1.0 to 0.3.0
mcdonnnj 502da8b
Add a Packer configuration block
mcdonnnj 218a1c4
Configure the variables and locals for the Packer templates
mcdonnnj eaf0f7b
Establish the source AMIs used in the Packer templates
mcdonnnj 986e9a9
Convert the `bastion` Packer template to HCL2
mcdonnnj 554b159
Convert the `dashboard` Packer template to HCL2
mcdonnnj 7121ac8
Convert the `docker` Packer template to HCL2
mcdonnnj d25e063
Convert the `mongo` Packer template to HCL2
mcdonnnj f153ebb
Convert the `nessus` Packer template to HCL2
mcdonnnj cc88d36
Convert the `nmap` Packer template to HCL2
mcdonnnj 2060260
Convert the `reporter` Packer template to HCL2
mcdonnnj 2323607
Add a README for the Packer configuration
mcdonnnj 9ceab2d
Use `terraform-docs` to populate Packer information
mcdonnnj 2c79e4b
Update the project README
mcdonnnj c086fc6
Add a missed period to the Packer template README
mcdonnnj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
formatter: markdown table | ||
output: | ||
file: README.md | ||
mode: inject | ||
template: |- | ||
<!-- BEGIN_TF_DOCS --> | ||
{{ .Content }} | ||
<!-- END_TF_DOCS --> | ||
settings: | ||
anchor: false | ||
atx-closed: true | ||
html: false | ||
lockfile: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Cyber Hygiene Packer templates # | ||
|
||
## AMIs ## | ||
|
||
The following AMIs are available in this Packer template: | ||
|
||
| Template name | Description | | ||
| ------------- | ----------- | | ||
| bastion | Provides a jump box to a private VPC. | | ||
| dashboard | The Cyber Hygiene dashboard application. | | ||
| docker | Runs Docker configurations to perform BOD 18-01 and 20-01 scanning as well as generate the DHS [code.gov](https://code.gov) inventory. | | ||
| mongo | Provides the MongoDB database used by the Cyber Hygiene scanning system as well as running [cisagov/cyhy-commander]. | | ||
| nessus | A Nessus scanner for the Cyber Hygiene scanning system (referred to as a `vulnscanner`). | | ||
| nmap | An Nmap scanner for the Cyber Hygiene scanning system (referred to as a `portscanner`). | | ||
| reporter | Runs the daily notification and weekly report generation using [cisagov/cyhy-reports]. | | ||
|
||
## Building ## | ||
|
||
Build an AMI with: | ||
|
||
```console | ||
cd packer | ||
ansible-galaxy install --role-file ansible/requirements.yml | ||
packer init . | ||
packer build -only amazon-ebs.<target AMI> . | ||
``` | ||
|
||
Also note that | ||
|
||
```console | ||
ansible-galaxy install --force --role-file ansible/requirements.yml | ||
``` | ||
|
||
will update the roles that are being pulled from external sources. This | ||
may be required, for example, if a role that is being pulled from a | ||
GitHub repository has been updated and you want the new changes. By | ||
default `ansible-galaxy install` *will not* upgrade roles. | ||
|
||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements ## | ||
|
||
No requirements. | ||
|
||
## Providers ## | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| amazon-ami | n/a | | ||
|
||
## Modules ## | ||
|
||
No modules. | ||
|
||
## Resources ## | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [amazon-ami_amazon-ami.debian_bookworm](https://registry.terraform.io/providers/hashicorp/amazon-ami/latest/docs/data-sources/amazon-ami) | data source | | ||
| [amazon-ami_amazon-ami.debian_buster](https://registry.terraform.io/providers/hashicorp/amazon-ami/latest/docs/data-sources/amazon-ami) | data source | | ||
|
||
## Inputs ## | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| ami\_prefix | The prefix to use for the names of AMIs created. | `string` | `"cyhy"` | no | | ||
| ami\_regions | The list of AWS regions to copy the AMI to once it has been created. Example: ["us-east-1"] | `list(string)` | ```[ "us-east-1", "us-west-1", "us-west-2" ]``` | no | | ||
| build\_region | The region in which to retrieve the base AMI from and build the new AMI. | `string` | `"us-east-2"` | no | | ||
| is\_prerelease | The pre-release status to use for the tags applied to the created AMI. | `bool` | `false` | no | | ||
|
||
## Outputs ## | ||
|
||
No outputs. | ||
<!-- END_TF_DOCS --> | ||
|
||
## License ## | ||
|
||
This project is in the worldwide [public domain](LICENSE.md). | ||
|
||
This project is in the public domain within the United States, and | ||
copyright and related rights in the work worldwide are waived through | ||
the [CC0 1.0 Universal public domain | ||
dedication](https://creativecommons.org/publicdomain/zero/1.0/). | ||
|
||
All contributions to this project will be released under the CC0 | ||
dedication. By submitting a pull request, you are agreeing to comply | ||
with this waiver of copyright interest. | ||
|
||
[cisagov/cyhy-commander]: https://github.com/cisagov/cyhy-commander | ||
[cisagov/cyhy-reports]: https://github.com/cisagov/cyhy-reports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
data "amazon-ami" "debian_buster" { | ||
filters = { | ||
name = "debian-10-amd64-*" | ||
root-device-type = "ebs" | ||
virtualization-type = "hvm" | ||
} | ||
most_recent = true | ||
owners = ["136693071363"] | ||
region = var.build_region | ||
} | ||
|
||
data "amazon-ami" "debian_bookworm" { | ||
filters = { | ||
name = "debian-12-amd64-*" | ||
root-device-type = "ebs" | ||
virtualization-type = "hvm" | ||
} | ||
most_recent = true | ||
owners = ["136693071363"] | ||
region = var.build_region | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
source "amazon-ebs" "bastion" { | ||
ami_block_device_mappings { | ||
delete_on_termination = true | ||
device_name = "/dev/xvda" | ||
encrypted = true | ||
volume_size = 8 | ||
volume_type = "gp3" | ||
} | ||
ami_name = "${var.ami_prefix}-bastion-hvm-${local.timestamp}-x86_64-ebs" | ||
ami_regions = var.ami_regions | ||
instance_type = "t3.small" | ||
launch_block_device_mappings { | ||
delete_on_termination = true | ||
device_name = "/dev/xvda" | ||
encrypted = true | ||
volume_size = 8 | ||
volume_type = "gp3" | ||
} | ||
region = var.build_region | ||
source_ami = data.amazon-ami.debian_bookworm.id | ||
ssh_username = "admin" | ||
tags = { | ||
Application = "Cyber Hygiene" | ||
Architecture = "x86_64" | ||
Base_AMI_Name = data.amazon-ami.debian_bookworm.name | ||
OS_Version = "Debian Bookworm" | ||
Pre_Release = var.is_prerelease | ||
Release = "Latest" | ||
Team = "VM Fusion - Development" | ||
} | ||
temporary_key_pair_type = "ed25519" | ||
} | ||
|
||
build { | ||
sources = ["source.amazon-ebs.bastion"] | ||
|
||
provisioner "ansible" { | ||
groups = ["bastion"] | ||
playbook_file = "ansible/upgrade.yml" | ||
use_proxy = false | ||
use_sftp = true | ||
} | ||
|
||
provisioner "ansible" { | ||
groups = ["bastion"] | ||
playbook_file = "ansible/python.yml" | ||
use_proxy = false | ||
use_sftp = true | ||
} | ||
|
||
provisioner "ansible" { | ||
ansible_env_vars = ["AWS_DEFAULT_REGION=${var.build_region}"] | ||
groups = ["bastion"] | ||
playbook_file = "ansible/playbook.yml" | ||
use_proxy = false | ||
use_sftp = true | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 also should mention here how to build all of the AMIs at once like we do in the main repo README.