Posted by: terryhowe | June 29, 2017

Automating Jenkins Configuration

What makes automating configuration of Jenkins so hard is there are so many ways to do it.  The easy and mindless way is to configure up a jenkins server and save xml configuration files.  To recreate the configuration you just need to automate the install and copy in the configuration file.  This works great until things start getting complicated like maybe you want to configure a job.  There are a lot of files associated with a single job.

Another approach is to use the Jenkins CLI which is great for some things, but you will quickly find that it is very limited.  There are a lot of things that cannot be configured the CLI.

Yet another approach is to use the web UI to set various configuration values.  This works well for some things, but not everything is available through that interface.

If you start on any of these paths you most likely end up with a combination of all three, but the best answer is to just use the groovy as much as possilble.  You may need to use some of the other approaches, but groovy is by far the comprehensive and it will be easier to support.

I’m going to post up some examples on github for automating Jenkins with groovy using ansible.

Posted by: terryhowe | June 29, 2017

My First Node.js Package

I’ve been trying out a lot of different Node frameworks lately and to get to know the frameworks, I’ve been implementing a text 3D maze for each one.  I tried out React, Meteor, and Express.  Each one of these uses the exact same text rendering logic so I decided to use a node package to share the code across projects.

Which happened to be my first Node.js package.  I’d like to expand the project so that it would be useful as a simple text maze out of the box.  Right now it expects you to create a database of rooms that represent the maze.  Ideally the user would pass a reference to a database and it would be able to render a maze from that.

Posted by: terryhowe | June 29, 2017

Redis Test Drive

I’ve wanted to test drive Redis for a while.  It seems like often when I’m standing up some application it uses Redis, so what is all the hype about.  I went through the tutorial today and wrote a simple application.  Initially I was not terribly impressed since the types of data structures you can store are pretty simple.  There are several different basic data structures that you can use like a list, set, hash,… but each one is pretty much name value.  What I loved about Mongo is you can jam a complex data structure in and get it out and one shot and Redis doesn’t do that.  What is cool about it is the speed for data set and get since it is best used as a replacement for something like memcache.  I also like the idea of simple pub/sub messaging for simple IPC.

Posted by: terryhowe | June 29, 2017

Dependency Injection for Testable Code

One of the easiest ways to make code testable is to use dependency injection.  For example if you need to create an object with some application level configuration you could either have your configuration class as a singleton or pass the configuration into to the class constructor.  If you pass the configuration into the class with dependency injection, it is much easier to test.  Your test code can create various mock configuration classes to test various scenarios.  Sometimes I feel making code testable causes me to make different design decisions, but I think having easily testable code is more valuable.


Posted by: terryhowe | June 10, 2017

Ubuntu 16.04 Headphones Not Working

I get into  a state sometimes where the headphones just ill not register.  I think it is some lock file that prevents the headphones from being detected.  To fix this:

alsactl restore

I think the key thing is to boot the PC with the headset plugged in and first attempt to plug/unplug if they do not work.  If that fails, try the above command.

Posted by: terryhowe | March 20, 2017

Is you is or is you ain’t you my metric?

This is the funniest thing I think I’ve seen in a database table schema:

CREATE TABLE `economic_metric` (
 `active` int(1) NOT NULL,
 `metricid` int(11) NOT NULL AUTO_INCREMENT,
 `is_metric` int(11) NOT NULL DEFAULT '1',


Posted by: terryhowe | March 16, 2017

Creating a Gem Mirror

  1. Install the rubygems-mirror:
    sudo gem install rubygems-mirror
  2. Create a ~/.gem/.mirrorrc file
    to: /var/www/mirror
  3. Run the mirror command
    gem mirror
Posted by: terryhowe | March 16, 2017

Spinning up a Stackato Server in the Cloud PaaS

I’m working today trying to use Stackato to be able to spin up a slave for Jenkins.  Hopefully, Stackato can help me make spinning up these slave servers easier, we will see.  I have a fair amount of software I need to install on the server.  The basic getting started guide can be found here:

What the documentation doesn’t really talk about as far as security groups is what ports you need to open.  To create these rules with the CLI:

hpcloud securitygroups:add stackato Stackato
hpcloud securitygroups:rules:add stackato tcp -p 22..22
hpcloud securitygroups:rules:add stackato tcp -p 80..80
hpcloud securitygroups:rules:add stackato tcp -p 443..443
hpcloud securitygroups:rules:add stackato tcp -p 1..65535 -g stackato
hpcloud securitygroups:rules:add stackato icmp

When you have the ports open, they should look like this:

$ hpcloud securitygroups:rules stackato
 | id    | source    | protocol | from | to    |
 | 32415 | | tcp      | 22   | 22    |
 | 32417 | | tcp      | 80   | 80    |
 | 32419 | | tcp      | 443  | 443   |
 | 37583 | stackato  | tcp      | 1    | 65535 |
 | 44411 | | icmp     | -1   | -1    |

To create the server with the CLI, I ran:

 hpcloud servers:add stackato large -i 1000095768 -k cli_test_key1 -s stackato

Then I got the IP with the following command:

hpcloud servers stackato

I’m not going to set up DNS, so I just put some entries in my /etc/hosts file:

The first thing I did was secure shell into my new server using the CLI:

hpcloud servers:ssh stackato -l stackato

Next I set the server name and rebooted:

kato rename


Posted by: terryhowe | March 16, 2017

Running a basic Django Application with Stackato

I’ve been experimenting with Stackato lately to create a basic Django application and I’ve found the documentation a bit scattered. There is a very basic which I took and kind of combined with the Django quick start instructions. The biggest missing thing is when I deployed the application with stackato push -n it did not connect the database to the application.

The first thing I looked at was the on the Stackato WUI application page there is a link for logs. They didn’t provide a lot of detail. There are better logs in the Files page under logs. Here, the first thing I noticed is that it claimed that DATABASES was not set. I’m not sure why this was since I could see where it was being set in the stackato/ file. What I ended up doing was modifying the to set DATABASES. I’d messed up the when I was merging the getting started application with the Stackato sample application.

The next problem was the static style sheets where not pushed to the application. I was able to update the static information with:

stackato run python collectstatic --noinput

Posted by: terryhowe | March 15, 2017

Python one line web server

Instant web server:

python -m SimpleHTTPServer

« Newer Posts - Older Posts »