My linux projects

I have never been a Linux developer although I started with BASIC programming language on Commodore 64 when I was about 6 years old. When I was 13 I was given my first PC, Pentium at 100Mhz which was really fast beast by that time. I met with Pascal programming language a bit later at high school. Then I was trying to improve my programming skills by coding some kind of simple mostly text based games, encryption programs or PC speaker music editors ;)

When I switched to Linux I abandoned all these programming skills and tented to explore this amazing OS more deeply. I started to learn C programming language by the way and did find the best way to learn is to develop some real project. Thus was me and couple of school mates working on SDL based game “Free Tunneler” which was also unfortunately abandoned after while due to lack of time. After short period as PHP coding, I somehow transformed into Linux administrator as I was working on bunch of smaller projects or later webhostings. As full-time working Linux admin I have never had any programming ambitions.

Few years ago I bought Kiss DVD player that is also capable streaming music and video from a PC. By that time I didn’t success by finding any suitable Linux streaming server for this piece of device and therefore I decided to brush up my programming skills by trying to develop simple Linux server for Kiss DP-600 device. I am not a programmer by any chance but I did make work what I wanted and publish it under GPL at freshmeat. Just few changes were made since very first release including large file support and some minor bugfixes as few people reported these problems in Linux Kiss Server forum. I never thought of how many people could be using LKS (Linux Kiss Server) primarily developed for my personal use. When I found few (1,2,3) security related websites publishing a security issue regarding format string vulnerability in my Linux Kiss Server program, just few days ago, it just blew me away.

I really like the fact it was worth for someone investigate the source code and publishing this problem. I see my weak programming skills and development effort weren’t useless as some other people might be using this little piece of work as well as I do. Viva opensource ! ;)

Choosing an open source configuration management software - Part 2

Ok, we were talking about Puppet vs Cfengine. Both are open source configuration management software.
Cfengine is much older and I think still has more users as it’s been well known for some time. This article is ment to be little presentation of Puppet which I have chose as cfengine replacement in our company network.
To be honest, I am using puppet just for about one month but I dare to claim I am pretty familiar with it and able to manage the same range of server configuration as I did (and saw) with cfengine.

Let’s look at few things that are being made differently with Puppet. Stupid thing about cfengine was that each managed server downloaded all files placed in /var/cfengine/conf where were placed all files for all servers what led to total mess everywhere. Puppet has solved this boring thing by implementing something what is called File Server. It’s intended to run File Server on puppet server besides managed servers fetch all needed files from there. The default location for the file service is /etc/puppet/fileserver.conf and is configured very easily in few seconds and could seem for example like this:

[export1]
path /export
allow 127.0.0.1
allow 192.168.0.*

[export2]
path /export2
allow 127.0.0.1
allow 192.168.1.*

This simple example defines two file server repositories each accessible from different IP range. Such repository can then be very easily set as a source of configuration files for managed servers in /etc/puppet/manifests/site.pp which is main configuration file ( something like cfagent.conf in Cfengine ):

file { “/etc/resolv.conf”:
source => “puppet://puppetserver.mydomain.com/export2/new_resolv.conf”,
owner => root, group => root,
}

Please note, that this example won’t work as it is, since we didn’t define for what nodes this action should be run.
Another thing where I saw difference between cfengine and Puppet at first sight was grouping things together ( what actions are run on what servers ). Ok, speaking in terms of Cengine those are groups:

groups:
srv_group1 = ( 10.0.0.1 10.0.0.2 10.0.0.3 )

copy:

srv_group1::
$(master_input_dir)/conf/new_resolv.conf dest=/etc/resolv.conf
mode=0644
owner=root
group=root

In Puppet, similar action would be defined in following way:

node “10.0.0.1″, “10.0.0.2″, “10.0.0.3″ {
include common
}

class common {

file { “/etc/resolv.conf”:
source => “puppet://puppetserver.mydomain.com/export2/new_resolv.conf”,
owner => root, group => root,
mode => 0644
}
}

This example instructs Puppet to fetch file new_resolv.conf from Puppet repository called export2 running on File Server puppetserver.mydomain.com. As you see configuration of File Server as well as using it as source for copying files to managed server(s) is very easy.

Ok, we understand File Server and now we saw what must be done to manage our servers. See, that idea of Puppet in contrast to Cfengine is to group different actions into classes and then call those classes ( see “include common” in our example ) for specific groups of managed servers rather then define groups of servers and then specify what is done for every single group in each action section (copy,packages,links etc..)

