Thursday, January 19, 2012

Getting started with Puppet on CentOS 6

This is a how to for setting up Puppet on machines running CentOS 6. Instructions were tested on CentOS 6.2 machines.

Introduction

Instructions below assume you have two machines named master.example.com which will be the Puppet master and client.example.com which will be the Puppet client.
Puppet requires machines to have full qualified domain names (FQDN). Also, the clocks on machines must be in sync. Enable NTP daemon on both machines to sync the machine clock to NTP servers.
# service ntpd start

Prerequisites

Puppet requires "ruby" and "ruby-lib" packages installed.
To view puppet command-line help, you need "ruby-rdoc" package installed.
# yum ruby ruby-lib ruby-rdoc
Puppet is not available in CentOS "base" repository. PuppetLabs provides a Yum repository for puppet. You can install a RPM provided by PuppetLabs to configure the Yum repository.
# wget -c http://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-1.noarch.rpm
# yum install puppetlabs-release-6-1.noarch.rpm

Puppet Server

Install Puppet server package on master.example.com
[root@master ~]# yum install puppet-server
Start the Puppet master daemon.
[root@master ~]# service puppetmaster start

Puppet and SSL

Puppet clients uses HTTPS to communicate with the server. In order to communicate with the server Puppet clients require valid SSL certificate. Puppet master daemon acts as CA (certificate authority) for SSL certificates.
During the first run of the puppet client it generates a SSL certificate and sends to puppet master.
[root@client ~]# puppet agent --no-daemonize --onetime --verbose --debug --server=master.example.com
Before the client can successfully connect to the master, master has to sign the client certificate.
[root@master ~]# puppet cert list --all
[root@master ~]# puppet cert --sign client.example.com

Puppet Client

Install Puppet client package on client.example.com
[root@client ~]# yum install puppet
Test Puppet client from the command-line. We will assume that the master has valid signed certificate for client.example.com.
[root@client ~]# puppet agent --help
[root@client ~]# puppet agent --no-daemonize --onetime --verbose --debug --server=master.example.com
See the "puppet agent --help" to understand the command line flags.

In the next post, we will see how to setup a "helloworld" example for Puppet.

Monday, October 10, 2011

Location of userContent.css in Linux and Windows 7

Windows 7

C:\Users\{username}\AppData\Roaming\Mozilla\Firefox\Profiles\{profile-directory}\chrome
E.g.
C:\Users\arun\AppData\Roaming\Mozilla\Firefox\Profiles\4s7v2bl8.default\chrome

Linux

/home/{username}/.mozilla/firefox/{profile-directory}/chrome
E.g.
/home/arun/.mozilla/firefox/4s7v2bl8.default/chrome

Sunday, October 9, 2011

View Gmail conversations in fixed width font using Firefox

Add the following lines to "$HOME/.mozilla/firefox/{profile-directory}/chrome/userContent.css" to view Gmail emails in fixed width font using Firefox.
@-moz-document domain(mail.google.com)
{
    /* GMail messages and textarea should use fixed-width font */
    .gs .ii, textarea.Ak {
        font-family: MonoSpace !important;
        font-size: 10pt !important;
    }
}
That's it. Enjoy.
Edit: 13 Feb 2016 (Originally published on 09 Oct 2011)
This still works on Firefox 44 on Fedora 23. The "chrome" directory was missing in profiles directory. Just create the directory and put "userContent.css" file inside it.

Friday, November 5, 2010

Google Yum repository configuration on Fedora

To install and update Google programs like Chrome and Picasa using Yum, create a new configuration file named "google.repo" under /etc/yum.repos.d/. The contents of "google.repo" would like below.

[google]
name=Google - i386
baseurl=http://dl.google.com/linux/rpm/stable/i386
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

With this setup in place, you should be able to install Google Chrome using the following command.

# yum install google-chrome-unstable
or
# yum install google-chrome-stable

For more information, refer to [1].
1. http://www.google.com/linuxrepositories/yum.html

