Kickstart Server


This is a quick tutorial on how to setup an Apache based Kickstart install server for provisioning Red Hat or CentOS hosts in your environment. By Kickstarting a host/s you can save time and standardize your environment by defining a configuration file that all hosts will use to perform automated installs.

1. Head over to centos.org and download the iso of the CentOS release you are interested in. I will be using CentOS 5.4 for the purposes of this tutorial.
2. Install Apache.
Check your system for Apache being installed using:
[root@kickstart kickstart]# rpm -qa |grep -i httpd
If nothing returns issue:
yum -y install httpd
This should download and install the dependencies for Apache.
3. Create a install root where we will be installing the contents of the cdrom to. I’ll be using the default document root in /var/www/html.
mkdir /var/www/html/centos5
4. Mount the iso you downloaded to a mount point.
[root@kickstart iso]# mount -o loop CentOS-5.4-i386-bin-DVD.iso /mnt
5. Copy the contents of the iso into the directory you created.
cp -ar /mnt/* /var/www/html/centos5/
6. Create a directory to house your kickstart configurations. Once again I’ll be using Apache’s default document root of /var/www/html. I will be creating a directory called ks to store my configurations.
mkdir /var/www/html/ks
7. Create the kickstart configuration file. I named my configuration ks.cfg and dropped it in the ks directory we created in step 6. Here is what I use for my kickstart profile. Very minimal config.
text
install
url --url http://192.168.3.128/centos5
lang en_US.UTF-8
keyboard us
langsupport --default=en_US.UTF-8 en_US.UTF-8
network --device eth0 --bootproto dhcp
rootpw --iscrypted $1$/KEoeArl$f5TokNUdzGIqlvRCLFWW9/
firewall --disabled
selinux --disabled
authconfig --enableshadow --enablemd5
timezone America/New_York
bootloader --location=mbr --append="console=xvc0"
#
zerombr yes
clearpart --all
part /boot --asprimary --fstype="ext3" --size=100 --bytes-per-inode=4096
part swap --asprimary --fstype="swap" --recommended --bytes-per-inode=4096
part / --asprimary --fstype="ext3" --grow --size=1 --bytes-per-inode=4096
reboot
#
%packages --nobase
authconfig
crontabs
kbd
kudzu
man
ntp
openssh-clients
openssh-server
passwd
pciutils
rootfiles
rpm
system-config-securitylevel-tui
traceroute
yum
yum-updatesd
vim-minimal
vixie-cron
which
wget
unzip
kudzu
man
ntp
openssh-clients
openssh-server
passwd
pciutils
rootfiles
rpm
system-config-securitylevel-tui
traceroute
yum
yum-updatesd
vim-minimal
vixie-cron
which
wget
unzip
sudo
%post
(
chkconfig --level 3 ip6tables off
chkconfig --level 3 kudzu off
chkconfig --level 3 netfs off
chkconfig --level 3 yum-updatesd off
#
useradd -p 'myreallycomplexpass' someuser
)  2>&1 | tee /root/post-install.log
8. Use the dvd you downloaded or grab a copy of the boot.iso from the install root. You can either use the install DVD iso you or use the 10MB boot.iso located in centos5/images/boot.iso I choose to use the boot.iso since its 10MB and is easily distributable.
9. Start up the Apache process
[root@kickstart images]# service httpd start
Starting httpd:                                            [  OK  ]
10. Now for the Moment of truth. Boot the system with boot.iso or install DVD. At the boot prompt enter:
linux ks=http://your_kickstart_ip/ks/ks.cfg
DONE

Automated Installation of CentOS 6.x And Kickstart File

Today, I am going to show you how you can automate installation of CentOS version 6.0 or later without any user intervention. Just turn on computer and follow the steps ! You can use the same process for RedHat too.

Advantage:
It’s totally automated installation for a mass of computers. Just imagine that you have 250 or more workstations or you have 100 servers in production. Of course, you don’t want to install OS one by one for each machine. Instead, you should use automated installation.

You may say that we use virtualization software such as KVM,  VMWare,  VirtualBox or etc... and we can clone servers easily. But this is not true in mass installation because of following reasons:
  1.    In most virtualization software, you have to turn off the VM in order to clone it and it’s not possible in production environment
  2.    If you clone a VM, you have to configure Mac address, ip address, hostname, all network setting of cloned VM and also customize other configurations manually
  3.     You don’t have a menu with different flavour of OS to select to install. Automated installation has ability of creation a menu with different OS and changing the default selection. This gives you flexibility of installation for different OS, but clone cannot do this.
In KVM, you can use virt-install command with the same kickstart file, which I will explain later, but you are limited to using just KVM.

Automated Installation Process:
  1. Setup TFTP and PXE server
  2. Setup DHCP server
  3. Setup FTP server
  4. Setup Kickstart file
You can set up a server for TFTP/PXE, DHCP, and FTP (all of them). In my example, I set up one server for TFTP/PXE and one server for FTP.

Setup TFTP and PXE server:   

  1.  Login as root:    su –
  2. Install TFTP service:    yum install tftp-server
  3.  Run  vi /etc/xinetd.d/tftp  command and change disable to 'no'         disable = no
  4. Start xinetd service:      service xinetd start
  5. Set xinetd service to start after booting server:   chkconfig xinetd on
  6. Install syslinux, it’s a boot loader:   yum install syslinux
  7. Copy the following files from syslinux directory to the TFTP directory:
            cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
            cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
            cp /usr/share/syslinux/memdisk /var/lib/tftpboot/
            cp /usr/share/syslinux/mboot.c32 /var/lib/tftpboot/
            cp /usr/share/syslinux/chain.c32 /var/lib/tftpboot/


      8. Create the directory for your PXE menus:    mkdir /var/lib/tftpboot/pxelinux.cfg
      9. Create a directory for each pxeboot image:

            mkdir –p /var/lib/tftpboot/images/centos/x86_64/6.3
            mkdir –p /var/lib/tftpboot/images/centos/i386/6.3


     10. Download CentOS 6.x DVD1 from CentOS website
     11. Insert CentOS DVD or mount ISO file to /media directory
     12. Copy vmlinuz and initrd.img from /images/pxeboot/ directory on "DVD 1" to appropriate   release/arch directory like this:

cp /media/CentOS_6.3_Final/images/pxeboot/initrd.img /var/lib/tftpboot/images/centos/x86_64/6.3
cp /media/CentOS_6.3_Final/images/pxeboot/vmlinuz /var/lib/tftpboot/images/centos/x86_64/6.3


     13. Install DHCP server:    yum install dhcp
     14. Configure DHCP:       vi /etc/dhcp/dhcpd.conf
add the following lines to dhcpd.conf and change the ip addresses and domain name accordingly:

option domain-name      "taraghi.com";
option domain-name-servers      khosro.taraghi.com;
default-lease-time 600;
max-lease-time 7200;
authoritative;
#################The followings are mandatory to be able to boot from PXE ############
allow booting;
allow bootp;
option option-128 code 128 = string;
option option-129 code 129 = text;
next-server 10.0.0.150;
filename "/pxelinux.0";

######################################
subnet 10.0.0.0 netmask 255.255.255.0 {
        range dynamic-bootp 10.0.0.151 10.0.0.254;
        option broadcast-address 10.0.0.255;
        option routers 10.0.0.1;
}


As you can see here the ip address range is 10.0.0.151-10.0.0.254 and TFTP/PXE/DHCP server has static ip address of 10.0.0.150
     15. Restart DHCP service:     service dhcp restart
     16. Set dhcpd service to start after booting server:   chkconfig dhcpd on
     17. Adjust firewall setting, run the following commands:

          iptables -A INPUT –p udp --dport 67 -j ACCEPT
          iptables -A INPUT –p udp --dport 68 -j ACCEPT


     18. Creating a menu for OS selection and setting default OS selection after loading PXE:

          vi /var/lib/tftpboot/pxelinux.cfg/default

now, add the following lines to /var/lib/tftpboot/pxelinux.cfg/default

default menu.c32
prompt 0
timeout 30

MENU TITLE PXE Menu

LABEL CentsOS 6.3 x86_64
    MENU LABEL CentOS 6.3 x86_64
    KERNEL images/centos/x86_64/6.3/ vmlinuz
    APPEND initrd=images/centos/x86_64/6.3/initrd.img ks=ftp://10.0.0.153/pub/ks.cfg ramdisk_size=100000


If you have more images, you can also add those images above. Also, 10.0.0.153 is ftp server which contains kickstart file.

Setup FTP server:

  1. Login to FTP server as root:     su- 
  2. Install FTP server:     yum install vsftpd
  3. Insert DVD1 installation of CentOS 6.3 or mount the ISO file to /media
  4. Copy installation files to FTP public directory:
           cp -ar /media/CentOS_6.3_Final/. /var/ftp/pub/
          don’t forget dot “.”, it will copy hidden files as well

     5. Create an empty kickstart file in public directory:

            touch /var/ftp/pub/ks.cfg

     6. Set seliunx for /var/ftp/pub directory
            chcon -R -t public_content_t /var/ftp/
     7. Set up firewall:
            iptables -A INPUT -p tcp -m state --state NEW --dport 21 -j ACCEPT
     8. Save firewall setting:
           /etc/init.d/iptables save
     9. Start FTP service:   
          service vsftpd restart
    10. Set vsftpd to start after rebooting server:
          chkconfig vsftpd on

Setup Kickstart file:

    Edit ks.cfg:  vi  /var/ftp/pub/ks.cfg
    Add following lines to this file. I explain them with comments:

#It starts the installation process
Install
#configure a connection to a FTP server to locate installation files
url --url ftp://10.0.0.153/pub/
#setup language and keyboard
lang en_US.UTF-8
keyboard us

#Get network info from DHCP server
network --device eth0 bootproto dhcp
#setup encrypted root password, you can take out the encrypted password from /etc/shadow file
rootpw --iscrypted $6$NF6F/Yng442eA8oL$c/sHM
#setup firewall and open ssh port 22
firewall --service=ssh
#sets up the Shadow Password Suite
#(--enableshadow), the SHA 512 bit encryption algorithm for password encryption
#(--passalgo=sha512), and authentication with any existing fingerprint reader.
authconfig --enableshadow --passalgo=sha512 --enablefingerprint
#The selinux directive can be set to --enforcing, --permissive, or --disabled
selinux --enforcing
#setup timezone
timezone America/Toronto
#The default bootloader is GRUB. It should normally be installed on the Master
#Boot Record (MBR) of a hard drive. You can include a --driveorder switch to specify
#the drive with the bootloader and an --append switch to specify commands for
#the kernel.
bootloader --location=mbr --driveorder=sda --append=”crashkernel=auto rhgb quiet”
#Clear the Master Boot Record
zerombr yes
#This directive clears all volumes on the sda hard drive. If it hasn’t been used before,
#--initlabel initializes that drive.
clearpart --all --drives=sda --initlabel
#Changes are required in the partition (part) directives that follow.
part /boot --fstype=ext4 --size=500
part / --fstype=ext4 --size=27500
part swap --size=1000
part /home --fstype=ext4 --size=1000

#reboot machine
reboot
#skip answers to the First Boot process
firstboot --disable

%packages
              # This is the actual package install section. The
              # resolvedeps option allows you to make mistakes and
              # have anaconda sort it out for you, i.e. resolving
              # package dependencies.
@ Base
@ Development Tools
mc
wget

#If you want to switch to GUI mode, you have to install the following packages
@ basic-desktop
@ desktop-platform
@ x11
@ fonts
%end


%post
#Adding a user, in this case”khosro”
useradd -m khosro
#Set password for user “khosro”
echo Khosropass123 | passwd --stdin khosro
#expire the password and force the user to enter the new password after first login
passwd -e khosro
#Turn on the GUI mode, if you want to
sed -i 's/id:3:initdefault:/id:5:initdefault:/g' /etc/inittab

And that’s all. As soon as you turn on computer, you machine will go to Automated Installation mode without any user intervention.
 

OpenNMS installation on Windows Platform (Step by Step)

While on an official assignment i was asked to deploy open source Network Management System on the windows platform. While working on the task i got some problems and issues for which i was not able to find solution on internet and i got solution using hit and trial method. And then I thought to write on these problems and their solutions. But at the first step I will write step by step guide to install the of OpenNMS on Windows Platform (i.e. Windows XP or Win Server 2003)

Installation of OpenNMS will consist of 4 steps,

1. Installation of Java Development Kit
2. Installation of PostgreSQL
3. Initialize the Database
4. Adding JRRD library
5. installation of OpenNMS

1. Installation of Java Development Kit
  • Download the latest version of Java SE JDK from Java official website java.sun.com
  • Remember JDK is not just JRE and you need to download Java SE (Standard Edition) and not Java EE or Java ME or Java FX.
  • Run the JDK installer and it will ask for the License Agreement.
  • Click the Accept Button.
  • Click Next and installation will begin.
  • It will prompt to install JRE. Click Next to install JRE and then you will get the final window.
  • Press the Finish button to complete the installation of Java SE JDK.
2. Installation of PostgreSQL
  • Click next to proceed the installation
  • If it is required to change the destination path then select the installation directory, or simply press Next to proceed.
  • If it is required to change the destination Data Directory path then select the directory, or simply press Next to proceed.
  • Enter the password for the Superuser and Service account i.e. POSTGRES and press Next.
  • Enter the Server Listening port (Recommended to use the default port), and press Next.
  • Choose appropriate Locale or use Default locale and press Next.
  • Setup is now ready to install. Press Next to start installation.
  • Wait till the installer continues and finish screen appears.
  • Press the finish button to complete the installation.
3. Initialize the Database
  • If for any reason during the installation default database is not initialized then it can be done manually. Open the command prompt and go to the Bin directory of PostgreSQL. In my case it is "C:\Program Files\PostgreSQL\8.3\bin"
  • Initialize the database by using the following command "initdb -E UTF-8 -U postgres ..\data"
  • If "../data exists but is not empty" message appears then it means the Database is already initialized.
  • Run the Server by going to Start Menu --> Programs --> postgresql 8.X and click Start Server.
  • Follow the same path and click pgAdmin III.
  • Double click on postgresql 8.X (localhost:5432) to connect to the Database.
  • It will prompt for the password. Enter password and press OK button.
  • Select the postgres Database by following Databases --> Postgres.
  • Go to the file menu and select Options.
  • Under the Display tab activate the Languages as shown above, and press OK button.
  • Go back to the database postgres and expand it. Now Languages option will be available under tree. right click Languages and select New Language.
  • From the Name drop down menu select plpgsql and press OK button to add the language.
  • Exit pgAdmin.
4. Adding JRRD Library
  • Now JRRD is no longer distributed as part of OpenNMS. If you want to be compatible with RRDTool instead of JRobin then download JRRD from here.
  • Add library to the path variable.
5.
Installation of OpenNMS
  • Download latest version of standalone-opennms-installer-X.X.X.jar from the OpenNMS download page.
  • When download is finished then double click the Jar installer and it will start installation. If internet explorer saves the file as a ZIP file which contains different folders then it means that you have not installed java SDK.
  • Click Next.
  • Accept the license agreement and press Next button.
  • Select JDK home directory and select Next.
  • Select Installation directory and select Next.
  • Enter postgres user password and press Next.
  • Enter IP range to Discover nodes and press Next.
  • Press Next.
  • When installation completes press Next button.
  • When configuration and database installation completes press Next.
  • Click Done to finish the installation.
  • Open the command prompt and goto the openNMS bin directory. by default it would be C:\program files\opennms\bin
  • If you are installing the JRRD separately and your JRRD.jar file is placed at c:\opennms\lib then run following command
install.bat -disl "c:\opennms\lib"
  • Execute the following command
opennms.bat start
  • open your browser and open the link http://localhost:8980/opennms
  • Use admin user name and admin password to login to the web console.
  • and you are ready to Go with OpenNMS

Install WordPress 3.5.2 Using LAMP or LEMP on RHEL, CentOS & Fedora


Well, on the internet you will find a number of good and better ways to install WordPress on Linux, but this installation guide is prepared for my future reference as well as for those beginners who are new to WordPress and Linux platform. In this installation I will show you’ll how to install latest WordPress 3.5.2 on RHEL 6.4/6.3/6.2/6.1/6/5.8, CentOS 6.4/6.3/6.2/6.1/6/5.8 and Fedora 18,17,16,15,14,13,12 distributions.
Install WordPress in Linux
Install WordPress Using Apache and Nginx
This guide has two way of installation, one is using LAMP (Linux, Apache, MySQL, PHP) and other is LEMP (Linux, Nginx, MySQL, PHP). So, please select your installation method based on your web servers. Before moving ahead let me provide you a little description about WordPress, LAMP & LEMP.

What Is WordPress?

WordPress is an open source and free blogging application and a dynamic CMS (Content Management System) developed using MySQL and PHP. It has huge number of third party plugins and themes. WordPress currently one of the most popular blogging platform available on the internet and used by millions of people across the globe.

What Is LAMP and LEMP?

LAMP (Linux, Apache, MySQL, PHP) and LEMP (Linux, Nginx, MySQL, PHP) is an open source Web application platform that runs on Linux systems. Apache and Nginx both are Web servers, MySQL is RDMS (Relational Database Management System) and PHP is a server side scripting language.
Install WordPress 3.5.2 on RHEL 6.4/6.3/6.2/6.1/6/5.8, CentOS 6.4/6.3/6.2/6.1/6/5.8 and Fedora 18,17,16,15,14,13,12
As I said above the installation method has two ways, one is using Apache and other is Nginx. So I have named it A and B. Those who want to install WordPress on their Apache server they can use A method and those who want to install WordPress using Nginx they can follow method B. In case, if you don’t have LAMP or LEMP setup on your systems, please use the following guides to install it.

Method A: Installing WordPress 3.5.2 for Apache on RHEL, CentOS & Fedora

This Method A installation guide shows you how to install latest WordPress 3.5.2 using LAMP setup on RHEL 6.4/6.3/6.2/6.1/6/5.8, CentOS 6.4/6.3/6.2/6.1/6/5.8 and Fedora 18,17,16,15,14,13,12.

Step 1: Downloading WordPress 3.5.2 for Apache

You must be root user to download the package.
# cd /tmp
# wget http://wordpress.org/latest.tar.gz

Step 2: Extracting WordPress 3.5.2 for Apache

Once the download finishes, run the following command to untar it.
# tar -xvzf latest.tar.gz -C /var/www/html

Step 3: Creating MySQL Database WordPress

Connect to MySQL server and run the following commands to create database and grant privileges.
## Connect to MySQL Server & Enter Password (if any or leave blank)## 
mysql -u root -p
Enter password:

## Creating New User for WordPress Database ##
CREATE USER wordpress@localhost IDENTIFIED BY "your_password_here";

## Create New Database ##
create database wordpress;

## Grant Privileges to Database ##
GRANT ALL ON wordpress.* TO wordpress@localhost;

## FLUSH privileges ##
FLUSH PRIVILEGES;

## Exit ##
exit
Please replace text a shown in Red color with your appropriate Database Name, User and Password. These settings we will required later.

Step 4: Creating Apache VirtualHost for WordPress

Open the file /etc/httpd/conf/httpd.conf with VI editor.
# vi /etc/httpd/conf/httpd.conf
Add the following lines of code at the bottom of the file. Replace the text shown in Red color with your required settings.

  ServerAdmin tecmint@tecmint.com
  DocumentRoot /var/www/html/wordpress
  ServerName wordpress
  ErrorLog /var/log/httpd/wordpress-error-log
  CustomLog /var/log/httpd/wordpress-acces-log common
Next, restart the Apache service to reflect changes.
# service httpd restart
Add the following line to /etc/hosts file.
127.0.0.1  wordpress

Step 5: Configuring WordPress Installation

Copy default wp-config-sample.php to wp-config.php to configure WordPress installation.
# cd /var/www/html/wordpress
# cp wp-config-sample.php wp-config.php
Open wp-config.php file.
# vi wp-config.php
Modify the following database settings as we created in the Step #3 above.
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');

/** MySQL database username */
define('DB_USER', 'username_here');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

