Sunday, 18 January 2015

IPA Cluster with Windows Server 2012 Trust

Scenario

  • IPA cluster consists of 2 RHEL 6.6 servers
  • Windows Server 2012 will be used for the Active Directory component
  • IPA will manage a sub domain of the Active Directory domain (ipa.demo.net)
  • IPA realm is (IPA)
  • Active Directory domain is (demo.net)
  • Active Directory realm is (WINDOWS)
  • No existing DNS service is pre-existing

Using

  • RHEL 6.6
  • ipa-server 3.0.0

Build Master IPA Server

Fix the servers network identity

  • /etc/sysconfig/network
  • /etc/sysconfig/network-scripts/ifcfg-eth0
  • /etc/resolv.conf (DNS to resolve Red Hat Satellite service)
  • /etc/ntp.conf
  • /etc/hosts (no existing DNS so add an entry for this host)
    echo '192.168.1.53 ipa1.ipa.demo.net ipa1' >> /etc/hosts

Enable NTP

 [root@ipa1 ~]# chkconfig ntpdate on
 [root@ipa1 ~]# chkconfig ntpd on

Update software

 [root@ipa1 ~]# yum update

Reboot

 [root@ipa1 ~]# init 6

Log back in and make sure it is as you expect it to be:

[root@ipa1 ~]# hostname
[root@ipa1 ~]# ntpq -c lpeers
[root@ipa1 ~]# route -n

Install IPA

[root@ipa1 ~]# yum install ipa-server bind bind-dyndb-ldap
[root@ipa1 ~]# ipa-server-install --hostname=ipa1.ipa.demo.net -n ipa.demo.net -r IPA --setup-dns
The log file for this installation can be found in /var/log/ipaserver-install.log
==============================================================================
    This program will set up the IPA Server.

This includes:
  * Configure a stand-alone CA (dogtag) for certificate management
  * Configure the Network Time Daemon (ntpd)
  * Create and configure an instance of Directory Server
  * Create and configure a Kerberos Key Distribution Center (KDC)
  * Configure Apache (httpd)
  * Configure DNS (bind)

To accept the default shown in brackets, press the Enter key.

Existing BIND configuration detected, overwrite? [no]: yes
Enter the fully qualified domain name of the computer
on which you're setting up server software. Using the form
<hostname>.<domainname>
Example: master.example.com.


Server host name [ipa1.ipa.demo.net]: 

Warning: skipping DNS resolution of host ipa1.ipa.demo.net
Certain directory server operations require an administrative user.
This user is referred to as the Directory Manager and has full access
to the Directory for system management tasks and will be added to the
instance of directory server created for IPA.
The password must be at least 8 characters long.

Directory Manager password: 
Password (confirm): 

The IPA server requires an administrative user, named 'admin'.
This user is a regular system account used for IPA server administration.

IPA admin password: 
Password (confirm): 

Do you want to configure DNS forwarders? [yes]: 
Enter the IP address of DNS forwarder to use, or press Enter to finish.
Enter IP address for a DNS forwarder: 192.168.1.3
DNS forwarder 192.168.1.3 added
Enter IP address for a DNS forwarder: 
Do you want to configure the reverse zone? [yes]: 
Please specify the reverse zone name [1.168.192.in-addr.arpa.]: 
Using reverse zone 1.168.192.in-addr.arpa.

The IPA Master Server will be configured with:
Hostname:      ipa1.ipa.demo.net
IP address:    192.168.1.53
Domain name:   ipa.demo.net
Realm name:    IPA

BIND DNS server will be configured to serve IPA domain with:
Forwarders:    192.168.1.3
Reverse zone:  1.168.192.in-addr.arpa.

Continue to configure the system with these values? [no]: yes

The following operations may take some minutes to complete.
Please wait until the prompt is returned.

Configuring NTP daemon (ntpd)
  [1/4]: stopping ntpd
  [2/4]: writing configuration
  [3/4]: configuring ntpd to start on boot
  [4/4]: starting ntpd
Done configuring NTP daemon (ntpd).
Configuring directory server for the CA (pkids): Estimated time 30 seconds
  [1/3]: creating directory server user
  [2/3]: creating directory server instance
  [3/3]: restarting directory server