Monday, July 13, 2009

Accessing Microsoft Exchange with Evolution on Fedora

Install Evolution if it not already installed. To make Evolution work with Microsoft Exchange you will need to install "evolution-exchange" package.

$ yum install evolution-exchange

Launch Evolution.
Go to Edit->Preferences->Mail Accounts
To create a new account choose "Add"
"Mail Configuration" window click "Forward"
"Identity" enter your name and email address
"Receiving Email": Choose Server Type: Microsoft Exchange
User Name: domain/username
OWA URL: https://webmail.example.com/exchange/ Click Authenticate. Click Forward.
"Receiving Options": The defaults are fine. If you want to customize them you can do so later. Click Forward
"Account Management": The defaults are fine. If not, choose a name. Click Forward
In the next screen, once you click "Apply" your account will be setup.

Wednesday, July 1, 2009

Fedora 11 yum plugins

Two yum plugins which are not installed by default, but which very useful are "fastestmirror" and "presto".

$ yum install yum-plugin-fastestmirror
$ yum install yum-presto

As the name indicates, the "fastermirror" plugin finds the fastest mirror to download the packages. Combined with the "presto" plugin which only downloads delta rpms instead of the full rpms it significantly speeds up yum updates.

Friday, June 26, 2009

History and page up/down keys in Fedora

In Fedora, the page-up and page-down keys are mapped to beginning of history and end of history which I don't find very useful. These entries are in "/etc/inputrc".

"\e[5~": beginning-of-history
"\e[6~": end-of-history

I prefer to have them mapped to search history forwards and backwards. It allows me to type the beginning of the command and hit page up/down and bash will auto complete the command by recalling the command from history. Here is relevant parts of "/etc/inputrc" which achieves this effect.

"\e[5~": history-search-backward
"\e[6~": history-search-forward

Thursday, June 25, 2009

Enable bash-completion in Fedora

Here are the steps to enable bash-completion in Fedora.
Fedora does not install bash-completion by default. So, first install it.

$ sudo yum install bash-completion

Put the following lines in your ".bashrc" file.

#Bash completion
[ -f /etc/bash_completion ] && source /etc/bash_completion

Turning off annoying beeping in gvim

In order to turn off the annoying beeping in gvim put the following in your ".gvimrc".

" Turn off the annoying beeping and flashing
set visualbell t_vb=

This enables the "visualbell" which flashes instead of beeping.The "t_vb=" turns of the flashing also.

Wednesday, June 24, 2009

Exclude/blacklist a mirror from yum

I have installed the fastestmirror plugin for yum. The mirror that yum finds using this plugin is sometimes unavailable. Fastestmirror plugin allows you exclude/blacklist one or more mirrors.

Add the following line to "/etc/yum/pluginconf.d"

exclude=mirror.example.com

Sunday, June 21, 2009

Splitting a file name into name and extension using bash

I was writing a bash script and wanted to split a file name into its constituent name and extension parts. Here is how I did it.

#!/bin/bash

