Mar 4 2014

Raspberrypi and ISPUnity

Raspberrypi is a credit card sized computer. Link SAMSUNG

ISPUnity is an opensource rubygem/software based multiple internet load balancer and failover. Link .Anybody can download, install, configure and use it for free. Although professional help and support is also available for a small fees from us.

We released ISPUnity at RubyConf2012. While it was much appreciated and well received, the adoption was not that fast. Few of the reasons that interested users mentioned that was making them reluctant to try it out was:

  1. ISPUnity runs on linux.(There were many who were either using windows or mac.)
  2. It neeeded multiple nics(one for each internet connection.)
  3. Some small startup was not ready to dedicate 1 complete machine to act as the gateway with all the services installed etc.
  4. Some individuals who had multiple internet connections wanted to deploy it at home.
  5. ISPUnity currently doesn’t have a web UI.

When sometime back i heard about Raspberrypi, a low cost, low power basic computer and what other community members are making use of it, i thought it’ll be really good idea to use Raspberrypi for ispunity and make it my gateway.

Hence, mentioned below is the detailed description of my experience with Raspberrypi, ISPUnity and the cost involved and functionality that i’m using it for.

Hardware:

Descrition Cost(INR)
Raspberry Pi – Model B – 512MB Complete Kit : 5650
  • SoC – Broadcom BCM2835
  • CPU – 700 MHz ARM1176JZF-S core (ARM11 family)
  • GPU – Broadcom VideoCore IV, OpenGL ES 2.0, MPEG-2
  • Memory – 512MB
  • USB 2.0 – 2 Ports
  • Video Outputs – HDMI and Composite RCA
  • Audio Out – 3.5 mm jack and via HDMI
  • Storage – SD Card Slot supports Upto 32GB
  • Network – 10/100 Ethernet (RJ45)
  • Power Source – 5Volt (Micro USB)
  • Size – 85.60 mm × 53.98 mm
  • Weight – 45g
  • Operating Systems – Debian Linux, Raspbian OS, Fedora, Arch Linux ARM, XBMC
USB wireless adaptor2000
4 port USB hub100

Software:

OS: Raspbian After playing around with all the various linux distros for Raspberrypi i finalized to use Raspbian. I connected the lan interface to 1 internet and wifi adapter to another internet, and installed ISPUnity on it and ran it and it worked well :)

Screenshot from 2014-02-12 01:30:27

Services:

  • ISPUnity: Installed and configured ISPUnity and works like a charm.
  • DHCP server: To dynamically provide ip’s to my machines on the network.
  • DNS server: Becuase every ISP has it’s on dns, and the request for the same should come from their own network, that creates a problem when cross request are sent. So, better to have a caching dns server with forwarders to open dns servers across the globe.
  • Proxy Server: currently i’m using proxy just to conserve bandwith, and faster response through the proxy cache. But i could use it for filtering the traffic as well.
  • Firewall: There are very few necessary ports opened and that too for security and safety reasons are protected and filtered via firewall.
  • Wakeonlan: Earlier i had to keep my systems running 24×7 for various reasons, which used to consume power ranging from 250W – 500W based on the smps. Now all my systems are powered off when not required and Raspberrypi can wake the server/system whenever it’s required, thus saving lot of power and electricity bill. There is no problem in running Raspberrypi 24×7 as it only consumes 5V.
  • Network storage: I then attached 1 usb hard disk that i already had to Raspberrypi and all my downloads are saved and shared from it. So that makes it a low cost NAS device also.

Some limitations:

  1. Overall the device works well and can handle the workload of a SOHO. but you can’t change/extend/increase the specs like cpu and ram etc as of now.
  2. Lan card is attached to the board via usb2 interface, so max network throughput that you’ll get is somewhere between 2-3 mbps. So be aware of that.
  3. Limited number of device drivers eg: wifi adapter works with Raspberrypi, so be sure to check the HCL (Hardware compatibilty list) before buying accessories.
  4. I’ve got a usb2lan adapter, it gets detected, but b’cas of driver issue, it’s not working on it currently. so if someone has/know a usb2lan adapter that would work with Raspberrypi that will be a lot of help.

Jun 12 2013