Done configuring directory server for the CA (pkids).
Configuring certificate server (pki-cad): Estimated time 3 minutes 30 seconds
  [1/21]: creating certificate server user
  [2/21]: creating pki-ca instance
  [3/21]: configuring certificate server instance
  [4/21]: disabling nonces
  [5/21]: creating CA agent PKCS#12 file in /root
  [6/21]: creating RA agent certificate database
  [7/21]: importing CA chain to RA certificate database
  [8/21]: fixing RA database permissions
  [9/21]: setting up signing cert profile
  [10/21]: set up CRL publishing
  [11/21]: set certificate subject base
  [12/21]: enabling Subject Key Identifier
  [13/21]: setting audit signing renewal to 2 years
  [14/21]: configuring certificate server to start on boot
  [15/21]: restarting certificate server
  [16/21]: requesting RA certificate from CA
  [17/21]: issuing RA agent certificate
  [18/21]: adding RA agent as a trusted user
  [19/21]: configure certificate renewals
  [20/21]: configure Server-Cert certificate renewal
  [21/21]: Configure HTTP to proxy connections
Done configuring certificate server (pki-cad).
Configuring directory server (dirsrv): Estimated time 1 minute
  [1/38]: creating directory server user
  [2/38]: creating directory server instance
  [3/38]: adding default schema
  [4/38]: enabling memberof plugin
  [5/38]: enabling winsync plugin
  [6/38]: configuring replication version plugin
  [7/38]: enabling IPA enrollment plugin
  [8/38]: enabling ldapi
  [9/38]: disabling betxn plugins
  [10/38]: configuring uniqueness plugin
  [11/38]: configuring uuid plugin
  [12/38]: configuring modrdn plugin
  [13/38]: enabling entryUSN plugin
  [14/38]: configuring lockout plugin
  [15/38]: creating indices
  [16/38]: enabling referential integrity plugin
  [17/38]: configuring ssl for ds instance
  [18/38]: configuring certmap.conf
  [19/38]: configure autobind for root
  [20/38]: configure new location for managed entries
  [21/38]: restarting directory server
  [22/38]: adding default layout
  [23/38]: adding delegation layout
  [24/38]: adding replication acis
  [25/38]: creating container for managed entries
  [26/38]: configuring user private groups
  [27/38]: configuring netgroups from hostgroups
  [28/38]: creating default Sudo bind user
  [29/38]: creating default Auto Member layout
  [30/38]: adding range check plugin
  [31/38]: creating default HBAC rule allow_all
  [32/38]: Upload CA cert to the directory
  [33/38]: initializing group membership
  [34/38]: adding master entry
  [35/38]: configuring Posix uid/gid generation
  [36/38]: enabling compatibility plugin
  [37/38]: tuning directory server
  [38/38]: configuring directory to start on boot
Done configuring directory server (dirsrv).
Configuring Kerberos KDC (krb5kdc): Estimated time 30 seconds
  [1/10]: adding sasl mappings to the directory
  [2/10]: adding kerberos container to the directory
  [3/10]: configuring KDC
  [4/10]: initialize kerberos container
  [5/10]: adding default ACIs
  [6/10]: creating a keytab for the directory
  [7/10]: creating a keytab for the machine
  [8/10]: adding the password extension to the directory
  [9/10]: starting the KDC
  [10/10]: configuring KDC to start on boot
Done configuring Kerberos KDC (krb5kdc).
Configuring kadmin
  [1/2]: starting kadmin 
  [2/2]: configuring kadmin to start on boot
Done configuring kadmin.
Configuring ipa_memcached
  [1/2]: starting ipa_memcached 
  [2/2]: configuring ipa_memcached to start on boot
Done configuring ipa_memcached.
Configuring the web interface (httpd): Estimated time 1 minute
  [1/13]: setting mod_nss port to 443
  [2/13]: setting mod_nss password file
  [3/13]: enabling mod_nss renegotiate
  [4/13]: adding URL rewriting rules
  [5/13]: configuring httpd
  [6/13]: setting up ssl
  [7/13]: setting up browser autoconfig
  [8/13]: publish CA cert
  [9/13]: creating a keytab for httpd
  [10/13]: clean up any existing httpd ccache
  [11/13]: configuring SELinux for httpd
  [12/13]: restarting httpd
  [13/13]: configuring httpd to start on boot
