Fixing keyboard problems with OSX and virt-manager

If, like me, you have been running virt-manager over an SSH tunnel, and are getting problems with the keyboard / key mappings, then you may be able to fix them by changing the keyboard settings in the virtual machines configuration.

1) Click the details button in the virtual machines virt-manager window.

2) Navigate to the Display VNC option in the left hand menu.

3) You should now see a Keymap drop down box. Select the correct Keymap that matches your keyboard, in my case it was en-gb.

4) Click Apply.

Good luck, it worked for me!

 

Installing Ansible on OSX Lion

We’re currently evaluating configuration management (devops) tools at CATN to help us deploy and manage our new vCluster hosting platform in a production environment. Many of the tools we have looked at are fairly complicated, with a steep learning curve.

Then we came across, Ansible. It’s developed primarily by the guy who wrote Cobbler (our previous favourite deployment tool), and it’s been built from scratch to be much simpler to use.

Although it only took me just a few minutes to get it up and running, there were a couple of dependencies required to install it on OSX, so I thought I would document the steps here in case it helps someone else in the future:

Step 1 – Install Dependencies

Check that you have Xcode installed with , try typing gcc -v from the command line. If it says command not found, then ensure you have downloaded Xcode from App Store, then once it’s installed go to Xcode > Preferences > Downloads  and install the Command Line Tools.

Install pre-requisite Python modules on your main OSX machine that will be running ansible.

sudo easy_install jinja2
sudo easy_install PyYAML
sudo easy_install paramiko

If you get an error saying configure: error: no acceptable C compiler found in $PATH then you should double check you have Xcode and it’s command line tools as per the instructions above.

And on the managed nodes, assuming it’s a Centos/SL/RedHat node:

yum install python-simplejson

Step 2 – Checkout latest version of Ansible

Download the latest version from Github. Assuming you are installing into ~/github

cd ~/github
git clone git://github.com/ansible/ansible.git
cd ./ansible
source ./hacking/env-setup

Set up your bash profile to load the environment variables when you load a terminal

# Setup Ansible
cd ~/github/ansible
source ./hacking/env-setup
cd ~
export ANSIBLE_HOSTS=~/ansible_hosts
# End Ansible Setup

If you wanted to install it properly, rather than run the latest code from checkout you could do so with sudo make install. In this case you wouldn’t need to run the hacking/env-setup script to modify the environment variables, since ansible would be located within the ordinary search paths.

Step 3 – Test it works

Add some hosts to your ansible_hosts file, and then ping them.

echo "192.168.0.62" >> ~/ansible_hosts
ansible all -m ping

How to bulk add an ssh key to multiple servers

If you need to add a colleague’s ssh key to multiple servers that share a similar name, you can do it with a simple one liner. In this post I will show you how.

Assuming the servers you need to add they key to are called:

server1.example.com
server2.example.com
server3.example.com
server4.example.com
etc…

And your colleagues key is in a file called key.pub

To add to a list of consecutive servers, use:

for i in {1..10}; do ssh-copy-id -i key.pub root@server$i.example.com; done

If you wanted to list specific servers, you could use:

for i in {1,4,7,10}; do ssh-copy-id -i key.pub root@server$i.example.com; done

You can then check it worked with the following: (replace colleagues-key-comment with the comment that identifies their public key):

for i in {1..14}; do echo server$i; ssh root@server$i.example.com cat /root/.ssh/authorized_keys | grep colleagues-key-comment; done

Raspberry Pi Measurements & Dimensions

I was asked by Tim Lossen on one of my previous Raspberry Pi posts if I could take some measurements of the Pi board so that he could complete a 3D model of it that he is working on. Unfortunately, we don’t have a ruler in our house, so I’ve printed off some ruler sheets, and taken some photos of the board along side the rulers. Hopefully this will allow someone to take some more precise measurements of the components using Photoshop and it’s rulers.

I’ve also measured the heights to be the following:

  • Ethernet port – 13mm tall
  • Usb 2.0 ports – 15mm
  • Audio jack – 10mm
  • RCA video – 13mm
  • HDMI – 6 mm
  • SD Card – 4.5 mm (underneath)
  • Micro USB power – 2.5 mm

