kostyrev / packer-anaconda

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status

SSH

General info

Read this overview.

Generate ssh key

Follow this guide to generate new ssh key.

Specify default username and keepalive for ssh (optionally)

cat >> ~/.ssh/config <<EOF
Host *
   User kostyrev
   ServerAliveInterval 30
   ServerAliveCountMax 10
EOF

Homebrew (MacOS only)

Read about brew and install it.

Working with this repository

Initial cloning

cd ~/
git clone https://github.com/kostyrev/packer-anaconda.git
cd packer-anaconda

Pulling recent commits

git pull --no-edit origin $(git rev-parse --abbrev-ref HEAD) --rebase --ff-only

PRs

Read this guide about pull requests.

Building AMI (for admins only)

Using packer

make anaconda

Using molecule

Use molecule to verify that packer will build right AMI with all required packages and modifications.

Using AMI

Configure required environment variables

cp .envrc.dist .envrc and set appropriate environment variables in it.

AWS_PROFILE

AWS_PROFILE is used to configure aws_access_key_id and aws_secret_access_key to access AWS API in some AWS account.
For example, you could name your profile fasten-analytics and configure it:

mkdir ~/.aws/
cat >> ~/.aws/credentials <<EOF
[fasten-analytics]
aws_access_key_id=AKIAIXXXXXXXXXX
aws_secret_access_key=XXXXXXXXXXX
EOF

TF_VAR_spot_price

TF_VAR_spot_price is a price you willing to pay for an instance on the spot market. Gradually increase this value until your request for instance is fulfilled.

Export those environment variables by sourcing .envrc manually
. .envrc
or
read and setup direnv.

Note: Use brew install direnv on MacOS

Note: Do not forget to execute direnv allow . after installing.

Use terraform to request an instance

Install terraform

Note: Use brew install terraform on MacOS

Note: Before creating any resources execute terraform plan to verify that terraform will do what you planned it to do.

Create volume to persist data

cd terraform/volume
terraform apply

Start instance with volume

cd ..
terraform apply

Connect to instance with port forwarding for jupiter

connect to instance
ssh -L 127.0.0.1:8888:127.0.0.1:8888 ubuntu@$(terraform output public_address)
run jupiter
jupyter notebook --port=8888 --no-browser

Destroy instance

cd terraform/
terraform destroy

Note: Do not cd into terraform/volume and do not terraform destroy in it unless you know what you are doing

Demo

asciicast

About


Languages

Language:HCL 73.5%Language:Shell 20.4%Language:Makefile 6.1%