WARNING: THIS PROJECT ASSUMES PRE-CONFIGURED IMAGES. THIS WILL LIKELY NOT WORK OUTSIDE INTERNAL CHEF
DOUBLE WARNING: THE ABOVE IS ESPECIALLY TRUE FOR CHEF ESSENTIALS WINDOWS IT WILL ONLY WORK IN THE TRAINING AWS ACCOUNT
Creating machines for students to use in our onsite Chef training takes manual effort. I don't like manual effort. This project reduces manual effort significantly.
This project does the following:
- Creates machines for onsite Chef training
- Creates a Markdown file that assigns machines to students
This project depends on Hashicorp Terraform to create resources in AWS. Ensure Terraform is installed by installing from here.
NOTE: This guide assumes that the Terraform binary is in your PATH environment variable. Your package manager should handle this. If not, place the binary in
/usr/local/bin
or if on Windows, create a directory containing that binary and add it to your%PATH%
(Example:C:\Hashicorp\terraform
)
Terraform uses the AWS CLI to perform the actions of the AWS provider. To install the AWS CLI follow the guide here.
Make sure to configure your ~/.aws/credentials
as well (see here).
- Verify
~/.aws/credentials
is configured. (see here) - Copy
config.yml.example
toconfig.yml
- Modify
config.yml
- Modify class type
- Modify company name
- Modify tag info (X-Dept, X-Contact)
- Modify student list
- Run
rake create
or./exe/garcon PATH_TO_CONFIG_YAML create
- Verify that the AMIs used match the AMIs in Appendix Z of your training material
- Create a GitHub Gist from resulting Markdown in
output/
(I recommend using https://github.com/defunkt/gist) - Profit
- Run
rake destroy:force
or./exe/garcon PATH_TO_CONFIG_YAML destroy --force
- Run
terraform destroy
in the terraform directory corresponding to your class (Example:output/2017-04-06-Testing-chef-essentials-windows/terraform/
)
Since this project uses Terraform you have the option to configure it to use an multiple AWS accounts. To do this you need to configure profiles in your ~/.aws/config
. A detailed guide on this process can be found here.
TL;DR:
- Add a profile block to your
~/.aws/config
. Example:
[default]
region=us-west-2
output=json
[profile other-account]
region=us-east-1
output=json
- Add credentials for your profile to
~/.aws/credentials
. Example:
[default]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
[other-account]
aws_access_key_id=AKIAI44QH8DHBEXAMPLE
aws_secret_access_key=je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
- Modify profile value in your
config.yml
- Follow other parts of the
How to Use
section above
NOTE: Should you have AWS access and secret keys hardcoded as environment variables Terraform will give these values precedence. You may wish to update those entries or manage your AWS credentials as indicated above.
This project both conforms to RuboCop standards and has RSpec tests.
To run both use: rake test
To run just RSpec run: rake test:unit
To run just RuboCop run: rake test:lint
When creating Linux classrooms Terraform occasionally selects an AWS region that does not support t1.micro
instances
Delete class directory under output/
and try again