lunedì 7 maggio 2012

Autenticazione Multi-Tenant Active Directory con Dovecot

Nota: questo articolo è un'estensione di Mailbox Virtuali con Dovecot, Postfix e Active Directory

Se volessimo fare in modo che il nostro server di posta autentichi su diversi domini AD è necessario apportare qualche piccola modifica alla configurazione di Dovecot.
Prendiamo come esempio questa struttura:


Il dominio BRICK.LOCAL ha una relazione di Trust unidirezionale col dominio TRICK.LOCAL. Percé la relazione di trust funzioni c'è bisogno che sui due DNS di AD sia impostato un conditional forward.

Proviamo quindi a risolvere TRICK.LOCAL:

nslookup trick.local
Server:        192.168.98.101
Address:    192.168.98.101#53

Non-authoritative answer:
Name:    trick.local
Address: 192.168.99.101

Nel caso non risolvesse, c'è da controllare la configurazione DNS.

Aggiungiamo nella configurazione di kerberos i parametri relativi al secondo dominio AD, modificando il file /etc/krb5.conf:

[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log 

[libdefaults]
default_realm = BRICK.LOCAL
dns_lookup_realm = true
dns_lookup_kdc = true

[realms]
BRICK.LOCAL = {
kdc = brick.local:88
admin_server = brick.local:749
default_domain = brick.local
}

TRICK.LOCAL = {
kdc = trick.local:88
admin_server = trick.local:749
default_domain = trick.local
}

[domain_realm]
.brick.local = BRICK.LOCAL
brick.local = BRICK.LOCAL
.trick.local = TRICK.LOCAL
trick.local = TRICK.LOCAL

[kdc]
profile = /var/kerberos/krb5kdc/kdc.conf

[appdefaults]
pam = {
debug = false
ticket_lifetime = 36000
renew_lifetime = 36000
forwardable = true
krb4_convert = false
}


Dal momento che il setup che andremo a realizzare sarà un setup multidominio, e si configurerà la possibilità di collisione fra nomi utente, è necessario variare il modo in cui Dovecot chiamerà la procedure di login e in cuiandrà a salvare i messaggi su filesystem.

Modifichiamo il file /etc/dovecot/conf.d/10-auth.conf

auth_username_format =%Ln@%Ud

In questo modo Dovecot passerà a PAM il nome utente nella forma utente@DOMINIO, in modo da rispettare la sintassi di kerberos utente@REALM.

Modifichiamo poi i file:

/etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:/var/vmail/%Ld/%Ln/Maildir

/etc/dovecot/conf.d/auth-system.conf.ext

userdb {
  driver = static
  args = uid=500 gid=500 home=/var/vmail/%Ld/%Lu/Maildir allow_all_users=yes
}

In questo modo i messaggi verranno registrati nella cartella dominio/utente sotto /var/mail.

venerdì 23 marzo 2012

xenbackup-ng, for backing up your xenserver VMs with quiescent snapshot

Starting from Filippo Zanardo's Xenbackup, I wrote a modified version of his scripts, now tested and running on Citrix Xenserver 5.6 fp1 and Citrix Xenserver 6.0.2.

The script has the purpose to backup a Citrix Xenserver Guests Virtual Machines and it can be configured for doing it in different ways. 

Besides the Filippo's original version, I included some features:
  • Split configuration files: one for strings, one for operational parameters.
  • Added the Job feature: it is possible to create a job file in the job dir where general options can be overridden.
  • Selective VM backup: it is possible to declare a list of VMs that will be backed up.
  • Quiesce Snapshot on Windows VM: only with Xen VSS Provider installed on guest.
  • Preserve VM power state: in case of normal backup (Shutdown->Backup->Start) the original vm state will be preserved. So, if a VM is initially powered off it will not powered on after backup.
  • Improved email notifications: now is possible to receive a mail with a summary of operations executed or a verbose log of backup process. 

You can download the script direct from here or from my GitHub.

Dont't forget to change the mail address where you receive notification!

venerdì 16 marzo 2012

SCST iSCSI Resource agents for pacemaker.


Inspired by Openfiler I built my own DIY Highly Available SAN using Pacemaker, DRBD, LVM and SCST.
 
My current setup is:
- Two servers running gentoo
- a DRBD device in single primary
- a floating IP address
- an iSCSI Target with one LUN pointing straight to the DRBD device (vdisk_fileio, nv_cache).

The cib looks like:

node isan01 \
    attributes standby="off"
node isan02 \
    attributes standby="off"
primitive DRBD_VG1 ocf:linbit:drbd \
    params drbd_resource="ISCSIVG1" \
    op monitor interval="29" role="Master" \
    op monitor interval="31" role="Slave"
primitive ISCSI_IP1 ocf:heartbeat:IPaddr2 \
    params ip="192.168.100.20" \
    op monitor interval="10s"
primitive ISCSI_LUN_LUN10 ocf:scst:SCSTLun \
    params target_iqn="iqn.2012-02.com.

isan:vdisk.lun10" lun="0" path="/dev/drbd/by-res/DRBD_VG1" handler="vdisk_fileio" device_name="VDISK-LUN10" additional_parameters="nv_cache=1" \
    op monitor interval="10s"
primitive ISCSI_TGT_LUN10 ocf:scst:SCSTTarget \
    params iqn="iqn.2012-02.com.isan:vdisk.lun10" portals="192.168.100.20" \
    op monitor interval="10s" timeout="60s"
group GR_ISCSIVG1 ISCSI_TGT_LUN10 ISCSI_LUN_LUN10 ISCSI_IP1
ms MS_DRBD_VG1 DRBD_VG1 \
    meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true"
colocation CO_ISCSI_ON_DRBD_VG1 inf: GR_ISCSIVG1 MS_DRBD_VG1:Master 
order OR_TARGET_BEFORE_VG1 inf: CL_ISCSI_TGT_LUN1:start GR_ISCSIVG1:start
order OR_DRBD_BEFORE_VG1 inf: MS_DRBD_VG1:promote GR_ISCSIVG1:start
property $id="cib-bootstrap-options" \
    dc-version="1.0.9-da7075976b5ff0bee71074385f8fd02f296ec8a3" \
    cluster-infrastructure="openais" \
    expected-quorum-votes="2" \
    stonith-enabled="false" \
    no-quorum-policy="ignore" \
    default-action-timeout="240"
rsc_defaults $id="rsc-options" \
    resource-stickiness="200"


Now I'm testing it  using vmware ESXi 5 as initiator. Seems working.

You can download them from my Github account ...

... and put them in /usr/lib/ocf/resource.d/scst.

UPDATE

SCST resource agent are now included in head revision of SCST project.
I'm just finished writing a master/slave version of SCSTLun, suitable only for iSCSI vdisk.
In the next days I'll test it and soon publish a little howto :)

venerdì 9 marzo 2012

Esportare le unità a nastro via iSCSI con SCST, autoloader compresi!

Nelle moderne sale server ci piace virtualizzare tutto. A volte anche il server che gestisce i backup. Quando facciamo backup su disco è facile, basta un NAS, ma quando dobbiamo farlo su nastro?
Va bene che vmware supporta il pass-through dei dispositivi SCSI, ma dato che ho un paio di storage iSCSI realizzati con Linux, perché non usarli anche per rendere disponibili nastri e autoloader, oltre che ai dischi?

Vediamo come farlo con linux, il target generico SCST e una unità Dell Powervault 124T.

( Do per scontato che abbiate già un'installazione linux con SCST funzionante, altrimenti in rete ci sono diversi howto da seguire per arrivare allo scopo. )

Per prima cosa colleghiamo e accendiamo la nostra libreria, se è esterna.
Poi controlliamo che il sistema la rilevi correttamente, con il comando lsscsi:

brick01# lsscsi 
[1:0:0:0] cd/dvd PLDS DVD+-RW DS-8W2S 1D11 /dev/sr0
[2:0:0:0] disk Generic STORAGE DEVICE 0207 /dev/sda
[3:0:32:0] enclosu DP BACKPLANE 1.05 -
[3:2:0:0] disk DELL PERC 6/i 1.21 /dev/sdb
[4:0:0:0] tape IBM ULTRIUM-TD4 97F0 -


Le librerie normalmente sono costituite da due LUN, la LUN0 che punta al nastro e la LUN1 che punta al media changer. Nel mio caso quindi (e probabilmente anche nel vostro) manca qualcosa ...

Dal momento che lo SCSI ID dell'unità a nastro è 4:0:0:0, rappresentato nella forma H:C:I:L (Host:Channel-ID-Lun), il nostro media changer dovrebbe corrispondere allo SCSI ID 4:0:0:1.
Per cui diciamo al sottosistema SCSI di linux di andare a interrogare anche l'ID del media changer.

brick01#echo "scsi add-single-device 4:0:0:1" > /proc/scsi/scsi

Ora l'unità dovrebbe fare un po' di rumori. Almeno è quello che ha fatto la mia!
Verifichiamo con lsscsi che il comando sia andato a buon fine:

brick01# lsscsi
[1:0:0:0] cd/dvd PLDS DVD+-RW DS-8W2S 1D11 /dev/sr0
[2:0:0:0] disk Generic STORAGE DEVICE 0207 /dev/sda
[3:0:32:0] enclosu DP BACKPLANE 1.05 -
[3:2:0:0] disk DELL PERC 6/i 1.21 /dev/sdb
[4:0:0:0] tape IBM ULTRIUM-TD4 97F0 -
[4:0:0:1] mediumx DELL PV-124T 0075 -


Ed ecco il apparire il changer!

Ora possiamo procedere con la configurazione di SCST.
Attiviamo prima gli handler di nastro e changer:

brick01#modprobe scst_tape
brick01#modprobe scst_changer


Per chi usa scstadmin, creiamo i due device in pass-through, creiamo un target iscsi e abilitiamolo:


brick01# scstadmin -open_dev 4:0:0:0 -handler dev_tape_perf
brick01# scstadmin -open_dev 4:0:0:1 -handler dev_changer
brick01# scstadmin -add_target iqn.2012-03.com.brick:vsan.tape -driver iscsi
brick01# scstadmin -add_lun 0 -target iqn.2012-03.com.brick:vsan.tape -device 4:0:0:0 -driver iscsi
brick01# scstadmin -add_lun 1 -target iqn.2012-03.com.brick:vsan.tape -device 4:0:0:1 -driver iscsi
brick01# scstadmin -enable_target iqn.2012-03.com.brick:vsan.tape -driver iscsi


Per chi vuole agire direttamente sul file di configurazione, invece:

#File /etc/scst.conf

HANDLER dev_changer {
        DEVICE 4:0:0:1
}

HANDLER dev_tape_perf {
        DEVICE 4:0:0:0
}

TARGET_DRIVER iscsi {
        enabled 1

        TARGET iqn.2012-03.com.brick:vsan.tape {
                enabled 1
                rel_tgt_id 1

                LUN 0 4:0:0:0
                LUN 1 4:0:0:1
        }
}


Poi andate sul vostro initiator preferito (io ho testato il tutto con Microsoft iSCSI Initiator e Symantec Backup Exec), collegate il target, e buon backup!