Done configuring the web interface (httpd).
Applying LDAP updates
Restarting the directory server
Restarting the KDC
Configuring DNS (named)
  [1/9]: adding DNS container
  [2/9]: setting up our zone
  [3/9]: setting up reverse zone
  [4/9]: setting up our own record
  [5/9]: setting up kerberos principal
  [6/9]: setting up named.conf
  [7/9]: restarting named
  [8/9]: configuring named to start on boot
  [9/9]: changing resolv.conf to point to ourselves
Done configuring DNS (named).

Global DNS configuration in LDAP server is empty
You can use 'dnsconfig-mod' command to set global DNS options that
would override settings in local named.conf files

Restarting the web server
==============================================================================
Setup complete

Next steps:
        1. You must make sure these network ports are open:
                TCP Ports:
                  * 80, 443: HTTP/HTTPS
                  * 389, 636: LDAP/LDAPS
                  * 88, 464: kerberos
                  * 53: bind
                UDP Ports:
                  * 88, 464: kerberos
                  * 53: bind
                  * 123: ntp

        2. You can now obtain a kerberos ticket using the command: 'kinit admin'
           This ticket will allow you to use the IPA tools (e.g., ipa user-add)
           and the web user interface.

Be sure to back up the CA certificate stored in /root/cacert.p12
This file is required to create replicas. The password for this
file is the Directory Manager password

Login and Test IPA Master

Ensure your web browser can resolve the fully-qualified host name of the ipa1 server. Even if this means adding an entry to the hosts file.

Point a web browser to:

https://ipa1.ipa.demo.net
Username:  admin
Password:  <as typed during installation>

Build Replica IPA Server

On the Master IPA Server

Prepare the initialisation file for the Replica:

[root@ipa1 ~]# ipa-replica-prepare ipa2.ipa.demo.net --ip-address 192.168.122.54
Directory Manager (existing master) password: 

Preparing replica for ipa2.ipa.demo.net from ipa1.ipa.demo.net
Creating SSL certificate for the Directory Server
Creating SSL certificate for the dogtag Directory Server
Creating SSL certificate for the Web Server
Exporting RA certificate
Copying additional files
Finalizing configuration
Packaging replica information into /var/lib/ipa/replica-info-ipa2.ipa.demo.net.gpg
Adding DNS records for ipa2.ipa.demo.net
Using reverse zone 122.168.192.in-addr.arpa.

Written with StackEdit.

Saturday, 8 November 2014

Install Red Hat Satellite 6 in Disconnected Mode on RHEL 7

The server running katello-disconnected can itself be managed by a local Satellite server including Satellite 5. Pulp will still go to cdn.redhat.com and any other defined repositories for syncing the repositories.

Prerequisites:
  • RHEL 7
  • check networking to Red Hat Network
  • check host DNS entries, forward and reverse:
    • nslookup <hostname>
    • nslookup <ip address>
  • check NTP:
    • ntpq
Debug:
Example print statement for Ruby
STDERR.puts "Variable x is #{x.inspect}"
 
Register host with Red Hat Network:

subscription-manager register


Identify the "Pool Id" for your Satellite Entitlement:

subscription-manager list --available --all | sed -e '0,/^Subscription Name: Red Hat Satellite/ d' -e '/^$/,$ d'


Attach the Satellite Entitlement:

subscription-manager subscribe --pool=<pool_id>


Disable any existing repos:

subscription-manager repos --disable "*"


Enable the following repos:

subscription-manager repos --enable rhel-6-server-rpms --enable rhel-server-rhscl-6-rpms --enable rhel-6-server-satellite-6.0-rpms


Ensure the server's packages are up to date:

yum groupinstall \@base
yum update


Install katello-utils:

yum install python-qpid-qmf python-qpid qpid-cpp-server-store katello-utils


Configure the oauth_secret for the Pulp service:

pass=$(tr -dc "[:alnum:]" < /dev/urandom | head -c 32)
sed --in-place -e "/^\[oauth\]/ a \
enabled: true\noauth_key: katello\noauth_secret: $pass" /etc/pulp/server.conf


Disable authentication in qpid so the Satellite's default releam will be used:

sed --in-place -e '/^auth=/ s/yes/no/' /etc/qpid/qpidd.conf


Configure katello-disconnected to use Pulp's secret:

katello-disconnected setup --oauth-key=katello --oauth-secret=$pass


Configure the Pulp service to start now and on boot:

systemctl start qpidd
systemctl enable qpidd
systemctl start mongod
sleep 10
systemctl enable mongod
sudo -u apache pulp-manage-db
systemctl restart httpd
systemctl enable httpd
systemctl start pulp_workers
systemctl enable pulp_workers
systemctl start pulp_celerybeat
systemctl enable pulp_celerybeat
systemctl start pulp_resource_manager
systemctl enable pulp_resource_manager


Import the Satellite Manifest:

katello-disconnected import -m <manifest.zip>


Disable all repositories: (this is not disabling anything on mine as verified by katello-disconnected list)

katello-disconnected disable --all


View all disabled repositories:

katello-disconnected list --disabled > /root/available.repos
grep -v -e debug -e beta -e source -e -eus- available.repos | grep -- -x86_64$ | less


Enable the required repositories:

katello-disconnected enable --repos <repository_label>[,<repository_label>,...]

Eg.
katello-disconnected enable --repos rhel-6-server-kickstart-6Server-x86_64,rhel-6-server-extras-rpms--x86_64,rhel-6-server-optional-rpms-6Server-x86_64,rhel-6-server-rh-common-rpms-6Server-x86_64,rhel-6-server-rhev-agent-rpms-6Server-x86_64,rhel-6-server-rhn-tools-rpms-6Server-x86_64,rhel-6-server-rpms-6Server-x86_64,rhel-6-server-supplementary-rpms-6Server-x86_64,rhel-7-server-extras-rpms--x86_64,rhel-7-server-kickstart-7Server-x86_64,rhel-7-server-optional-rpms-7Server-x86_64,rhel-7-server-rh-common-rpms-7Server-x86_64,rhel-7-server-rhn-tools-rpms-7Server-x86_64,rhel-7-server-rpms-7Server-x86_64,rhel-7-server-supplementary-rpms-7Server-x86_64,puppet-forge


Create the repositories and push them to Pulp to allow synchronisation:

katello-disconnected configure


Sync a single repository as the "disable --all" repositories did not work earlier:

katello-disconnected sync -r rhel-7-server-rpms-7Server-x86_64


Tuesday, 4 November 2014

Getting Started with RHEL 7

Fix the Host's Name

  • hostnamectl set-hostname pilot.spud.net.au
  • hostnamectl status
Well that was easy and dynamic. 
Reference:  http://www.itzgeek.com/how-tos/linux/centos-how-tos/change-hostname-in-centos-7-rhel-7.html#axzz3I3bWPTDI

Fix Networking

  • nmtui

Friday, 4 April 2014

RHEL 6 Custom Installation DVD

The following procedure will create a custom RHEL 6 DVD ISO image file with the following attributes:
  • based on the original Red Hat installation DVD with all its features including rescue mode and the default Red Hat installation
  • changes the default boot menu  to "local boot" so you don't accidentally blow away a server!
  • adds a your own custom boot menu to the top of the list
  • adds your own custom kickstart script to the custom boot menu
I have added my "Core" kickstart file which:
  • installs on the first hard disk, virtual or physical
  • partition 1:  /boot ext4 512MB
  • partition 2: LVM VG "vg0" 2560MB
  • vg0/ROOT ext4 2048MB
  • vg0/SWAP swap 512MB
The idea is that the partitions, LVM volume group(s) and logical volumes as created/expanded by a later configuration script.  I purposely wanted to make this first installation generic but practical.  I am providing my configuration via a second DVD which will be mounted after the first reboot. 

There is no networking.  Packages are "core" plus a few more.  Please enjoy.

 Files

 Instructions

cd ISOs/

