Skip to content

Instantly share code, notes, and snippets.

@vpack
vpack / cpu_speed.sh
Created February 7, 2015 15:17
CPU performance check
time for i in {0..10000}; do for j in {0..1000}; do :; done; done
@vpack
vpack / Chef-solo.md
Last active February 7, 2018 11:15
Chef Solo

Chef Solo is very useful for single server configuration management.

Chef Solo config file '/etc/chef/solo.rb' is optional and it defaults to repo='/var/chef/'.

Just copy cookbooks directly to /var/chef/cookbooks. Run them using chef-solo command.

For e.g

chef-solo -o 'recipe[awsutil::cloudwatchlog]'
@vpack
vpack / ChefTrainingVideos.md
Last active August 29, 2015 14:14
Chef : Getting Started Training

Chef Training Resources

@vpack
vpack / autoscale.md
Last active August 29, 2015 14:15
Auto scale and get me the private IPs

Its easy to login to the AWS console to spin up an instance to test your app. But it gets frustrating when you have do this over and over developing/testing automation scripts (Chef recipes or Shell scripts).

I wrote this simple script using AWS CLI to kill the current instance and spin up a new instance. Once i have the IP,I login via SSH to verify the results.

  • kill: > autoscale.sh 0
  • Spin a new instance: > autoscale.sh 1
    • You can run this a few times until an IP is assigned to the new instance.
@vpack
vpack / openldap-search.sh
Last active August 29, 2015 14:15
openLDAP commands for verifying LDAP connection
# sudo su
yum install openldap-clients
echo "TLS_REQCERT never" >> /etc/openldap/ldap.conf
ldapsearch -LLL -H ldaps://naas1.myco.com:636 -b 'dc=myco,dc=com' -D 'CN=chefAdmin,CN=Service,CN=Non-People,DC=myco,DC=com' -W -d 3
ldapsearch -LLL -H ldaps://naas1.myco.com:636 -b 'dc=myco,dc=com' -D 'CN=chefAdmin,CN=Service,CN=Non-People,DC=myco,DC=com' -W '(sAMAccountName=MY USER ID)' | grep -i samac
@vpack
vpack / KeyPair.md
Last active August 29, 2015 14:15
AWS KeyPair

This is simple. But i couldn't understand why the fingerprints don't match in AWS. So i started to dig deeper.

  • Option 1: Generate a key and upload the key to multiple AWS regions. (Clean and Simple)
  • Option 2: Create new Key at AWS and uplaod the key to other AWS regions.

When creating private key using Amazon (CLI or console) the fingerprint that appears AWS console will be the fingerprint on the private key. However when you import that same key to other regions, the fingerprint that appears AWS console will be the fingerprint on the public key. (This is the current behavior at the time of this writing.) To keep the fingerprints consistent, delete the AWS Keypair in the region you created the key and (re)import the public key.

@vpack
vpack / file2fs.sh
Created March 4, 2015 14:10
Mounting a file as a filesystem
# Create a new file
dd if=/dev/zero of=my_fs bs=1M count=1024
Or
truncate -s 30M my_fs
# Check if the device is not already in use before using it
sudo losetup /dev/loop0
sudo losetup /dev/loop0 my_fs
# Make a file system and mount it
@vpack
vpack / chefdkInstall.sh
Last active August 29, 2015 14:16
Chef dk install in Amazon Linux
curl -L https://www.opscode.com/chef/install.sh | bash
or
curl -L https://www.opscode.com/chef/install.sh | bash -s -- -v 11
rpm -Uvh https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chefdk-0.4.0-1.x86_64.rpm
mkdir /var/chef
cd /var/chef
yum -y install git