BTMash

Blob of contradictions

Installing Jenkins and Fabric on RHEL5

Written

I have recently been asked to help a client with setting up their server environments and to figure out a development workflow so the site can be moved from dev -> staging -> live in some manner. Tired of the way I was doing things myself, I took it as an opportunity to see some of the ways developers were setting up their development workflow. In doing so, I stumbled upon some amazing articles by mig5 on his blog, most particularly about Zero-touch Drupal deployment with Jenkins, Aegir, Git, Fabric, and Drush. I have been getting something similar set up on the servers at my day job (on our dev servers to start) and the difference in working with my colleagues has been very positive (no more logging in for immediate updates, faster changes...less reliant on me being around for them to do their work). And this is all without Aegir even being part of the picture (I have to get my head wrapped around that along with some scripts and will hopefully post on that in the future). Getting back on topic, I needed to install Jenkins and Fabric to get started on the initial work (I'm still debating between Fabric and Capistrano - they both do different things but going to see which better fits the task). Doing this work for the client has been turning out to be a little more challenging that I had expected, however.

I was now out of my element and working with Red Hat Enterprise Linux (or RHEL) servers having being set up by the hosting company. For the past 4 or 5 years, I've primarily worked with the Debian / Ubuntu distribution and was used to things being relatively easy to set up (apt-get X, etc - its surprising just how much is set up right away). So let's get down to it (and what happened):

  1. yum install java

Yay, that installed java 1.6. I don't think Jenkins requires anything more than that. Now I see that Jenkins is not a part of the yum repositories. But the Jenkins wiki has instructions. So let's follow them:

  1. sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
  2. sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
  3. sudo yum install jenkins

Wow, that was...surprisingly easy. The download showed it was on version 1.4.x so I'm feeling good! Let's start this up:

  1. /etc/init.d/jenkins start
  2.  
  3. Starting Jenkins Exception in thread "main" java.lang.reflect.InvocationTargetException
  4. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  5. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  6. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  7. at java.lang.reflect.Method.invoke(Method.java:616)
  8. at Main.main(Main.java:81)
  9. Caused by: java.lang.UnsatisfiedLinkError: /tmp/jna8547980376337168520.tmp: /tmp/jna8547980376337168520.tmp: failed to map segment from shared object: Operation not permitted
  10. at java.lang.ClassLoader$NativeLibrary.load(Native Method)
  11. at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1747)
  12. at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1643)
  13. at java.lang.Runtime.load0(Runtime.java:787)
  14. at java.lang.System.load(System.java:1022)
  15. at com.sun.jna.Native.loadNativeLibraryFromJar(Native.java:746)
  16. at com.sun.jna.Native.loadNativeLibrary(Native.java:680)
  17. at com.sun.jna.Native.<clinit>(Native.java:108)
  18. at com.sun.akuma.CLibrary.<clinit>(CLibrary.java:54)
  19. at com.sun.akuma.JavaVMArguments.resolvePID(JavaVMArguments.java:103)
  20. at com.sun.akuma.JavaVMArguments.ofLinux(JavaVMArguments.java:91)
  21. at com.sun.akuma.JavaVMArguments.of(JavaVMArguments.java:81)
  22. at com.sun.akuma.JavaVMArguments.current(JavaVMArguments.java:69)
  23. at com.sun.akuma.Daemon.daemonize(Daemon.java:77)
  24. at com.sun.akuma.Daemon.all(Daemon.java:59)
  25. ... 5 more

Err... what the heck is that?!? After some cursing and research, I find out through the following command:

  1. grep tmp /etc/fstab

That the /tmp directory (which jenkins uses) has noexec enabled meaning temp files cannot execute in there. Both good and bad - argh. I found one way that I could get around this was via the following (and this might work if you are installing some program and it is just for that purpose):

  1. mount -o remount,exec /tmp
  2. <command>
  3. ...
  4. mount -o remount,noexec /tmp

I found a similar issue and change the JENKINS_JAVA_OPTIONS in /etc/sysconfig/jenkins along with changing the prefix so I can access it at http://url/jenkins:

  1. JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Djava.io.tmpdir=$JENKINS_HOME/tmp"
  2. JENKINS_ARGS="--prefix=/jenkins"

Now I try starting Jenkins - yay, it works!

On to Fabric. By default, the server came with both python2.4 and python2.6 (with 2.4 being the default). And the instructions to install fabric were...obtuse. However, upon some further reading, there were recommendations to install Fabric via PIP. This seems like a better way to approach the whole thing and easy_install actually allows it! After some trial and error, the following:

  1. yum install python26-setuptools python26-devel
  2. easy_install-2.6 pip
  3. pip install pycrypto fabric

This will ensure pip gets set up with utilizing python2.6 and that packages such as fabric will specifically call on that version of Python as well. So far, seems to work quite well :) Now we're up and running with the basics!

Let's install git - bah, it is not a part of the yum repositories. Thankfully, we can use the EPEL project which will take care of all the pieces.

  1. rpm -Uvh http://ftp.osuosl.org/pub/fedora-epel/5/i386/epel-release-5-4.noarch.rpm
  2. yum install git

We're set up with git as well. Now the repository can finally get loaded into Jenkins.