[solved] cannot load such file — rubygems/format (LoadError)

require’: cannot load such file — rubygems/format (LoadError)

 ➜ appsurfer git:(master) knife cookbook
 zsh: correct 'cookbook' to 'cookbooks' [nyae]? n
 /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.4.4/lib/chef/provider/package/rubygems.rb:34:in `require': cannot load such file -- rubygems/format (LoadError)
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.4.4/lib/chef/provider/package/rubygems.rb:34:in `'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.4.4/lib/chef/providers.rb:60:in `require'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.4.4/lib/chef/providers.rb:60:in `'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.4.4/lib/chef.rb:25:in `require'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.4.4/lib/chef.rb:25:in `'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chefspec-1.3.0/lib/chefspec.rb:1:in `require'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chefspec-1.3.0/lib/chefspec.rb:1:in `'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chefspec-1.3.0/lib/chef/knife/cookbook_create_specs.rb:1:in `require'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chefspec-1.3.0/lib/chef/knife/cookbook_create_specs.rb:1:in `'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.4.4/lib/chef/knife/core/subcommand_loader.rb:37:in `load'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.4.4/lib/chef/knife/core/subcommand_loader.rb:37:in `block in load_commands'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.4.4/lib/chef/knife/core/subcommand_loader.rb:37:in `each'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.4.4/lib/chef/knife/core/subcommand_loader.rb:37:in `load_commands'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.4.4/lib/chef/knife.rb:119:in `load_commands'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.4.4/lib/chef/knife.rb:167:in `run'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.4.4/lib/chef/application/knife.rb:123:in `run'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/gems/chef-11.4.4/bin/knife:25:in `'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/bin/knife:23:in `load'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/bin/knife:23:in `'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `eval'
 from /home/arun/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `'

the gem environment looked like this

 ➜ appsurfer git:(master) gem env
 RubyGems Environment:
 - RUBYGEMS VERSION: 2.0.3
 - RUBY VERSION: 2.0.0 (2013-05-14 patchlevel 195) [x86_64-linux]
 - INSTALLATION DIRECTORY: /home/arun/.rvm/gems/ruby-2.0.0-p195
 - RUBY EXECUTABLE: /home/arun/.rvm/rubies/ruby-2.0.0-p195/bin/ruby
 - EXECUTABLE DIRECTORY: /home/arun/.rvm/gems/ruby-2.0.0-p195/bin
 - RUBYGEMS PLATFORMS:
 - ruby
 - x86_64-linux
 - GEM PATHS:
 - /home/arun/.rvm/gems/ruby-2.0.0-p195
 - /home/arun/.rvm/gems/ruby-2.0.0-p195@global
 - GEM CONFIGURATION:
 - :update_sources => true
 - :verbose => true
 - :backtrace => false
 - :bulk_threshold => 1000
 - REMOTE SOURCES:
 - https://rubygems.org/

Solution: i finally found that it’s neither ruby or chef’s fault but a problem with rubygems. so if you downgrade or use rubygems 1.8.25, everything works perfectly fine.

 ➜ appsurfer git:(master) rvm rubygems 1.8.25
 Retrieving rubygems-1.8.25
 Extracting rubygems-1.8.25 ...
 Removing old Rubygems files...
 Installing rubygems-1.8.25 for ruby-2.0.0-p195.....................
 Installation of rubygems completed successfully.

and then switch it to use that rubygems.

echo "rubygems_version=latest-1.8.25" >> $rvm_path/user/db

exit the shell and open new shell and test the settings. you should see something like this

 ➜ appsurfer git:(master) gem env
 RubyGems Environment:
 - RUBYGEMS VERSION: 1.8.25
 - RUBY VERSION: 2.0.0 (2013-05-14 patchlevel 195) [x86_64-linux]
 - INSTALLATION DIRECTORY: /home/arun/.rvm/gems/ruby-2.0.0-p195
 - RUBY EXECUTABLE: /home/arun/.rvm/rubies/ruby-2.0.0-p195/bin/ruby
 - EXECUTABLE DIRECTORY: /home/arun/.rvm/gems/ruby-2.0.0-p195/bin
 - RUBYGEMS PLATFORMS:
 - ruby
 - x86_64-linux
 - GEM PATHS:
 - /home/arun/.rvm/gems/ruby-2.0.0-p195
 - /home/arun/.rvm/gems/ruby-2.0.0-p195@global
 - GEM CONFIGURATION:
 - :update_sources => true
 - :verbose => true
 - :benchmark => false
 - :backtrace => false
 - :bulk_threshold => 1000
 - REMOTE SOURCES:
 - http://rubygems.org/

Feb 18 2013

how to configure chef workstation with chef server 11

So I figured, even configuration of chef workstation with chef server 11 is a bit different.

This is how I’ve configured my chef workstation with my open source chef server 11. Please note: I’m firing all these commands from my chef workstation.

First, i created a folder where i want to have all my code.

➜ /tmp mkdir chef11
➜ /tmp cd chef11

Then clone the chef repo.

➜ chef11 git clone https://github.com/opscode/chef-repo.git
Initialized empty Git repository in /tmp/chef11/chef-repo/.git/
remote: Counting objects: 202, done.
remote: Compressing objects: 100% (121/121), done.
remote: Total 202 (delta 73), reused 160 (delta 48)
Receiving objects: 100% (202/202), 34.25 KiB | 5 KiB/s, done.
Resolving deltas: 100% (73/73), done.

Create a .chef folder inside the chef-repo and create a empty knife.rb file.

➜ chef11 cd chef-repo
➜ chef-repo git:(master) pwd
/tmp/chef11/chef-repo
➜ chef-repo git:(master) mkdir .chef
➜ chef-repo git:(master) cd .chef
➜ .chef git:(master) ls
➜ .chef git:(master) touch knife.rb

In my case, my chef server is named and chef11.linuxguy.in and is resolvable by my dns. you can use the ip or fqdn, once you configure it into your hosts file.

Anyways, what you need is admin.pem and chef-validator.pem files from the chef server 11. These are located in /etc/chef-server

Note: In earlier version of open source chef server, we needed 2 files, validation.pem and webui.pem, and they used to be in /etc/chef on the chef server.

➜ .chef git:(master) ✗ scp root@chef11.linuxguy.lan:/etc/chef-server/admin.pem .
Warning: Permanently added 'chef11.linuxguy.lan' (RSA) to the list of known hosts.
root@chef11.linuxguy.lan's password:
admin.pem 100% 1675 1.6KB/s 00:00
➜ .chef git:(master) ✗ scp root@chef11.linuxguy.lan:/etc/chef-server/chef-validator.pem .
root@chef11.linuxguy.lan's password:
chef-validator.pem 100% 1679 1.6KB/s 00:00
➜ .chef git:(master) ✗ ls
admin.pem chef-validator.pem knife.rb
➜ chef-repo git:(master) ✗ pwd
/tmp/chef11/chef-repo

Now configure your knife.rb

➜ chef-repo git:(master) ✗ knife configure -i
Overwrite /tmp/chef11/chef-repo/.chef/knife.rb? (Y/N) y
Please enter the chef server URL: [http://router.linuxguy.lan:4000] https://chef11.linuxguy.lan
Please enter a name for the new user: [arun] testuser
Please enter the existing admin name: [admin] admin
Please enter the location of the existing admin's private key: [/etc/chef/admin.pem] .chef/admin.pem
Please enter the validation clientname: [chef-validator]
Please enter the location of the validation key: [/etc/chef/validation.pem] .chef/chef-validator.pem
Please enter the path to a chef repository (or leave blank):
Creating initial API user...
Please enter a password for the new user:
Created user[testuser]
Configuration file written to /tmp/chef11/chef-repo/.chef/knife.rb
➜ chef-repo git:(master) ✗ cd .chef
➜ .chef git:(master) ✗ ls
admin.pem chef-validator.pem knife.rb testuser.pem
➜ .chef git:(master) ✗ cd ..

Now confirm whether you can access your chef server or not.

➜ chef-repo git:(master) ✗ knife user list
admin
ak
crazy
testuser

That’s it.

Enjoy.

Arun Tomar.

Note: Please leave your valuable feedback and comments to improve it or if i made any mistake.