mkdir rhel6-dvd
mount -o loop,ro rhel-server-6.5-x86_64-dvd.iso rhel6-dvd/

mkdir rhel-server-6.5-x86_64-core-dvd
cp -av rhel6-dvd/. rhel-server-6.5-x86_64-core-dvd
umount rhel6-dvd  && rmdir rhel6-dvd

cp <.../ks-core-nonetwork.cfg> rhel-server-6.5-x86_64-core-dvd
sed -i -e '/menu default/d' \
   -e '/^label local/ a \
  menu default' rhel-server-6.5-x86_64-core-dvd/isolinux/isolinux.cfg
awk '/^label / && !found {print "label core\nmenu label ^Core installation of RHEL 6.5. First disk, no network.\nmenu default \nkernel vmlinuz \nappend initrd=initrd.img ks=cdrom:/ks-core-nonetwork.cfg"; found=1} 1' rhel-server-6.5-x86_64-core-dvd/isolinux/isolinux.cfg > /tmp/isolinux.cfg
mv -vf /tmp/isolinux.cfg rhel-server-6.5-x86_64-core-dvd/isolinux/isolinux.cfg

yum install genisoimage
mkisofs -r -T -J -V "RHEL Server 6.5-x86_64 Core" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o rhel-server-6.5-x86_64-core-dvd.iso rhel-server-6.5-x86_64-core-dvd



Wednesday, 1 January 2014

Building a Gentoo Mediatomb server

References:
  • http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?full=1
  • http://wiki.gentoo.org/wiki/MediaTomb
Used 2.9GB of disk to get to a fully functional Gentoo Mediatomb server with only 55 installed packages.

Below is a list of the commands I used to prepare a KVM virtual machine hosted on RHEL 6.  It starts with preparing the virtual disk which in this case a an LVM Logical Volume:

On host that is preparing Gentoo "/" file system (not chroot):

 1020  lvcreate -m 1 --mirrorlog mirrored -L10G -n vm_mediatomb-ROOT JD
 1021  fdisk /dev/JD/vm_mediatomb-ROOT
 1022  cfdisk /dev/JD/vm_mediatomb-ROOT
 1023  kpartx -l /dev/JD/vm_mediatomb-ROOT
 1024  kpartx -a /dev/JD/vm_mediatomb-ROOT
 1025  mkfs.ext4 -L mediatomb-ROOT /dev/mapper/JD-vm_mediatomb--ROOT1
 1027  cd /mnt
 1028  mkdir mediatomb
 1029  mount /dev/mapper/JD-vm_mediatomb--ROOT1 mediatomb
mkdir /root/tmp
cd /root/tmp
wget http://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3/stage3-amd64-20131226.tar.bz2
 1030  cd /mnt/mediatomb/
 1032  tar xvjpf /root/tmp/stage3-amd64-20131226.tar.bz2
 1034  cd etc
 1037  cp -L /etc/resolv.conf .
 1038  vim resolv.conf
vim portage/make.conf
• CFLAGS="-march=native -O2 -pipe"
• USE="mmx sse sse2 aac faac jpeg2k mmxext mp3 ssse3 threads twolame vorbis x264 xvid"
• MAKEOPTS="-j4"
• GENTOO_MIRRORS="rsync://rsync.au.gentoo.org"
• PORTAGE_RSYNC_INITIAL_TIMEOUT=45
• DONT_MOUNT_BOOT=1
ls ../usr/share/zoneinfo/Australia/Canberra
echo "Australia/Canberra" >timezone
cat timezone
vim locale.gen
blkid
vim fstab
vim conf.d/hostname
• hostname="mediatomb"
vim conf.d/net
• config_eth0="dhcp"
cd ..
mount -t proc none proc
mount --rbind /sys sys
mount --rbind /dev dev
chroot /mnt/mediatomb /bin/bash


