2012-03-21

Creating a new GIT repository on Synology

These are the tasks I need to go through to create a new git repository on my Synology server.  I already have the Git server running and a putty client connection setup.

I login to the server using the root user. Go to the directory \volume1\git which was a share I had create earlier.

mkdir newproj

chown me:users newproj

cd newproj

git init –bare

chown –R me:users *

Then logging to new project directory on the development machine and right click and using TortoiseGit leaving the bare option unclicked.  You now have a local repository.  Now push it to the arbitrary URL using the master branch ssh://me@192.168.1.1/volume1/git/newproj

You will then be prompted for the password as the Putty key has not been set up.

2012-03-16

Configuring Django on Vagrant not including chef

In my last post the formatting was going odd so have started again.  My next job is to get Django installed on the UAT rather than a plain Ubuntu box.  You will see at the end I deferred using chef and just got the machine up and running.

I am going to try and follow Simon William’s post. I have a working server.  I also looked at this video. git was not installed on my base machine so I logged in and installed it, made a new directory and got my test software:

sudo apt-get install git
git clone
https://github.com/simeonwillbanks/vagrant-up-django-app-server.git

The syntax of the command in the Vagrant file had changed from

config.vm.forward_port “http”, 80, 8080

to

config.vm.forward_port 80, 8080

Then I needed to install chef which I hadn’t done. So trying the bootstrap knife on my local machine, and having the usual problem about verifying hosts:

C:\Users\me\chef-repo\.chef>knife bootstrap 192.168.1.7 –x me -P mypassword --sudo --no-host-key-verify

It didn’t work.  Unsure why I just installed directly on my base station using the apt-get process which worked fine and I tested it had worked with:

chef-client –-version

However I had forgotten the /etc/chef/validation.pem file which I moved with a fabric script:

def base_key():
    put(r'c:\chef\validation.pem','/home/me/validation.pem')
    run('sudo mv /home/me/validation.pem /etc/chef/validation.pem')




Then chef-client worked (don’t forget the sudo)




sudo chef-client




I had to reedit the Vagrantfile.  Vagrant up now nearly worked.  However I would get the message “The file /etc/chef/validation.pem does not contain a correctly formatted private key.”  It looked fine but I must have edited it with notepad as it had CR (Ctrl-M) at the end of each line.



Now it booted ok but it complained that it had already been registered (which it had in the last debug cycle).  At the end of the cycle I just destroyed the machine leaving the node registered on the chef server.  I need to bring the machine offline gracefully.



This command is still failing:




chef-client -c /etc/chef/client.rb -j /etc/chef/dna.json




One of my problems mois that I am building Ubuntu lucid boxes which have chef 0.09 and I am running it from a base build of Ubuntu Oneiric 11.10 with chef 0.10.  So I am going to use veewee to make a new base box.  I install veewee:




sudo gem install veewee




It didn’t go well veewee installation didn’t complete and it corrupted some gemspec files that I had to hand edit to fix.  I rebooted and my test vagrant box is working again.  I learnt one useful thing in that the Vagrantfile directory (on my base machine ~/uatbox32) is mounted as /vagrant in the vagrant virtual machine.



I mounted the VBoxGuestAdditions.iso in the client box and that eliminated one problem.  I still need to work on the chef upgrade from 0.09 to 0.10 which I did on the virtual box with:




sudo gem install chef




I hadn’t realised that chef had both clients and nodes and I needed to delete both from the chef server page after a vagrant up.  On a reboot the guest additions reverted – I should have done halt rather than destroy.  Luckily I had packaged the build so can use that as a base.



I am going back to Fabric for deployment.  A  historical chanes that might catch you out (it caught me out).  In 0.9 and later versions of fabric (I am using 1.4) Fabric uses the ‘env’ environment dictionary which used to be called config.  So any examples with config.x = are no obsolete.



I have found some nice guidance on django best practices:



http://lincolnloop.com/django-best-practices/projects.html



After a lot of mucking about I now have a working site.  The next stage is to simplify and to roll out for the dev,test,uat and prod environments.



dev is on my development machine and might do anything.



test is on production type hardware and is for testing.



uat is on production type harward and a recent backup of the production database for final acceptance.



prod is then the delivered product.

Long post now shorter

I had a long post about the tribulations of installing Ubuntu on a local server and then getting virtual box.  However a combination of Windows update and Windows live writer managed to edit it down to nothing so I am starting again.

Installing the OS, OpenSSH, virtual box and Vagrant

I used Ubuntu 32 bit 11.10 (as I needed RubyGems >= 1.3.6) to install virtual box and vagrant.  I should have selected OpenSSH as a default package (I selected nothing) so had to install that later:

sudo apt-get install openssh-server openssh-client

In order to login with out a username and password I wanted to used the SSH public key.  I modified the network interfaces to change the IP adresss and after a reboot changed the SSH control file to read the atuhorisation file.  Then added the authorisation key to the public key from that generated by Putty.  Note you have to edit the framework and end of lines, see here.

Another lifesaver which slowed me down all afternoon:

--disable-known-hosts stops Fabric from getting confused when you generate the same VM repeatedly”

Vagrant up for the first time

