Skip to content

Instantly share code, notes, and snippets.

@miztiik
Last active August 30, 2016 05:37
Show Gist options
  • Save miztiik/0029ede6b994c25b089e351ef053c2cb to your computer and use it in GitHub Desktop.
Save miztiik/0029ede6b994c25b089e351ef053c2cb to your computer and use it in GitHub Desktop.
chef-workstation-quick-setup.sh
yum install deltarpm wget unzip python-pip -y
cd /tmp
wget https://github.com/miztiik/Learn-Chef/blob/master/init/init.zip?raw=true -O init.zip
mv init.zip /
cd /
unzip init.zip
cd /chef-repo
# curl -L https://www.opscode.com/chef/install.sh | bash
curl -L https://www.opscode.com/chef/install.sh | bash -s -v 12.13.30 && rm install.sh
service chef-client restart
knife ssl check && knife client list
# Install AWS CLI
pip install awscli
# Install Boto
pip install -U boto
# Get the AWS EC2 plugin
## Set chef ruby as default in profile
export PATH="/opt/chefdk/embedded/bin:${HOME}/.chefdk/gem/ruby/2.1.0/bin:$PATH"
chef gem install knife-ec2
# Configure AWS Profile
## in /chef-repo/.chef/knife.rb file
knife[:aws_access_key_id] = "Your_AWS_Access_Key"
knife[:aws_secret_access_key] = "Your_AWS_Secret_Access_Key"
# To set your default AWS region,
knife[:region] = "us-east-1"
# To set your instance launching keypair,
knife[:ssh_key_name] = "kum-key"
# Launch an instance
# This will launch a Red-Hat free tier instance
knife ec2 server create --image ami-2051294a \
--ssh-key kum-key \
--flavor t2.micro \
--ssh-user ec2-user \
--identity-file /chef-repo/.chef/kum-key.pem \
--region us-east-1a \
--node-name "webNode01"
@miztiik
Copy link
Author

miztiik commented Aug 1, 2016

Create an EC2 instance using Chef knife

  • "role[ubuntu]" : The run_list I want to associate with the newly created node. You can put any roles and recipes you like here
  • -I : The AMI ID that you would like to start
  • -f or --flavor : The Amazon EC2 instance type
  • -S or --ssh-key : The name you gave to the SSH key pair generated in the AWS management console
  • -i or --identity-file : The private key file of that SSH key pair as downloaded when the key pair was created in the AWS management console
  • --ssh-user : The official Ubuntu EC2 AMIs use ubuntu as the default user
  • --region : If you want your instances to be deployed in any specific Amazon AWS region, add this parameter and the desired region
  • -Z : The availability zone within your region

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment