Auto assign owner in RT – version 2

Here only the clean up code is little different to make the owner list
generated externally and feed it back to the array and also sanitize the
user list. Also some silly static debug option and static disable option

# if you want to disable it, just uncomment the following line
# return 1;

# get out if ticket has a owner
return 1 unless $self->TicketObj->Owner == $RT::Nobody->id;

# get the user list from the file
# this file has the list of users who will be assigned as owner in round-robin
# you could have another logic external that could update this file to get the
# generate the list of owners
my $file = “/var/tmp/ownerlist”;

return 1 unless open(my $fh, ‘<‘, $file);
my @owners = <$fh>;
return 1 unless close $fh;

# sanitizing the entries – accounts should be all alphanumerics
foreach my $line (@owners) {
$line =~ tr/A-Za-z0-9//cd;
# get a count for the owners
my $totmembers = scalar( @owners );

# get this ticket id
my $ticket_id = $self->TicketObj->id;

# ticket_id modulo totmembers to pick the next owner
my $x = $ticket_id % $totmembers;
my $owner = $owners[$x];

## Some debug option when uncommented
## $RT::Logger->info(“AUTOASSIGN: DEBUG “. $self->TicketObj->id .” to user “. $owner );
## $RT::Logger->info(“AUTOASSIGN: DEBUG Total number of owners “. scalar(@owners) );
## uncomment this if you want to run in dry run mode
## return 1;

# set the owner
$RT::Logger->info(“AUTOASSIGN: “. $self->TicketObj->id .” to user “. $owner );

my ($status, $msg) = $self->TicketObj->SetOwner( $owner );
unless( $status ) {
$RT::Logger->error( “Impossible to assign the ticket to $owner: $msg” );
return undef;

return 1;

Posted in solaris | Leave a comment

Auto assign owner in RT

Description: Auto assign ticket on create
Condition: On Create
Action: User Defined
Template: Global template: Blank
Stage: TransactionCreate

Custom condition: return 1;
Custom action preparation code: return 1;
Custom action cleanup code:
# get out if ticket has a owner
return 1 unless $self->TicketObj->Owner == $RT::Nobody->id;

# gather the list of owners
my @owners = qw(

push(@owners, @owners);

# get a count for the owners
my $totmembers = scalar( @owners );

# get this ticket id
my $ticket_id = $self->TicketObj->id;

# ticket_id modulo totmembers to pick the next owner
my $x = $ticket_id % $totmembers;
my $owner = $owners[$x];

# set the owner
$RT::Logger->info(“Auto assign ticket “. $self->TicketObj->id .” to user “. $owner );
my ($status, $msg) = $self->TicketObj->SetOwner( $owner );
unless( $status ) {
$RT::Logger->error( “Impossible to assign the ticket to $owner: $msg” );
return undef;
return 1;


Posted in solaris | Leave a comment

Push your SSH key to all the ESXi servers

First collect the list of ESXi servers using ezmomi

ezmomi list –type HostSystem | awk ‘/^host/ {print $2}’ > /tmp/esxis

Now push the ssh key to all the ESXi systems under root using a while loop

while read -r host
echo $host
cat .ssh/ | sshpass -p ‘p@ssw0rd’ ssh -q -oStrictHostKeyChecking=no $host “cat – >> /etc/ssh/keys-root/authorized_keys”
done < /tmp/esxis

root password for esxi servers

I picked a while loop since ansible cannot push it as esxis is missing python grp module. It fails at import grp with ImportError: No module named grp.

Posted in solaris | Leave a comment

Push your SSH Key to Tons of Systems

If you want to push your ssh key on multiple systems or one system you can use ansible to make the push. I am assuming your sshd_config on remote server has PubkeyAuthentication set to yes. It is a requirement for ssh key based authentication to work. You could use a Match block in sshd_config and allow a group to login with ssh key.

For single server:

ansible myhost -i inventory –ask-pass -m authorized_key -a ” user=<username> key=’$(cat ~/.ssh/’ “

For multiple servers:

ansible myhostgroup -i inventory –ask-pass -m authorized_key -a ” user=<username> key=’$(cat ~/.ssh/’ “

Inventory file:

cat inventory

<username> is just a placeholder for most likely your username assuming you have an account on remote system.

This is an idempotent operation. So it will not append the key multiple times even if you
run this multiple times

Checkout more details on the ansible module authorized_key

Posted in solaris | Leave a comment

2012 in review

The stats helper monkeys prepared a 2012 annual report for this blog.

Here’s an excerpt:

600 people reached the top of Mt. Everest in 2012. This blog got about 2,500 views in 2012. If every person who reached the top of Mt. Everest viewed this blog, it would have taken 4 years to get that many views.

Click here to see the complete report.

Posted in solaris | Leave a comment

Run devmon using upstart script

$ cat /etc/init/devmon.conf
description “DEVMON Hobbit SNMP tool upstart script”
author “Asif Iqbal”

start on runlevel [23]
stop on runlevel [!23]

exec su devmon -c “/usr/local/devmon/devmon -f”


Posted in solaris | Tagged | 1 Comment

Install Ubuntu on X2100 over the network using PXE

Pick a server that will host the netboot image, run dhcp and tftp server. Lets call it sys-ubuntu.

– login to sys-ubuntu

– install dhcp server
sudo apt-get install dhcp3-server

– edit the /etc/dhcp3/dhcpd.conf like this

sudo vi /etc/dhcp3/dhcpd.conf
ddns-update-style none;
option domain-name “”; # pick the right domain
option domain-name-servers,; # pick the correct dns resolvers. you may try opendns IPs
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet netmask { # pick your network
option domain-name-servers,;
option routers; # pick the correct gateway
range; # pick a range of IP that are not in use and on same network as sys-ubuntu
next-server; # this is the IP of sys-ubuntu. YMMV
filename “/var/lib/tftpboot/pxelinux.0”; # for some reason tftp was complaining if absolute pathname is given

– start the dhcp server
sudo /etc/init.d/dhcp3-server start

– install tftpd server
sudo apt-get install tftpd-hpa

– update the tftpd-hpa default tftp directory

sudo vi /etc/default/tftpd-hpa

– restart tftpd-hpa

stop tftpd-hpa
start tftpd-hpa

– get the latest 64bit netboot image and dump it into the tftp’s root dir

  sudo cd /var/lib/tftpboot
         current/images/netboot/netboot.tar.gz (one line)
  sudo tar -xzvf netboot.tar.gz

– edit pxelinux.cfg/default and ubuntu-installer/amd64/boot-screens/text.cfg to enable the serial console to work

sudo vi pxelinux.cfg/default and add serial 0 and modify prompt and timeout so it looks something like below

serial 0
include ubuntu-installer/amd64/boot-screens/menu.cfg
default ubuntu-installer/amd64/boot-screens/vesamenu.c32
prompt 1
timeout 300

sudo vi ubuntu-installer/amd64/boot-screens/text.cfg
replace default install with default cli, append console=ttyS0,9600n8 and remove quiet at the end of the second append.. line like below stanza

default cli
label install
menu label ^Install
menu default
kernel ubuntu-installer/amd64/linux
append vga=normal initrd=ubuntu-installer/amd64/initrd.gz — quiet
label cli
menu label ^Command-line install
kernel ubuntu-installer/amd64/linux
append tasks=standard pkgsel/language-pack-patterns= pkgsel/install-language-support=false vga=normal initrd=ubuntu-installer/amd64/initrd.gz — console=ttyS0,9600n8

– disable UFW for few mins for the PXE talk
(better would be adding some fw rules)
ufw disable

– look at this X2100.png for key maps

– connect your laptop to your X2100’s serial (rs232) interface, start minicom (or hyperterminal) and power it on

– direct it to boot thru PXE using ESC+8

– if the client screen is blank at any point, just hit enter.

– once installation completes enable the fw and disable the dhcp and tftpd server

ufw enable
sudo /etc/init.d/dhcp3-server stop
stop tftpd-hpa

Posted in ubuntu | Leave a comment