On Gentoo chroot environment:
source /etc/profile
export PS1="(chroot) $PS1"
    4  ls -l /etc
    5  emerge-webrsync    # failed.  Played with mirrors and eventually "emerge --sync" worked instead.
    6  emerge --sync
    9  eselect news list
   14  eselect news read 1
   15  eselect news read 2
   16  eselect news read 3
   17  eselect news read 4
   18  eselect news read 5
   19  eselect news read 6
   20  eselect news purge
   21  eselect news list
   22  eselect profile list
   23  emerge --config sys-libs/timezone-data
   24  locale-gen
   25  locale -a
   26  eselect locale list
   27  eselect locale set 4
   28  env-update && source /etc/profile
   29  emerge gentoo-sources
   30  cd /etc/init.d
   34  ls
   35  ln -s net.lo net.eth0
   36  ls -l
   37  rc-update add net.eth0 default
   38  cd /usr/src
   41  ls -l
   42  cd linux
   43  make menuconfig
   44  make && make modules_install
   49  cp arch/x86_64/boot/bzImage /boot/kernel-3.10.17-gentoo
   52  ls -hl /boot/kernel-3.10.17-gentoo
passwd
 emerge -av vim syslog-ng logrotate vixie-cron dhcpcd sys-boot/grub
rc-update add sshd default
rc-update add syslog-ng default
vim /etc/conf.d/hwclock

emerge -av mediatomb


I could not get Grub2 to install from the above chroot-ed environment as the running virtual machine is just too different from this.  Therefore I used a Gentoo Installation ISO to start the VM and finish the Grub2 installation:

grub2-install /dev/vda
grub2-mkconfig -o /boot/grub/grub.cfg

Tuesday, 22 October 2013

Upgrade / Install Red Hat Satellite v5.6


  • Documentation:  https://access.redhat.com/site/documentation/Red_Hat_Satellite/
  • Installation Media:  https://rhn.redhat.com/rhn/software/channel/downloads/Download.do?cid=18952
  • RHN Software Channel:   
  • New Satellite Certificate:   https://access.redhat.com/home under Subscriptions → RHN Classic → Entitlements.

Problems with the Official Documentation

  • Manual says to install "rhn-upgrade" package from the "Red Hat Satellite Channel" but it does not say which version of the channel, 5.5 or 5.6.  I am going to assume that the upgrade will subscribe an RHN Connected Red Hat Satellite Server to the new Software Channel, there this must be the ?
  • The upgrade installs the "postgres" package for you but you need the directory /var/lib/pgsql to be owned by postgres with group of postgres and a mode of 0700 and the SELinux context set to "".  Maybe it is easy to pre-emptively install postgres?

Upgrade Red Hat Satellite

"Chapter 6. Upgrades"  of the "Red Hat Satellite 5.6 Installation Guide" covers this process in detail.  My summary is as follows:

  • Update RHEL.
  • Ensure there are no outstanding Red Hat Satellite database schema updates. 
  • Ensure that when the directory /var/lib/pgsql comes to exist it will have sufficient free space to accommodate the equivalent contents of /rhnsat.
  • Install "postgres" package to ensure the correct permissions before the Red Hat Satellite installer can complain about it.
  • Upgrade as per the manual
  • Rebuild the Cobbler Distro Trees:  /etc/sysconfig/rhn/satellite-upgrade/scripts/regenerate-repodata -a
  •  


hmm....sorry run out of time tonight.  maybe later this week!

Monday, 21 October 2013

Red Hat Satellite Integrity Checker

Setup a regular job to test the integrity of the Satellite's database records and the RPM repository.  spacewalk-data-fsck comes with Red Hat Satellite and it does not produce much output even with the verbose switch.  It really does take a whole day to run so schedule it accordingly.

I use the "-r" switch so it deletes any stray packages that are no-longer in the database.  I don't know if that can get someone into trouble on some edge case with custom packages or something.  The "satellite-sync" is run after to replace any packages that were deleted because there was a consistency issue with either the database record or the package itself.

cat <<EOF > /usr/local/sbin/satellite-integrity-checker.sh
#!/bin/bash

spacewalk-data-fsck -v -r &>/tmp/spacewalk-data-fsck.output
satellite-sync &>/tmp/satellite-sync.output

EOF

chmod 755 /usr/local/sbin/satellite-integrity-checker.sh

ln -s
/usr/local/sbin/satellite-integrity-checker.sh /etc/cron.weekly/