Skip to content

soudegesu/my_packer_best_practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

my_packer_best_practice

My best practice of project structure to provison AWS EC2 AMI with Packer.

Preconditions

This repository requires following runtime environment and modules.

Setting up

  • Install ansible
pip install -r requirements.txt -c constraints.txt

Test ansible scripts locally

  • Boot vargrant instance, initialize and take vagrant snapshot for rollback.
make init-vagrant
  • Provison to vagrant instance with null provisioner, and rollback to initial instance state.
    • ROLE : role name linked ansible-playbook file.
make test-local ROLE=hoge

Create AMI

  • Edit your aws credential information on ~/.aws/credentials.
[your-profile]
aws_access_key_id = [your access_key_id]
aws_secret_access_key = [your_secret_access_key]
region = [your region]
  • Edit packer/env-aws-variables.json that includes packer setting for AWS provisioning.
{
    "aws_region": "your-region",
    "aws_vpc_id": "vpc-xxxxxxxxxxxxxx",
    "aws_subnet_id": "subnet-xxxxxxxxxxx",
    "ssh_user": "centos",
    "use_profile": "your-profile",
    "aws_instance_role": "your-packer-role",
    "aws_keypair_name": "your-keypair-name"
}
  • Provision AWS instacne
make create-ami ROLE=hoge AWS_KEY_FILE=${absolute path to aws key file for ssh to instance}

Releases

No releases published

Packages

No packages published