Reference doc learn-chef
-
create a aws account and gather the below details
a. Create your credentials file b. Note your region and availability zone c. Note your VPC subnet d. Create a security group e. Get the AMI ID for CentOS 7 in your region f. Prepare your key pair file
-
Download learn_chef_httpd cookbook from github
-
Create a folder for cookbooks for example
mkdir learn-chef/cookbooks
- Clone the learn_chef_cookbook from github
prereq: install git
git clone https://github.com/learn-chef/learn_chef_httpd.git
now change the directory.
cd ~/learn-chef/cookbooks/learn_chef_httpd
- Edit the .kitchen.yml file as below
---
driver:
name: ec2
aws_ssh_key_id: learn-chef
region: us-east-1
availability_zone: b
subnet_id: subnet-3f22bd15
instance_type: t2.micro
image_id: ami-6d1c2007
security_group_ids: sg-0e08cf75
retryable_tries: 120
provisioner:
name: chef_zero
verifier:
name: inspec
transport:
ssh_key: /root/.ssh/learn-chef.pem
platforms:
- name: centos-7.2
suites:
- name: default
run_list:
- recipe[learn_chef_httpd::default]
verifier:
inspec_tests:
- test/smoke/default
attributes:
replace the following with the values you gathered in the previous part.
aws_ssh_key_id The name of your EC2 key pair
region Your AWS region
availability_zone Your AWS availability zone
subnet_id Your subnet ID
image_id Your AMI ID
security_group_ids Your security group ID
ssh_key The full path to the private part of your EC2 key pair file
- Create the test kitchen instance
To see what's in the kitchen
kitchen list
To create the instance
Kitchen create
Now to see the changes in the kitchen list
run it again.
- Now apply the learn_chef_httpd cookbook to your test kitchen
kitchen converge
- Test Kitchen runs chef-client on the instance. When the chef-client run completes successfully, Test Kitchen exits with exit code 0. Run the following to check the exit code.
echo $?
- To see the latest status run the
kitchen list
- To delete the test kitchen run
kitchen destroy