Step 6: Finishing WordPress Installation

Open your browser and type any of the following address.
http://wordpress/

http://localhost


http://your-ip
Give your Site Title, Create Admin User, Create Admin Password, Enter Your E-Mail and then click on Install button.
Creating WordPress Admin Login
Creating WordPress Admin Login
Login into your WordPress Dashboard.
WordPress Login Screen
WordPress Login Screen
Enter your WordPress Login details.
Enter WordPress Login Details
Enter WordPress Login Details
Welcome to WordPress Dashboard.
Welcome to WordPress Dashboard
Welcome to WordPress Dashboard
View your New WordPress blog.
View WordPress Blog
View WordPress Blog

Method B: Installing WordPress 3.5.2 for Nginx on RHEL, CentOS & Fedora

Step 1: Creating WordPress Directories for Nginx

# mkdir -p /srv/www/wordpress/public_html
# mkdir /srv/www/wordpress/logs
# chown -R nginx:nginx /srv/www/wordpress

Step 2: Downloading and Extracting WordPress 3.5.2 for Nginx

cd /tmp
# wget http://wordpress.org/latest.tar.gz
# tar -xvzf latest.tar.gz -C /srv/www/wordpress/public_html --strip-components=1

Step 3: Creating MySQL Database WordPress

Connect to MySQL server and run the following commands to create database and grant privileges.
## Connect to MySQL Server & Enter Password (if any or leave blank)## 
mysql -u root -p
Enter password:

## Creating New User for WordPress Database ##
CREATE USER wordpress@localhost IDENTIFIED BY "your_password_here";

## Create New Database ##
create database wordpress;

## Grant Privileges to Database ##
GRANT ALL ON wordpress.* TO wordpress@localhost;

## FLUSH privileges ##
FLUSH PRIVILEGES;

## Exit ##
exit
Please replace text a shown in Red color with your appropriate Database Name, User and Password. These settings we will required later.

Step 4: Creating Nginx VirtualHost For WordPress

If you’ve followed our LEMP guide these directories are already created. In case, if not then please create it by running these commands.
# mkdir /etc/nginx/sites-available
# mkdir /etc/nginx/sites-enabled
Add the following line of code to /etc/nginx/nginx.conf file, After the line that says “include /etc/nginx/conf.d/*.conf.
include /etc/nginx/sites-enabled/*;
Next create Nginx virtualhost file for WordPress.
# vi /etc/nginx/sites-available/wordpress
Add the following content to /etc/nginx/sites-available/wordpress file.
server {
    server_name wordpress;
    access_log /srv/www/wordpress/logs/access.log;
    error_log /srv/www/wordpress/logs/error.log;
    root /srv/www/wordpress/public_html;

    location / {
        index index.php;
    }

    # Disable favicon.ico logging
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    # Allow robots and disable logging
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # Enable permalink structures
    if (!-e $request_filename) {
        rewrite . /index.php last;
    }

    # Handle php requests
    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /srv/www/wordpress/public_html$fastcgi_script_name;
    }

    # Disable static content logging and set cache time to max
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
    }

    # Deny access to htaccess and htpasswd files
    location ~ /\.ht {
        deny  all;
    }
}
Create symlink for sites enabled directory.
# cd /etc/nginx/sites-enabled/
# ln -s /etc/nginx/sites-available/wordpress
Restart the Nginx server to reflect changes.
# service nginx restart
Add the following line to /etc/hosts file.
127.0.0.1  wordpress

Step 5: Configuring WordPress Installation

Copy default wp-config-sample.php to wp-config.php to configure WordPress installation.
# cd /srv/www/wordpress/public_html
# cp wp-config-sample.php wp-config.php
Modify the following database settings as we created in the Step #3 above.
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');

/** MySQL database username */
define('DB_USER', 'username_here');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
Now follow STEP 6 above for the WordPress installation.
In case, if you are having any trouble while installing please do let me know via comments and don’t forget to share this article with your friends.