Raspberry Pi playing a 1080p video

In this short clip, I use my Raspberry Pi board to play a 1080p video – Big Buck Bunny. The playback is flawless with no interruptions. The commands used were:

sudo /opt/vc/bin/vcfiled
sudo /opt/vc/bin/ilplayer /home/pi/big_buck_bunny_1080p_h264_ac3.mkv

Big Buck Bunny is a short animated film by the Blender Foundation – (c) copyright 2008, Blender Foundation / www.bigbuckbunny.org.

Raspberry Pi #8 First Photoshoot

I came home from work this evening to find a small brown parcel containing a Raspberry Pi beta board that I had won in an ebay auction earlier this week. It was a charity auction with all the proceeds go to supporting the Raspberry Pi foundation whose aim is to promote computer science and electronics at the school level. I think this is an admirable aim – computer science has enabled me to run my own business, and I feel passionately that we should improve the teaching of it in schools.

The production boards should be going on sale in the next few months for £16 / £25 each depending on the model you choose. For those of you who are looking forward to ordering your own, I have taken some photos of it against my iPhone so you can get a better idea of the size for yourselves.

The first thing that strikes you about the Raspberry Pi board is how small it is. I had seen pictures of it online, but I’m sure it looked bigger! It’s great to see how far computing has evolved since I got my first BBC Model B computer approximately 25 years ago.

You can see the full size Raspberry Pi board diagram here.

Although these boards were designed for schools, I think they will transform the world of computing in myriad other ways. A few years ago the OLTP foundation set out to build a $100 laptop. 2012 marks the beginning of the $20 desktop.

What is the Raspberry Pi?

The Raspberry Pi board is effectively an entire computer on a credit card size board. Like a cut down Mac Mini, all you need is a keyboard and a monitor and you can run a full Linux desktop operating system like Fedora or Debian. It’ll even play Quake 3 and full 1080p films!

Re-using these photos

I’m releasing all these photos under the Creative commons attribution license:

Creative Commons License
Raspberry Pi Beta Board #8 Photos by Paul Maunders is licensed under a Creative Commons Attribution 2.0 UK: England & Wales License.

Raspberry Pi Beta Boards Raise Over £16,000 in ebay auctions

The Raspberry Pi Beta Board auctions have now finished, raising a total of £16,336 for the Raspberry Pi Charity.

  • The lowest winning bid was £930 for board 9
  • The highest winning bid was £3,500 for board 1

You can view the full spreadsheet here.

How to locate a previously submitted P60 or P45 on the HMRC Employers Portal

It always takes me a while to find the list of previously submitted documents on HMRC’s employers portal. So here are the steps for future reference:

  • Login to HMRC Online Services – https://online.hmrc.gov.uk/
  • On the services home page, click through to PAYE for Employers.
  • Click File PAYE return and forms online in the top right hand box.
  • Click Change Tax Year and then select the relevant tax year, e.g. 2010/2011.
  • Click Employee List from the left hand menu if you are not already on that page.
  • Click on the relevant employee name from the list.
  • Click View or Print submitted forms from the bottom of the page.
  • Click on the form you wish to download, and then download it from the following page.

And that’s it! Only 8 clicks 🙂

 

Green Easing – Save the planet while saving the economy

So we are now 4 years in to the worst recession since the 1980s, 1970s, 1930s, records began? and it seems like we are going to be stuck this way for a long time. Governments, individuals and companies around the world have racked up massive debts during the boom years, but they are now struggling to pay them back. For years central banks have targeted price stability (low inflation), but there is a growing realisation that stable prices can also mean stubborn debts, and so the previously unthinkable is now becoming a reality – that central banks pursue a higher rate of inflation in order to reduce the real value of old debts. Although the BoE have continued to state publicly that their inflation target is 2%, the reality in the UK is that we have had nearly 5% inflation (RPI) since early 2010.