The aim here is to get the first box so that I can power it up and down – then aim to make that happen using fabric.  I thought I might have to this several times so firstly I decided to download the box to my local webserver from opscode and then install from there.

 vagrant box add lucid32 http://files.mysite.net/ubuntu10.04-gems.box

That turned out to be a good plan as the update then only took a few seconds. Then to start the machine and vagrant up:

mkdir devbox32
cd devbox32
vagrant init lucid32
vagrant up



The machine paused and after some messages I had a new machine in about 2min.



I can login to it either using putty from my machine or:




vagrant ssh




vagrant ssh from the host machine.  The username and password were vagrant.  Then I shut it down with:




vagrant halt

vagrant destroy -f




You don’t need the halt but it is a bit cleaner.  Next time you start up you don’t need to download the box.  The vagrant up command is now in fabric.  The complete code is in the appendix 1, here is the guts of it and the command lines:




def uat_up():

run('cd uatbox32 && vagrant up')




and the command line on my windows development box is :




fab --disable-known-hosts base uat_up




and I can login with Putty.



Appendix 1 Initial fabric file to do vagrant up remotely


Complete fabfile.py to get you started you will need to edit the me to your user:




import os.path

import subprocess



from  fabric.api import *

from fabric.contrib.console import confirm



# Constants

KEY_DIR = r'C:\Users\me\Library\keys'


PUTTY_DIR = r'C:\Program Files (x86)\PuTTY'



# These private python functions do not get exposed on the command line via the

# 'fab' tool. They will not show up when the user runs 'fab --list'


def _start_pageant_and_store_key(keyfile_name):


    """


    Starts the Pageant key agent, and loads the private key in to it, prompting


    for the passphrase if needed. Also sets the Fabric env.keyfile_name


    property.


    """


    keyfile_path = os.path.join(KEY_DIR, keyfile_name)



    # Start pageant. Note that this works with the PuTTY key format (*.ppk), not

    # the OpenSSH format.


    path_to_pageant = os.path.join(PUTTY_DIR, 'pageant.exe')


    result = subprocess.call([path_to_pageant, keyfile_path])


    if result > 0:


        raise OSError, "Bad result %s" % result



    # Store the path to the key file in fabric's global env dictionary

    env.key_filename = keyfile_path



def base():

    """


    Set up for connection to the base server for provisioning of


    """


    # Once DNS is set up for these hosts, I can use hostname instead of ip address


    env.user = 'me'


    env.hosts = ['me@10.0.0.7']


    _start_pageant_and_store_key('UAT_PrivateKey2.ppk')



def uat_up():

    run('cd uatbox32 && vagrant up')



def uat_destroy():

    run('cd uatbox32 && vagrant destroy -f')

2012-03-08

Installing chef on a TurnkeyLinux instance

I thought this would be easier than it turned out to be.  I needed to do a number of things :

  • install sudo eg  

apt-get install sudo

  • copied all the infstall files from my orignal instalataion eg knife.rb, Mame.pem, myOrg_validator.pem to /etc/chef
  • make sure directory is mapped

cd ~ | ln –s /etc/chef ./.chef

Then my command knife note create django00

knife node create django00

I started using the hosted chef model and after this I had a single node. Exciting stuff.  It would be nice project to get the bootstrap code to work for the TurnkeyLinux instance.

2012-03-06

Installing Dia python plug in on Windows 7 x64

I tried to run the intro tutorial for Dia but it didn’t work.  Assuming that this might be something do with the different directory structure I  tried putting my code here

C:\Program Files (x86)\Dia

which is not very nice but does work.

2012-03-02

SVN creating a new repository

Since I am now running my own SVN server there is only a slight cost in time to creating a new repository.  The top level directory in an SVN server is the repository and has to be created on the server rather than creating lower level directories which can be done by Tortoise SVN.  Getting round running at the adminstrator level is handy about svnSync and also about the SVN hosting services such as Codesion  and SlikSVN.

So on synology SVN host I logged in as root, there may be better ways of doing this but this worked for me.  Created my new site:

svnadmin create /volume1/svn/new_repository

This now inherits the wrong file permissions (root) so the directory listing looks like this:

image

so I moved to the directory and changed the owner and group:

cd /volume1/svn/new_repository
chown –R svnowner:users .

(don’t forget the trailing dot) and now it looks like this:

image

Next you need to add your username and password to the configuration file new_repository/conf/passwd (I am using vi for the editor) eg

image

Then in the same directory you need to change the following entries for the configuration file (svnserve.conf)

Make anonymous access have no access and authorised access write access:

image

Turn on using the local password database:

image

I also changed the realm to my URL but that is optional.

Now you can import your new directory using the method I talked about a while back.

2012-03-01

Configuring VOIP phone and PBX passwords

I have been using the voipfone service as a virtual PBX.  It is so far working well although I had not been using any of the VOIP features just the call diversion service.  I tried out RingCentral but didn’t like the fact that my calls appeared to come from the US.  I like the fact that you can easily apply the recording of calls to meet compliance.

I had a problem configuring my VOIP SPA941 phone yesterday as I had not realised that my voipfone account has a master password but each extension has its own password.  When setting the password you need to give the extension password.  Everything now works fine.