How to set up an Ldap Server on Ubuntu 12.04 LTS

Today I will show you how to set up an ldap server on Ubuntu 12.04 LTS.


First we need to install the packages we need so in a terminal type:
sudo apt-get install slapd ldap-utils
During installation you will be asked for an ldap administrator password.  You should choose one and then retype it.
The configurations example that follows uses a FQDN of comtech.com. You should change this to the FQDN of your organisation.
Now we need to add some additional schema files. In a terminal enter:
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/cosine.ldif
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/nis.ldif
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/inetorgperson.ldif
Now make a file called backend.comtech.com.ldif somewhere on your system and add the following configuration to it.
# Load dynamic backend modules
dn: cn=module,cn=config
objectClass: olcModuleList
cn: module
olcModulepath: /usr/lib/ldap
olcModuleload: back_hdb.la
# Database settings
dn: olcDatabase=hdb,cn=config
objectClass: olcDatabaseConfig
objectClass: olcHdbConfig
olcDatabase: {1}hdb
olcSuffix: dc=comtech,dc=com
olcDbDirectory: /var/lib/ldap
olcRootDN: cn=admin,dc=comtech,dc=com
olcRootPW: secret
olcDbConfig: set_cachesize 0 2097152 0
olcDbConfig: set_lk_max_objects 1500
olcDbConfig: set_lk_max_locks 1500
olcDbConfig: set_lk_max_lockers 1500
olcDbIndex: objectClass eq
olcLastMod: TRUE
olcDbCheckpoint: 512 30
olcAccess: to attrs=userPassword by dn=”cn=admin,dc=comtech,dc=com” write by anonymous auth by self write by * none
olcAccess: to attrs=shadowLastChange by self write by * read
olcAccess: to dn.base=”" by * read
olcAccess: to * by dn=”cn=admin,dc=comtech,dc=com” write by * read
We now need to add the LDIF to the directory so in a terminal type:
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f  backend.comtech.com.ldif
Now create a file called frontend.comtech.com.ldif somewhere on your system and add the following configuration to it.
# Create top-level object in domain
dn: dc=comtech,dc=com
objectClass: top
objectClass: dcObject
objectclass: organization
o: Comtech
dc: comtech
description: Comtech LDAP Configuration
# Admin user.
dn: cn=admin,dc=comtech,dc=com
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
description: LDAP administrator
userPassword: (ADD YOUR OWN PASSWORD HERE)
dn: ou=people,dc=comtech,dc=com
objectClass: organizationalUnit
ou: people
dn: ou=groups,dc=comtech,dc=com
objectClass: organizationalUnit
ou: groups
dn: uid=bob,ou=people,dc=comtech,dc=com
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: shadowAccount
uid: Bob
sn: Wates
givenName: Bob
cn: Bob Wates
displayName: Bob Wates
uidNumber: 1000
gidNumber: 10000
userPassword: password
gecos: Bob Wates
loginShell: /bin/bash
homeDirectory: /home/bob
shadowExpire: -1
shadowFlag: 0
shadowWarning: 7
shadowMin: 8
shadowMax: 999999
shadowLastChange: 10877
mail: bob.wates@comtech.com
postalCode: CF24
l: Cardiff
o: Comtech
mobile: +44 (0)7 xx xx xx xx
homePhone: +44 (0)1 xx xx xx xx x
title: System Administrator
postalAddress:
initials: BW
dn: cn=comtech,ou=groups,dc=comtech,dc=com
objectClass: posixGroup
cn: comtech
gidNumber: 10000
Now we need to add the entries to the LDAP directory.  In a terminal type:
sudo ldapadd -x -D cn=admin,dc=comtech,dc=com -W -f frontend.comtech.com.ldif
You will be asked for the ldap administration password.  This is the password in the admin section of the frontend.comtech.com.ldif file.
All that is left to do is to test the configuration so in a terminal type:
ldapsearch -xLLL -b “dc=comtech,dc=com” uid=bob sn givenName cn
If your files are configured correctly then you get the following output.
dn: uid=bob,ou=people,dc=comtech,dc=com
cn: Bob Wates
sn: Wates
givenName: Bob

Part 1: Installing puppet 2.6.1 on CentOS with YUM/RPM


Installing Puppetmaster 2.6.1

Assuming, like me, the thought of letting rubygems vommit all over your filesystem is not a pleasant one, then how to get the latest puppet 2.6.1 installed on CentOS 5.5 with yum isn’t very clear. Things may differ on other peoples systems, but the below worked for me.


Set up yum repositories.

Do this on both the client and the server

Add the following files and save them to /etc/yum.repos.d/


puppet.repo
[puppetlabs]
name=Puppet Labs Packages
baseurl=http://yum.puppetlabs.com/base/
enabled=0
gpgcheck=0


epel.repo
[epel]
name=Extra Packages for Enterprise Linux 5 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
failovermethod=priority
enabled=0
gpgcheck=0
 
 
[epel-puppet]
name=epel puppet
baseurl=http://tmz.fedorapeople.org/repo/puppet/epel/5/$basearch/
enabled=0
gpgcheck=0


ruby.repo
[ruby]
name=ruby
baseurl=http://repo.premiumhelp.eu/ruby/
gpgcheck=0
enabled=0


Note that we include ruby and puppetlabs as the next steps in this tutorial will be to configure puppet and install puppet-dashboard. We want to upgrade to ruby 1.8.6 in order to run puppet-dashboard, doing this now will save you some pain down the line.