The Bank of England have already created £275bn of new money through their quantitative easing programme, which they used to buy Government bonds from private banks (asset purchases). The theory is that the banks will then have more cash to lend to small businesses. The reality appears to be that banks don’t really want to lend to the sort of companies that want to borrow. If a higher rate of inflation is now palatable, could there be a more effective route to injecting cash into the economy and encourage nominal GDP growth?

If we are going to print money, I feel it should be used to purchase assets that will bring long term positive benefits to the country. I think residential solar power plants are particularly well suited to this idea, and a green quantitative easing programme could replace the existing Feed In Tariff scheme (which has nearly run out of money).

Green Quantitative Easing

£200Bn Green Easing Target: Install 10GW of residential solar plants per year, for the 8 years to 2020. 

  • Use printed money to fund the installation of solar panels on the roof / open space of any household or community who wishes to participate.
  • Money goes directly to businesses who install the panels, avoids the relying on the banks.
  • Tangible assets with tangible benefits – homeowners would feel positive they are receiving something good (free electricity) as a result of the policy (can the same be said of normal QE?).
  • Easily administered through the MCS scheme – upon successful registration of an installation, the supplier could be paid by bank transfer by the BoE.
  • No additional debt for government, companies or individuals. Ownership of the panels could be retained by the BoE (with a long term lease on the roofs), giving them a real asset for their balance sheet. Free electricity would go to the household, export revenue could be collected by the BoE. Effectively the Bank would own a distributed network of green power plants, which generate an income through selling power to the grid. These could later be bundled off and sold to the private sector if that was deemed necessary.
  • Helps alleviate Fuel poverty. The poorest households would get free electricity during the day to run their appliances.
  • In rough terms, £200 billion would be enough to put solar panels on every house in the country (or in open spaces for shared community projects), and would give us a total installed capacity of 80GW (@ £2500 per KW). This would produce more electricity than total UK demand in the middle of the day during peak months of summer – so we would need to also invest in suitable storage techniques (batteries or running hydro power stations in reverse). The panels could be installed at a rate of 10 GW per year, which is achievable and would cost only £25 billion each year.
  • We would easily meet our 2020 targets of generating 15% of power from renewable sources.
  • Overall energy costs would be reduced as the huge supply of solar electricity comes online.
  • The scheme would easily support around 55,000 jobs (Capacity per employee: assuming 230 working man days per year / 1.25 man days per KW installed  = 184,000 W installed per person per year. Number of jobs = 10,000,000,000 W/ 184,000 W = 54,348)
The idea is still pretty rough around the edges, but I think in principle it could work really well to generate growth whilst hitting our climate goals. The solar sector has shown they already have the ability to hit this level of installations, by installing nearly 126MW in the week before the Feed In Tarrifs were cut. This is an annualised rate of 6.5GW, and not far from the 10GW which would be needed. What are your views on this? Disclosure: I have put my money where my mouth is, as I have recently invested in a Solar Panel business through my company, Fubra Limited.

Further Reading

How to deploy Zimbra ZCS Open Source Edition on Amazon EC2

This guide should help you deploy Zimbra ZCS 7.1.3_GA on an Ubuntu 10.04 instance with Amazon EC2.

Prerequisites

1) Ensure you have set up Amazon EC2 CLI scripts …

Download tools from here http://aws.amazon.com/developertools/351

Generate certificates in the security credentials section of AWS control panel

Set up environment variables in your .bash_profile (using your key paths, and your preferred EC2 region)

export EC2_PRIVATE_KEY=/path/to/ec2-private-key.pem
export EC2_CERT=/path/to/ec2-cert.pem
export EC2_URL=https://eu-west-1.ec2.amazonaws.com

2) Ensure you have imported your public ssh key (replace paul-public-key with whatever label you want to use)

for r in us-east-1 us-west-1 ap-southeast-1 eu-west-1; do ec2-import-keypair --region $r paul-public-key --public-key-file ~/.ssh/id_rsa.pub ; done

3) Setup an elastic IP, and then create DNS entries for your mail server, that point to that IP. Let’s assume you are going to call your mail server mail1.example.com, you will need records in example.com’s zone for:

