Wednesday, June 03, 2015

Testing your Syslogd Remote config

Test, test, test; right?

So you've configured syslogd or, increasingly, rsyslogd .  How do you trivially test?

It's really simple.
  1. make sure nc or ncat (netcat) are installed.  It's a common tool, but maybe you don't have it on this host.  It's with nmap on my EL6 host, but a standalone on EH5.  Because EL7 has to reinvent everything, nc is in mnap-ncat.  So here's your install:

    yum install {/usr,}/bin/{nc,ncat}

    Honestly, that's the easiest way.
  2. Launch tshark on the log forwarder:

    # tshark -plni any udp and port 514
  3. Now hit it.  Here's your nc invocation:

    # ncat -u loghost 514 <<< "test logger receipt"
  4. And here's how it looks:
    # tshark -plni any udp and port 514
    Running as user "root" and group "root". This could be dangerous.
    Capturing on Pseudo-device that captures on all interfaces
      0.000000 192.168.112.6 -> 192.168.10.251 Syslog 64 test logger receipt\n
      0.000301 192.168.10.251 -> 192.168.16.133 Syslog 83 USER.NOTICE: Jun  3 22:25:07 test logger receipt
      0.000389 192.168.10.251 -> 192.168.10.250 Syslog 83 USER.NOTICE: Jun  3 22:25:07 test logger receipt
    ^C
    
Fun fun?

Hey, look!  Our logger box is happily forwarding stuff out, too.  Double-win!


Labels: , , , ,

Sunday, July 01, 2012

Updating Cobbler on RHEL5 to Import ESXi5 for PXE Install

So you want to play with ESXi5, but on RHEL5, today, the latest version of cobbler (2.2.1?) doesn't yet support it.  Cobbler 2.2.3 does, though, but it's not available at all yet.  Nooooooo.

Here's what you do:
  1. install an RPMbuild of cobbler 2.2.3 .  Normally this is laughable-stupid, but we know the official one's coming eventually and we'll get the update from the official channels automatically.
    1. From the cobbler release_22 branch, go get the TGZ file for the latest 2.2 release:
      https://github.com/cobbler/cobbler/tarball/release22
    2. unpack that
      tar -C /tmp -xf cobbler-cobbler-cobbler-2.2.3-2-0-g80d646a.tar.gz(or just do it all in one go:
        wget -qO- 
      https://github.com/cobbler/cobbler/tarball/release22 | tar -C /tmp -xzf - )
    3. change and build it
      make -C /tmp/cobbler-cobbler-80d646a  rpms
    4. if you're me, you'll then remake it just to get the right apt repo, but hey.  People like to make things inside-out, and forget that the packaging is on the outside of the build.  Be nice to them, though, as they may be amateurs, and it's easy like rolling a stop-sign.
    5. install cobbler over what you have:
      rpm -Uvh  /tmp/cobbler-cobbler-80d646a/rpm-build/cobbler-2.2.3-2.noarch.rpm
    6. watch it fail when you do a cobbler check due to a missing and unreported dependency:
      cobbler check
    7. install said dependency, re-run cobbler check, think disapproving thoughts of the packagers:
      yum -y install python-ctypes
      cobbler check
  2. grab your ESXi5 ISO
  3. import that
    mount -o loop VMware-VMvisor-Installer-5.0.0.update01-623860.x86_64.iso /mnt/cdrom
    cobbler import -name esxi5 --path /mnt/cdrom/
  4. rejoice
    more beer
It really is that easy, once you have a cheat-sheet.  Now go hack up a decent esxi5 KS and start installing like a boss.


Labels: , , , , , ,

Saturday, March 03, 2012

Diffing Configs After an RPM install

Some daemon not starting?  Think you may have mucked with the config and you don't know how?  Let's talk about stashing your configs in an SCM, you lamer, or maybe doing a backup every month or so?  (ha, gotcha) For now, let's find out what you've done.
[root@gator ~]# mkdir /tmp/bz75819
[root@gator ~]# yumdownloader --destdir !$ `rpm -qf --qf "%{name}\n" /etc/httpd/conf/httpd.conf`
yumdownloader --destdir /tmp/bz75819 `rpm -qf --qf "%{name}\n" /etc/httpd/conf/httpd.conf`
[root@gator ~]# rpm2cpio /tmp/bz75819/*.rpm | cpio -tv | grep /etc/httpd/conf/httpd.conf
6573 blocks
-rw-r--r--   1 root     root        33726 Oct 20 14:05 ./etc/httpd/conf/httpd.conf
[root@gator ~]# rpm2cpio /tmp/bz75819/*.rpm | cpio -i --to-stdout */etc/httpd/conf/httpd.conf | diff -u - /etc/httpd/conf/httpd.conf
6573 blocks
--- -   2012-03-03 16:05:07.411845000 -0800
+++ /etc/httpd/conf/httpd.conf  2012-03-03 16:05:01.000000000 -0800
@@ -131,7 +131,7 @@
 # prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
 #
 #Listen 12.34.56.78:80
-Listen 80
+#Listen 80

 #
 # Dynamic Shared Object (DSO) Support
So that's what you've done.  Yeah, it looks contrived, but I saw that this week.  So when I see it again this week, I know what to do.

Have you ever needed to find out just what you've changed in a config since a package has been installed?

Labels: , , , , , ,

Thursday, December 15, 2011

Installing and Using MSSQL from PHP on Centos5/RHEL5

The boss wants to use an MSSQL (a Sybase derivative) to power a PHP page on Linux.  You're thinking to yourself that the boss has finally lost it as you nod and smile politely.

Thing is, it's possible. And it's actually not so hard.  Installing it is tricky;  it's like this:
  1. yum install php-mssql
That's it.  It'll pull in both freetds (from EPEL) and unixodbc if it's not already installed.  How easy was that?  Okay, you may need to install the EPEL repository as well, but that's cake.

Now to use it.  Here's a sample.php:
sed 's:#:<:' <<-EOF >/tmp/sample.php
#?php
try {
  if (function_exists("mssql_connect")) {
    if (($m = mssql_connect("db.host.com:1433", "user", "passwd")) !== FALSE) {
      if (function_exists("mssql_query")) {
        $res = mssql_query("SELECT @@VERSION", $m);
        $row = mssql_fetch_array($res);
        print_r($row);
      } else
        throw new Exception("mssql_query function doesn't exist");
    } else
      throw new Exception("connection failed");
  } else
    throw new Exception("mssql_connect function doesn't exist");
  mssql_close($m);
} catch(Exception $e) {
  echo "#PRE>";
  print_r($e);
  echo "#/PRE>";
}
?>
EOF
And that should easily return a valid query and response.  And that's nice, because while the boss may well be crazy, his crazy grin looks better over free coffees.

Labels: , , , ,

Monday, September 26, 2011

ReCollecting the FileProvides

I use APT for RPMs, as it's the most versatile tool out there.  Some folks don't seem to understand that APT was ported for RPMs about a decade ago, and those using Yum for their RPM management are encouraged to do so, lest their horizons grow too broad.  The truly genius folks at Conectiva used APT to great benefit, and allowed massive flexibility;  upgrading in-place over a major release was a possible, easy and well-tested procedure, as I recall.  But this isn't for the Apt-RPM genius so recently localized at Conectiva and now lost to the rest of the world.

Lately there's been another change to the repository format and layout as used by YUM;  this is nothing new, as many open-source de-facto standards are developed and grow in the same kind of seeming vacuum, and the gaijin must adapt.  If you're suffering as I was, your apt-get update invocations will look like this:
E: Error occured while processing sec (CollectFileProvides) E: Problem with MergeFileProvides /var/lib/apt/lists/archive_cobbler_repo%5fmirror_epel5-i386_repodata_277d21a2341fe766d0daff22b2846905517bcd71-primary.sqlite
I'm using Cobbler to mirror many, many repos locally; almost anywhere I have more than one machine.  The update to the createrepo invocation will either come from /etc/cobbler/settings or the createrepo flags in a particular repository item.

Here's my change:
--- /etc/cobbler/settings~ 2011-09-23 07:03:38.000000000 -0700 +++ /etc/cobbler/settings 2011-09-26 14:24:32.000000000 -0700 @@ -58,7 +58,7 @@ # enables working with Fedora repos from F11/F12 from EL-4 or # EL-5 without python-hashlib installed (which is not available # on EL-4) -createrepo_flags: "-c cache -s sha -C --update" +createrepo_flags: "-q -c cache -s sha --update -d" # if no kickstart is specified to profile add, use this template default_kickstart: /var/lib/cobbler/kickstarts/default.ks
You will need to adjust to suit, as the patch will not apply cleanly unless you've been mucking about there already, but take the patch and make yours match the result.  Restart cobbler when you're done and your repos will be updating madly as expected.

As always, sorry if the Blogspot editor butchers my blockquotes.

Labels: , , , , , ,

Tuesday, April 12, 2011

NoStorage and Kickstart - How to Specify Multiple HBA Modules

When kickstarting, you have the option of using 'nostorage' on the PXE command line to prevent storage HBA drivers from loading -- you can do the same to NICs, but it's not as interesting, not as common and the command line is dumber.
default linux
prompt 0
timeout 1
label linux
     kernel /images/centos55-x86_64/vmlinuz
     ipappend 2
     append initrd=/images/centos55-x86_64/initrd.img ksdevice=eth0 lang= kssendmac nostorage text ks=http://archive/cblr/svc/op/ks/system/Bish-PXETest
See that?  NoStorage.  Okay.

So what if you want to use the same kickstart for different machines?  For different HBAs ?  Normally you're screwed.  This won't work, either:
device scsi ahci
device scsi mptspi
device scsi cciss
Specifying the HBA drivers on multiple lines should work, but it's not that simple -- doing so makes it choose the first one and ignore every other invocation of the device line.  This does work, though:
device scsi ahci:mptspi:cciss
See the colons? There you go.  It allows/forces you to choose the order, so plan carefully.

Labels: , , , , ,

Saturday, October 30, 2010

Maintaining Repos in Kickstarted Machines After Install

After you've installed a machine, its install-time repository config in /etc/yum.repos.d is pretty much set.

Bah, I say! Bah! Just keep it updated.

Kickstart (cobbler):
#set yumconfcronfilename = "/etc/cron.daily/50-yum-config-stanza"
cat << EOECYCS > $yumconfcronfilename
#!/bin/sh
$yum_config_stanza

sed -ne '
        /^baseurl=/{
                s/baseurl=/repomd /
                s://:__:
                s:/: :
                s:__://:
                p
        }
        ' /etc/yum.repos.d/cobbler-config.repo \
          > /etc/apt/sources.list.d/cobbler-config.list
EOECYCS
chmod a+x $yumconfcronfilename
If you're not running cobbler, set it into place by hand:
cat << EOECYCS > /etc/cron.daily/50-yum-config-stanza
#!/bin/sh
wget "http://archive/cblr/svc/op/yum/profile/centos5-i386-minimal" --output-document=/etc/yum.repos.d/cobbler-config.repo

sed -ne '
 /^baseurl=/{
  s/baseurl=/repomd /
  s://:__:
  s:/: :
  s:__://:
  p
 }
 ' /etc/yum.repos.d/cobbler-config.repo \
   > /etc/apt/sources.list.d/cobbler-config.list
EOECYCS

chmod a+x /etc/cron.daily/50-yum-config-stanza
That's dereferenced for you. The actual profile's going to be way off, though, so don't use that one verbatim. Find your own:
awk -F/ '/^url/{print $NF}' anaconda-ks.cfg
As usual, watch carefully for the way in which the 'new', 'better' blogspot editor makes an artistic puree of the quoted stuff;  grain of salt, kids.

Labels: , , , , , , , , , ,

Friday, October 15, 2010

vconfig, invalid arguments and Favouritism

So I'm messing with vconfig;  really I'm letting the system do most of it, but it backs onto vconfig.

Explain to me why I can't vconfig a new vlan to an interface:

# service network stop ; service network start
Shutting down interface eth2.2401:  Removed VLAN -:eth2.2401:-
                                                   [  OK  ]
Shutting down interface eth2.2402:  Removed VLAN -:eth2.2402:-
                                                   [  OK  ]
Shutting down interface eth2.2403:  Removed VLAN -:eth2.2403:-
                                                   [  OK  ]
Shutting down interface eth2.2404:  Removed VLAN -:eth2.2404:-
                                                   [  OK  ]
Shutting down interface eth0:                      [  OK  ]
Shutting down interface eth1:                      [  OK  ]
Shutting down interface eth2:                      [  OK  ]
Shutting down loopback interface:                  [  OK  ]
Disabling IPv4 packet forwarding:  net.ipv4.ip_forward = 0
                                                   [  OK  ]
Bringing up loopback interface:                    [  OK  ]
Bringing up interface eth0:                        [  OK  ]
Bringing up interface eth1:
Determining IP information for eth1... done.
                                                   [  OK  ]
Bringing up interface eth2:                        [  OK  ]
Bringing up interface eth0.2401:                   [  OK  ]
Bringing up interface eth0.2403:  ERROR: trying to add VLAN #2403 to IF -:eth0:-  error: Invalid argument
ERROR: could not add vlan 2403 as eth0.2403 on dev eth0
                                                           [FAILED]
Bringing up interface eth2.2401:  Added VLAN with VID == 2401 to IF -:eth2:-
                                                   [  OK  ]
Bringing up interface eth2.2402:  Added VLAN with VID == 2402 to IF -:eth2:-
                                                   [  OK  ]
Bringing up interface eth2.2403:  Added VLAN with VID == 2403 to IF -:eth2:-
                                                   [  OK  ]
Bringing up interface eth2.2404:  Added VLAN with VID == 2404 to IF -:eth2:-
                                                   [  OK  ]
Bringing up interface br1:                         [  OK  ]
Bringing up interface br3:                         [  OK  ]

That's not the weirdest part:
# ifconfig | grep HW
br1       Link encap:Ethernet  HWaddr 00:0C:29:5C:6D:00
eth0      Link encap:Ethernet  HWaddr 00:0C:29:5C:6D:00
eth0.2401 Link encap:Ethernet  HWaddr 00:0C:29:5C:6D:00
eth1      Link encap:Ethernet  HWaddr 00:0C:29:78:8F:9E
eth2      Link encap:Ethernet  HWaddr 00:0C:29:5C:6D:14
eth2.2401 Link encap:Ethernet  HWaddr 00:0C:29:5C:6D:14
eth2.2402 Link encap:Ethernet  HWaddr 00:0C:29:5C:6D:14
eth2.2403 Link encap:Ethernet  HWaddr 00:0C:29:5C:6D:14
eth2.2404 Link encap:Ethernet  HWaddr 00:0C:29:5C:6D:14
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
tun1      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
tun2      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
tun3      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
# vconfig add eth0 2404
Added VLAN with VID == 2404 to IF -:eth0:-
# vconfig rem eth0.2404
Removed VLAN -:eth0.2404:-
# vconfig add eth0 2403
ERROR: trying to add VLAN #2403 to IF -:eth0:-  error: Invalid argument
For some reason, that exact vLAN is the one I can't apply to that interface.  The preceding one goes fine;  so does the one after.  That one?  No go.

Riddle me that.  And, once again. sorry if the format absolutely sucks.  I just can't figure out how to make this editor not chew up my blockquotes.

Labels: , ,

Thursday, September 30, 2010

Whither be Withered Stateless Linux?

I've been pocking at Stateless Linux for a while.

Probably since it was called Diskless Linux.  Names change.

Anyway, I stumbled over a stateless linux page referring to a tech preview in RHEL5, which sounds awesome.

Sadly it doesn't appear to be available.  "Install FC7," it says, not knowing that FC7's stereotypical 3-week support window closed at least a week ago, and thus any projects using it will simply not work.

So where did the Tech Preview go?  If it was a tech preview way back in 1992 or whenever RHEL5 was released, should it not be at least a tech preview now?

I worry that the Open Source Community has an attention span even shorter than mine.

Labels: , , , , ,

Wednesday, August 18, 2010

Check the CommandLine Options in your PXE Booting Linux

I'm not sure if the grammar in the subject is the best it can be.

A question came up on a mailing list about command line options which can be passed to the linux installer at boot time.  The user in question is rolling out a series of new hosts with RocketRaid HBAs in them - for which I admire his courage where I gave up - and needs to push the driver disk to them at install time or they'll never see the root disks.  No, kickstart is not a viable option yet.

After some groveling through the options - and I suspect a RH employee who I fear had  to hold back for fear of breaching a Centos/RHEL condition - I think we got him exactly what he needs, which is awesome.

Want to look at those command line options in one go?  Try this:

zcat /tftpboot/images/centos5-x86_64/initrd.img | \
     cpio -iv --to-stdout sbin/loader|strings|less

Do that - adjusting for location - and start vgrepping.

For what it's worth, after jamming a fan onto my Adaptec 2405 (a Scythe Mini Kaze HTPC Silent Mini Fan 50MM 4500RPM 9.42CFM 26.09DBA 2 Pin W/ 3 Pin Adaptor, to be OCD about it) works like a charm.  Go get one of those and discard the HotPoint stuff, imho.

Labels: , , , , , , , ,

Monday, July 19, 2010

vLANs on Linux (physical) Hosts

vLANs on VMware virtual linux guests is easy.  Set it and you're done, right?

On physical hosts, though, it can be a bit more tricky.  It seems the format's changed a bit, too, between RHEL4 and RHEL5 -- for the better!

By example, though, to add vLan 101 to your eth2, it's like this:
(emacs /etc/sysconfig/network-scripts/ifcfg-eth2.101)VLAN=yes
DEVICE=eth2.101
ONBOOT=yes

BOOTPROTO=none
IPADDR=10.101.2.17NETMASK=255.255.255.0
 Yeah, it's that easy.  The scripts extract the device name (eth2) and vLan (101) from the DEVICE tag, if it sees the VLAN=yes setting.  When you're done:
ifup eth2.101
Your machine should (wait an agonizing 2 seconds and) display something like this:
Added VLAN with VID == 101 to IF -:eth2:-
And you know you're done.  You can use all the tools you would expect, just like with regular devices and/or ipaliased devices:

ifconfig eth2.101
tshark -i eth2.101 host sniffme.mynet.com
ping -I eth2.101 sniffme
One bit of caution, though:  vLANs are privacy; not security.  What this means is that you should never have vLANs carrying data where anything-but-completely trustable machines can hear it, even if it's in a vLAN.  It's trivial to peel the leading vLAN tag off a packet and read it from the untagged network (eg eth2).

Get your stuff onto a managed switch!  Segregate your traffic!  If you aren't 100% sure, the best security between two networks is an air gap.

Labels: , , ,

Sunday, July 11, 2010

Find your RAID MD Device Name from a Member Device

So you've got a bajillion RAID arrays; that's okay, really.  Thing is, if you need to find its mdX device, it can get tricky.  vGrep taxing the eyes?  Mine too, and I haven't had much luck with an alternative.  I know there's one out there, but I have yet to trip over it.

Here's what I've started doing:
mdadm --detail --scan |\
awk '/'`mdadm -E /dev/sde3|awk '/UUID/{print $NF}'`'/{print $2}'

/dev/md6
 Substitute in your own values for /dev/sde3.

Labels: , , , , ,