Upgrade Ruby to 1.8.6

Do this on both the client and the server

As mentioned above, use the ruby repo to upgrade.

punch# yum --enablerepo="ruby" update ruby
[...]
==============================================================
 Package            Arch          Version               Repository     Size
==============================================================
Updating:
 ruby               i686          1.8.6.111-1           ruby          525 k
Updating for dependencies:
 ruby-libs          i686          1.8.6.111-1           ruby          2.6 M
 
Transaction Summary
===============================================================
Install       0 Package(s)
Upgrade       2 Package(s)
 
Total download size: 3.1 M
Is this ok [y/N]: y
[...]

Install Puppet Server

On your puppetmaster server:
punch# yum --enablerepo=epel,epel-puppet install puppet-server
 
[...]
Installing:
 puppet-server        noarch      2.6.1-0.3.rc3.el5       epel-puppet       20 k
Installing for dependencies:
 facter               noarch      1.5.8-0.2.rc2.el5       epel-puppet       55 k
 libselinux-ruby      i386        1.33.4-5.5.el5          base              60 k
 puppet               noarch      2.6.1-0.3.rc3.el5       epel-puppet      818 k
 ruby-augeas          i386        0.3.0-1.el5             epel              19 k
 ruby-shadow          i386        1.4.1-7.el5             epel             9.5 k
 
Install       6 Package(s)
Upgrade       0 Package(s)
 
Total download size: 981 k
Is this ok [y/N]: y
[...]


On your puppet client
judy# yum --enablerepo="epel,epel-puppet" install puppet
 
[...]
Installing:
 puppet            noarch   2.6.1-0.3.rc3.el5      epel-fedora   818 k
Installing for dependencies:
 facter            noarch   1.5.8-0.2.rc2.el5      epel-fedora    55 k
 libselinux-ruby   i386     1.33.4-5.5.el5         base           60 k
 ruby-augeas       i386     0.3.0-1.el5            epel           19 k
 ruby-shadow       i386     1.4.1-7.el5            epel          9.5 k
Install       5 Package(s)
Upgrade       0 Package(s)
 
Total download size: 961 k
Is this ok [y/N]: y

That’s it, in part 2 and 3 we will install our client and server and install dashboard.


Part 2: Puppet 2.6.1, configure puppetmaster and puppetd

Configure Puppetmaster

For installing puppetmaster 2.4.1 on CentOS please click here for Part 1


In Part 1 we covered installing the Puppetmaster and Puppetd packages on Centos 5.5. We will now configure a very basic client/server model to serve the /etc/resolv.conf file to our client. Simple enough!

Create your first module

Our first module will be called networking::resolver, it’s job will be to push out a resolve.conf file to clients.


Create the directory structure under /etc/puppet
punch# cd /etc/puppet
punch# mkdir modules
punch# mkdir modules/networking
punch# mkdir modules/networking/files
punch# mkdir modules/networking/manifests
punch# mkdir files

Create your resolv.conf file
punch# vi modules/networking/files/resolv.conf
Create your module manifest
punch# vi modules/networking/manifests/init.pp
class networking {
    # Here you can add stuff to be inhereted by your networking classes
    # We won't bother for this demonstration, but just for show!
}
 
class networking::resolver inherits networking { 
          file { "/etc/resolv.conf": 
              ensure => present,
              source => "puppet:///modules/networking/resolv.conf",
              group   => "root",
              owner => "root",
              mode  => "0755"
          }
}

Configure your site and nodes

Create a minimal site.pp
punch# vi manifests/site.pp
import "nodes"
import "templates"
 
filebucket { main: server => puppet }


Create a tempates file
punch# vi manifests/templates.pp
class baseclass { 
        include networking::resolver
}
 
node default { 
        include baseclass
}

Create your node file


Don’t forget to replace judy.craigdunn.org with the fqdn of your client server
punch# vi manifests/nodes.pp
node 'basenode' { 
  include baseclass
}
 
node 'judy.craigdunn.org' inherits basenode { 
}

Set up puppetmaster parameters



Create default configuration


This is a minimal puppet.conf file, a more detailed file can be produced with puppetmasterd –genconfig


The autosign will automatically sign certs for new clients, this is discouraged in a production environment but useful for testing. For information on running puppetmaster without autosign see the puppetca documentation.
punch# vi puppet.conf
[main]
    # The Puppet log directory.
    # The default value is '$vardir/log'.
    logdir = /var/log/puppet
 
    # Where Puppet PID files are kept.
    # The default value is '$vardir/run'.
    rundir = /var/run/puppet
 
    # Where SSL certificates are kept.
    # The default value is '$confdir/ssl'.
    ssldir = $vardir/ssl
 
[agent]
    # The file in which puppetd stores a list of the classes
    # associated with the retrieved configuratiion.  Can be loaded in
    # the separate ``puppet`` executable using the ``--loadclasses``
    # option.
    # The default value is '$confdir/classes.txt'.
    classfile = $vardir/classes.txt
 
    # Where puppetd caches the local configuration.  An
    # extension indicating the cache format is added automatically.
    # The default value is '$confdir/localconfig'.
    localconfig = $vardir/localconfig
    report = true
 
[master]
    autosign = true

Set permissions for your fileserver.

Note that this allows everything, you should restrict this in a production environment.
punch# vi fileserver.conf
[files]
  path /etc/puppet/files
  allow *
 