INPUT_FILE=$1
FILE_NAME=${INPUT_FILE%.*}
FILE_EXT=${INPUT_FILE##*.}

echo $FILE_NAME
echo $FILE_EXT

A good reference for bash script is Advanced Bash Scripting Guide. I referred to the string manipulation section to create the above snippet.

Configuring network profiles in Gentoo

I use my laptop at home and at work. At home, network is configured as static IP address and at work it is using DHCP. So, I needed solution to switch between the two easily. Here is what I came up with.
The contents of my "/etc/conf.d/net" is shown below.

modules_eth0=( "dhclient" )

config_work=( "dhcp" )

config_home="192.168.1.254 netmask 255.255.255.0 brd 192.168.0.255"
routes_home="default via 192.168.1.1"
dns_servers_home="127.0.0.1 192.168.1.1"

cmdline_opt() {
if [ $# -ne 1 ] || ! [ -r /proc/cmdline ]; then
return 1
fi

for opt in $(cat /proc/cmdline) ; do
[ "${opt}" = "${1}" ] && return 0
done

return 1
}

preup() {
if [ "${IFACE}" = "eth0" ] ; then
if cmdline_opt location=home ; then
einfo "Setting network profile: home"
_configure_variables "home"
elif cmdline_opt location=work ; then
einfo "Setting network profile: work"
_configure_variables "work"
else
return 1
fi
fi

# Remember to return 0 on success
return 0
}

I pass "location" as kernel parameter when I boot the machine. So, I added it to the kernel boot line in "grub.conf". I choose the appropriate kernel to boot from the grub menu depending on whether I am at home or work. The relevant portions of my "grub.conf" is shown below.

title Gentoo Vanilla Sources (2.6.28-ab1) (Home)
root (hd0,4)
kernel /boot/kernel-genkernel-x86-2.6.28-ab1 ro real_root=/dev/sda5 location=home

title Gentoo Vanilla Sources (2.6.28-ab1) (Work)
root (hd0,4)
kernel /boot/kernel-genkernel-x86-2.6.28-ab1 ro real_root=/dev/sda5 location=work


If there are any easier/cleaner solutions I would like to hear about them.

Syntax Highlighting in Blogger

I am using Alex Gorbatchev's excellent Syntax Highlighter scripts.

To enable syntax highlighting in your blog posts, add the following code snippet in the HTML head section of your template.

<link href='http://alexgorbatchev.com/pub/sh/2.0.320/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/2.0.320/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shCore.js"></script>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shLegacy.js'/>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushBash.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushCpp.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushCSharp.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushCss.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushDelphi.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushDiff.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushGroovy.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushJava.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushJScript.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushPhp.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushPlain.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushPython.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushRuby.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushPerl.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushScala.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushSql.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushVb.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushXml.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushAS3.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushJavaFX.js"></script>
<script language='javascript' src="http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushPowerShell.js"></script>
<script language='javascript'>
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = "http://alexgorbatchev.com/pub/sh/2.0.320/scripts/clipboard.swf";
SyntaxHighlighter.all();
dp.SyntaxHighlighter.HighlightAll('code');
</script>

To illustrate the use of SyntaxHighlighter, lets use a simple "helloworld" C program. You can enclose code snippets in your posting using the <pre> tag as shown below.

<pre class="brush: c">
#include <stdio.h>

int main() {
printf("Hello World!\n");
exit(0);
}
</pre>

If you want to post Python code instead, change the "brush" to "python" as shown below.

<pre class="brush: python">
#!/usr/bin/env python
print "Hello World"
</pre>

You can find the full list of supported languages ("brushes") here.

If you have a place to host the SyntaxHighlighter files then you can test and push out new versions when they become available. Also, if you want to modify the code this is an easier option. That is what I have done. So, my template configuration looks as shown below.

<link href='http://arunbhanu.com/sh/Styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://arunbhanu.com/sh/Styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script language='javascript' src='http://arunbhanu.com/sh/Scripts/shCore.js'></script>
.
.
.

Saturday, June 20, 2009

Setting Git Author and Email

To set git author and email fields globally use the following commands:
 
$ git config --global user.name 'Foo Bar'
$ git config --global user.email 'foo@bar.com'

These commands will add the entries to "user" section of "${HOME}/.gitconfig".

Gentoo "net.example"

On a Gentoo Linux system, a simple help file with examples on how to configure the network settings were previously located in "/etc/conf.d/". I was trying to find this file today and was unable to locate it.

Now, you can find the same file under "/usr/share/doc/openrc/net.example" instead.

Friday, June 19, 2009

Locking KDE session

In KDE 3.5 and KDE 4.2, Ctrl+Alt+l (ie. small letter L) shortcut key is the default mapping for locking your KDE session.

Monday, June 1, 2009

Recursive dos2unix

To recursively convert a directory containing files with DOS newlines to UNIX newlines use the following command:

$ find . -type f -exec dos2unix {} \;