Another interesting thing about Puppet is templating support. Stupid example:

content of /etc/puppet/manifests/site.pp

node ‘10.0.0.1′ {
include test
}

class test {

$name = $fqdn
$ip = $ipaddress

file { “/tmp/test”:
owner => root, group => root,
mode => 440,
ensure => “present”,
content => template(”/var/lib/puppet/templates/test.erb”)
}

}

content of /var/lib/puppet/templates/test.erb:

Servername <%= server %>
Ipaddress <%= ip %>”

Note that variables like $fqdn or $ipaddress are replaced with appropriate values of each node where template is applied. You can run facter command to see these values. Another interesting thing is that template values are filled in on Puppet server and afterwards sent to nodes.

This is just demonstration how templating works. I hope you won’t struggle as I did when I was trying to try templating for first time as this area is not very well documented on Puppet site.

If you are somehow experienced with Cfengine you remember that you had to define action sequence ( e.g: actionsequence = copy packages editfiles shellcomands ). I’ve seen this caused many problems when something wasn’t copied (copy) at time when for example shellcommand requested this file and changing action sequence caused later some more hidden problems. I just want to say that Puppet hasn’t anything such stupid as action sequence and all relations between actions can be solved separately:

node ‘10.0.0.1′ {
include test
}

class test {

file { “/etc/httpd/conf/httpd”:
owner => root, group => root,
mode => “600″,
source => “puppet://puppetserver.mydomain.com/export2/httpd.conf”,
require => package[”httpd”]
}

package { “httpd” :
ensure => installed
}
}

This example demonstrates how easy is to setup relations between specific actions. Before we copy httpd.conf file from Puppet server we want Puppet to check whether httpd package is installed. Puppet will automatically find suitable packaging software and install such package if not present.

Puppet service management is also worth mentioning.

node “10.0.0.1″, “10.0.0.2″, “10.0.0.3″ {
include common
}

class common {

package { “httpd” :
ensure => installed
}

service { httpd:
name => “httpd”,
ensure => running,
hasrestart => true,
enable => true,
require => [ package[”httpd”] ]

}
}

By this simple example we make sure that httpd package is installed, is running ( ensure => running ) and is started on boot ( enable => true ). Puppet will find suitable tool to make this service start on boot ( e.g: chkconfig for SLES)

I think I have covered all interesting Puppet’s features including templating, action sequence replacement, file server instead of copying everything on all nodes. Feel free to send your comments. If you mean it with Puppet seriously you can start reading Installation Guide and Puppet Introduction

Choosing an open source configuration management software - Part 1

I started to work for a new company as IT Administrator one month ago. Since there is a lot of hard work to do, all concerning network changes and network services I of course started to look around a bit for couple of mostly open source tools that could come in handy during network administration.

Yes, I am talking about configuration management software like Cfengine which is apparently the most known one as it is being used by IT Administrator since 1993.

I was also using Cfengine for about 3 year in SuSE and then in another job where Cfengine helped us administrators keep deploying most recent configuration files to all of those more than hundred servers. But everything has its pros and cons.

What are they ? Well, I’ve seen Cfengine being in trouble many times. For example it might be beyond its limitation to want it install a lot of RPM packages at once. In this case Cfengine certainly led to segfault after installing first few packages from the list. Once all packages having installed and just few of them were changed or added Cfengine coped well with it without harm.

I’ve also seen Cfengine being in trouble many times when it somehow started more than once over itself and thus was kind of locked along with RPM database which couldn’t be used anymore by anything else. The problem used to be caused again by performing lot of changes at once when it semi-died and other Cfengine process was run over it (although it shouldn’t as it has lock files)

Cfengine wasn’t a bad configuration management software at all but every IT administrator who fully used its features must have hit its weak spot after while.

When I was thinking about future plans concerning configuration management software I didn’t even know there are more powerful tools like Cfengine. I stumbled upon this website with configuration management software. After reading few articles by googling “cfengine vs others” and such I found Puppet as Cfengine’s big competitor and I decided to give it a try.

Compared to Cfengine, Puppet is pretty young project with its first release in 2005. Only thing which some administrators might not be familiar with is a need to install Ruby in what whole Puppet is written. That’s all what’s needed to run Puppet.

To be continued…