[modules]
  allow *
 
[plugins]
  allow *

Start puppetmaster
punch# service puppetmaster start
Starting puppetmaster:                                     [  OK  ]


The puppet client



Configure puppetd
On your client, edit puppet.conf and add the following in the [agent] section, remembering to change punch.craigdunn.org to the fqdn of your Puppetmaster.
judy# vi /etc/puppet/puppet.conf
[agent]
    server = punch.craigdunn.org
    report = true
    listen = true

Allow puppetrunner


Create a file called namespaceauth.conf and add the following, note in a production environment this should be restricted to the fqdn of your puppet master
judy# vi /etc/puppet/namespaceauth.conf
[puppetrunner]
allow *

Start puppetd
judy# service puppet start

View pending changes


Use –test along with –noop to do a dry run to view the changes that puppetd will make
judy# puppetd --noop --test
[...]
notice: /Stage[main]/Networking::Resolver/File[/etc/resolv.conf]/content: is 
{md5}e71a913327efa3ec8dae8c1a6df09b43, should be {md5}24b6444365e7e012e8fdc5f302b56e9c (noop)
[...]


Now you can run puppetd without –noop to pull in your new resolv.conf file


This is a very basic demonstration of creating a server/client pair with puppet. There is much more documentation on configuring and managing puppet here


Part 3: Installing puppet-dashboard on CentOS / Puppet 2.6.1

Puppet Dashboard

Puppet dashboard is a fairly new app with loads of future potential and is great for monitoring your puppet estate. This is a quick guide to getting it running on puppet 2.6.1. Be sure you have the correct yum repos and ruby versions installed, see Part 1 and Part 2 for more details.



Install the puppet-dashboard package.

punch# yum --enablerepo=puppetlabs,ruby,epel install puppet-dashboard
[...]
Installing for dependencies:
 mysql                        i386               5.0.77-4.el5_5.3            
 ruby-irb                     i686               1.8.6.111-1                 
 ruby-mysql                   i686               2.7.4-1                     
 ruby-rdoc                    i686               1.8.6.111-1                 
 rubygem-rake                 noarch             0.8.7-2.el5                 
 rubygems                     noarch             1.3.1-1.el5                 
Install       7 Package(s)
Upgrade       0 Package(s)
 
Total download size: 11 M
Is this ok [y/N]: y
[...]

Create a MySQL database for puppet-dashboard

Create a database for puppet-dashboard to use and set up a user with all privileges to use it. This can be done on a seperate host.
mysql> CREATE DATABASE puppetdash;
Query OK, 1 row affected (0.00 sec)
 
mysql> GRANT ALL PRIVILEGES ON puppetdash.* TO puppet@'%' IDENTIFIED BY 'punchandjudy';
Query OK, 0 rows affected (0.00 sec)

Configure database.yaml

cd /usr/share/puppet-dashboard
vi config/database.yaml
Add your database parameters to the development section, note that host: can be ommitted if you are using local sockets to connect to MySQL.
development:
  host: professor.craigdunn.org
  database: puppetdash
  username: puppet
  password: punchandjudy
  encoding: utf8
  adapter: mysql

Migrate the database
punch# rake RAILS_ENV=development db:migrate
[...]
(in /usr/share/puppet-dashboard)
==  BasicSchema: migrating ====================================================
-- create_table(:assignments, {:force=>true})
   -> 0.0072s
-- create_table(:nodes, {:force=>true})
   -> 0.0030s
-- create_table(:services, {:force=>true})
   -> 0.0026s
==  BasicSchema: migrated (0.0132s) ===========================================
[...]

Copy reports module to site_ruby



I hate doing this but puppetmasterd explicitly looks for reports in puppet/reports and so far I haven’t found a clean workaround to tell it to look in /usr/share/puppet-dashboard for it. If anyone knows of a way, please email me.
punch# cp /usr/share/puppet-dashboard/ext/puppet/puppet_dashboard.rb /usr/lib/ruby/site_ruby/1
.8/puppet/reports

Edit your puppet.conf

Include the following in the [master] section, changing punch.craigdunn.org to your puppet server
[master]
reports = puppet_dashboard,store
reportdir = /var/lib/puppet/reports
reporturl = http://punch.craigdunn.org:3000/reports

Restart puppetmaster and start puppet-dashboard

punch# service puppetmaster restart
Stopping puppetmaster:                                     [  OK  ]
Starting puppetmaster:                                      [  OK  ]
punch# service puppet-dashboard start
Starting puppet-dashboard:                                 [  OK  ]

Test web GUI

Go to the following link in your browser (replacing the hostname with your fqdn)
http://punch.craigdunn.org:3000/

Configure the client

Edit puppet.conf

Make sure the following things are set in the [agent] section of puppet.conf on your client node.
judy# vi /etc/puppet/puppet.conf
[agent]
    report = true


Run puppet in noop mode on the client
judy# puppetd --noop --test

Refresh browser

If all has gone well, you should now see your reports in puppet dashboard for your client node.