mail1 CNAME ec2-xxx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com.
mail1 MX 10 mail1

Where xxx-xxx-xxx-xxx is your elastic IP. For other domains, you can then point their MX records to mail1.example.com.

4) Setup a security group for your Zimbra server with the desired ports open (25,80,443, 110, 143, 389, 443, 993, 995, 7071, 7110, 7995, 7143, 7993 etc… ).

ec2-create-group "Zimbra ZCS" -d "Zimbra Collaboration Suite Group"
ec2-authorize "Zimbra ZCS" -P icmp -t -1:-1
ec2-authorize "Zimbra ZCS" -P tcp -p 22
ec2-authorize "Zimbra ZCS" -P tcp -p 25
ec2-authorize "Zimbra ZCS" -P tcp -p 80
ec2-authorize "Zimbra ZCS" -P tcp -p 7071

Instructions

1) Launch a new instance. Replace paul-public-key with the name of your public key (this will need to have been imported into AWS previously). The -g switch refers to your security group. We are using 100GB as the main disk size, as by default they are too small for a Zimbra installation.

// This will launch a new launch instance of Ubuntu 10.04 LTS
ec2-run-instances -t m1.large -g "Zimbra ZCS" -k paul-public-key -b "/dev/sda1=:100:false" ami-cc0e3cb8 --region eu-west-1

2) SSH in and resize the filesystem to the full disk size. Run ec2-describe instances to find your new instance’s IP address, then ssh in to it and resize the file system.

ssh ubuntu@your-instance-public-ip
sudo su -
resize2fs /dev/sda1

3) Assign the elastic IP you chose earlier

// Check your instances ID
ec2-describe-instances
// Associate the address to the instance
ec2-associate-address ELASTIC_IP_ADDRESS -i INSTANCE_ID

4) Set up hostname on the system

echo 'mail1.example.com' > /etc/hostname
echo '127.0.0.1 mail1.example.com mail1' >> /etc/hosts
hostname mail1.example.com

Then check it works with..

hostname --fqdn

IMPORTANT: The commands above specify 127.0.0.1 as the IP for the system’s hostname in /etc/hosts. You need all 3 fields listed in /etc/hosts (eg. 127.0.0.1 mail1.example.com mail1) – otherwise LDAP install fails as it tries to connect to resolved elastic IP. In addition, use a CNAME for the public DNS MX records hostname instead of A record, then when it is resolved internally, it should get a local IP, which should assist postfix with LMTP lookups. If you don’t do this you will get issues – http://wiki.zimbra.com/wiki/Incoming_Mail_Problems – A crude fix is to open port 7025 in the security group, but the CNAME is better.
4) Download Zimbra

cd /root/ 
mkdir zimbra
cd zimbra
// Download the appropriate version for your Linux distribution (and architecture, e.g. 64 bit)
wget http://files.zimbra.com/downloads/7.1.3_GA/zcs-7.1.3_GA_3346.UBUNTU10_64.20110928134610.tgz
tar -xvzf zcs-7.1.3_GA_3346.UBUNTU10_64.20110928134610.tgz

5) Install dependencies

apt-get install libperl5.10 sysstat sqlite3

6) Install Zimbra (this takes about 10-15 minutes)

./install.sh

Keep all default settings and proceed with install

When it complains “DNS ERROR – none of the MX records for mail1.example.com resolve to this host” say No to change domain name.

Set password… at menu (make a note of it).

Apply changes.

You can login to the web interface with:

u: [email protected]
p: whatever you set in the install script

http://mail1.example.com/
https://mail1.example.com:7071/zimbraAdmin/

Try sending a test e-mail to [email protected] – you should be able to log in to the web interface and view it.

References:

http://alestic.com/index.html – Ubuntu Image List

http://www.zimbra.com/downloads/os-downloads.html – Zimbra Downloads

http://elijahpaul.co.uk/2011/09/installing-zimbra-7-0-zcs-on-ubuntu-10-04-lts-using-amazon-aws/