Yearly Archives: 2012

TryStack is OpenStack Sandbox

OpenStack announced their sandbox called TryStack.
The saying goes like this “The Easiest Way To Try Out OpenStack”.

I manage to get an account via Facebook and testdrive TryStack.
The username and password were posted at Messages->Others. 🙂
The steps to launch an instance using TryStack
1. Creating Keypairs.
Name your keypair, mine is trystack. It will prompt to download.
Save the file will be used for SSH later.
Screenshot is here.

2. Allowing ports SSH and HTTP. In this case open to all networks for port 22 and 80.
Screenshot is here.

3. Click on Images, and put some server name, instance type, and user-data.
Screenshot is here.

4. Success page. Screenshot here.

5. Now try to SSH to the instance using the keypair downloaded.

chmod 600 ~/trystack/trystack.pem
ssh -i ~/trystack/trystack.pem ubuntu@<IP-ADDRESS> -v 
...
... 
ubuntu@apache-server:~$ tail /tmp/apache2_install.log 
finished install apache2
ubuntu@apache-server:~$ netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 *:www                   *:*                     LISTEN     
tcp        0      0 *:ssh                   *:*                     LISTEN     
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN     
udp        0      0 *:bootpc                *:*                                
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     STREAM     LISTENING     4620     @/com/ubuntu/upstart
unix  2      [ ACC ]     STREAM     LISTENING     6882     /var/run/apache2/cgisock.952
ubuntu@apache-server:~$ 

Very nice and cool..! Don’t you think? 🙂

Update March 20,2012:
Here’s a good tutorial also using nova client from Sagar.

LittleChef: playing with Chef recipes

For small number of servers and push deployment, I show how to run LittleChef here:

Using RVM for Ruby needed for Chef’s knife later.

ubuntu@testbox:~/littlechef$ rvm use 1.9.2

Using virtrualenv for Python, so as not to clutter environment’s Python installation.
Genenerate metadata.json for Chef recipes.

ubuntu@testbox:~/littlechef$ workon lchef
ubuntu@testbox:~/littlechef$ cd kitchen/cookbooks
(lchef)ubuntu@testbox:~/littlechef/kitchen/cookbooks$ knife cookbook metadata -a  -o ./
Generating metadata for alestic_ppa from /home/ubuntu/littlechef/kitchen/cookbooks/alestic_ppa/metadata.rb
Generating metadata for apt from /home/ubuntu/littlechef/kitchen/cookbooks/apt/metadata.rb
Generating metadata for graylog2 from /home/ubuntu/littlechef/kitchen/cookbooks/graylog2/metadata.rb
Generating metadata for java from /home/ubuntu/littlechef/kitchen/cookbooks/java/metadata.rb
Generating metadata for java_sun from /home/ubuntu/littlechef/kitchen/cookbooks/java_sun/metadata.rb
Generating metadata for logrotate from /home/ubuntu/littlechef/kitchen/cookbooks/logrotate/metadata.rb
Generating metadata for mdadm from /home/ubuntu/littlechef/kitchen/cookbooks/mdadm/metadata.rb
Generating metadata for memcached from /home/ubuntu/littlechef/kitchen/cookbooks/memcached/metadata.rb
Generating metadata for mongodb from /home/ubuntu/littlechef/kitchen/cookbooks/mongodb/metadata.rb
Generating metadata for mongodbx from /home/ubuntu/littlechef/kitchen/cookbooks/mongodbx/metadata.rb
Generating metadata for nginx from /home/ubuntu/littlechef/kitchen/cookbooks/nginx/metadata.rb
Generating metadata for quick_start from /home/ubuntu/littlechef/kitchen/cookbooks/quick_start/metadata.rb
Generating metadata for runit from /home/ubuntu/littlechef/kitchen/cookbooks/runit/metadata.rb
Generating metadata for xfs from /home/ubuntu/littlechef/kitchen/cookbooks/xfs/metadata.rb

List nodes using LittleChef:

(lchef)ubuntu@testbox:~/littlechef/$ fix list_nodes
ec2-xx-xx-xxx-xxx.compute-1.amazonaws.com
  Roles: 
  Recipes: alestic_ppa
  Node attributes:

server2
  Roles: 
  Recipes: mdadm, memcached
  Node attributes:
    mdadm: {'DEVICE': '/dev/sdj'}
    memcached: {'memory': '512'}

List of files on my kichen directory:

 
(lchef)ubuntu@testbox:~/littlechef/kitchen$ ls
auth.cfg  cookbooks  data_bags  nodes  roles  site-cookbooks

(lchef)ubuntu@testbox:~/littlechef/kitchen$ ls cookbooks/
alestic_ppa  apt  graylog2  java  java_sun  logrotate  mdadm  memcached  mongodb  mongodbx  nginx  quick_start  README  runit  xfs
 

Ok, let’s run the nginx installation using LittleChef to lucid32 server.
For simplicity, /etc/hosts file contains the IP mapping of lucid32 server.

(lchef)ubuntu@testbox:~/littlechef/kitchen$ fix node:lucid32 recipe:nginx

== Applying recipe 'nginx' on node lucid32 ==
Saving node configuration to nodes/lucid32.json...
Synchronizing node, cookbooks, roles and data bags...
ubuntu@lucid32's password: 

Cooking...
[Mon, 06 Feb 2012 23:13:40 -0800] INFO: *** Chef 0.10.8 ***
[Mon, 06 Feb 2012 23:13:40 -0800] INFO: Setting the run_list to ["recipe[nginx]"] from JSON
[Mon, 06 Feb 2012 23:13:40 -0800] INFO: Run List is [recipe[nginx]]
[Mon, 06 Feb 2012 23:13:40 -0800] INFO: Run List expands to [nginx]
[Mon, 06 Feb 2012 23:13:40 -0800] INFO: Starting Chef Run for lucid32
[Mon, 06 Feb 2012 23:13:40 -0800] INFO: Running start handlers
[Mon, 06 Feb 2012 23:13:40 -0800] INFO: Start handlers complete.
[Mon, 06 Feb 2012 23:13:41 -0800] INFO: execute[apt-get update] sh(apt-get update)
[Mon, 06 Feb 2012 23:13:44 -0800] INFO: execute[apt-get update] ran successfully
[Mon, 06 Feb 2012 23:13:44 -0800] INFO: directory[/var/cache/local] mode changed to 755
[Mon, 06 Feb 2012 23:13:44 -0800] INFO: Chef Run complete in 4.193466 seconds
[Mon, 06 Feb 2012 23:13:44 -0800] INFO: Running report handlers
[Mon, 06 Feb 2012 23:13:44 -0800] INFO: Report handlers complete

SUCCESS: Node correctly configured

Done.
Disconnecting from lucid32... done.

Now to check for the running Nginx server:

(lchef)ubuntu@testbox:~/littlechef/kitchen$ fix node:lucid32 ssh:"sudo netstat -lp | grep nginx "

Executing the command 'sudo netstat -lp | grep nginx ' on the node lucid32...
tcp        0      0 *:www                   *:*                     LISTEN      814/nginx       

Done.
Disconnecting from lucid32... done.