Saturday 5 August 2017

EX405 - Red Hat Certificate of Expertise in Configuration Management with Puppet

As per Red Hat Training team (08/05/2017):
The Red Hat Enterprise Linux version for DO405 is RHEL 7,Satellite version is 6 and Puppet version is 3.
....thanks a lot for the info about the minor version....

From Red Hat website Ex405 :Red Hat Certificate of Expertise in Configuration Management with Puppet

Study points for the exam

To help you prepare, the exam objectives highlight the task areas you can expect to see covered in the exam. Red Hat reserves the right to add, modify, and remove exam objectives. Such changes will be made public in advance.
Candidates should be able to perform these tasks:
  • Install and configure Puppet.
  • Create and maintain Puppet manifests.
    • Create new Puppet manifests.
    • Debug existing Puppet manifests.
  • Create Puppet modules.
    • Create reusable modules.
    • Create modules with classes, name spaces, variables, and conditionals.
    • Create modules that install software on target nodes and deploy configuration files.
  • Use facter to obtain system information.
    • Create custom facts.
    • Use facts to change Puppet behavior.
  • Create Git repositories.
    • Create and perform simple management of a Git repository.
    • Add files to a Git repository.
    • Apply changes and commit changed files to a Git repository.
  • Implement Puppet in a Red Hat Satellite 6 environment.
As with all Red Hat performance-based exams, configurations must persist after restart without intervention.

Install Puppet Server:

# firewall-cmd --permanent --add-service=https
# firewall-cmd --permanent --add-port={8140/tcp,61613/tcp}
# firewall-cmd --reload
  • Add your FQDN into /etc/hosts
  • Unzip the install and from the folder run
# ./puppet-enterprise-installer
  • After confirming the Install you'll be asked to open a browser and connect to https://<puppetmaster-hostname>:3000 to continue the install
  • Select Monolithic install (all in one server) and follow the instructions

Install Puppet nodes:

  • Download and Install the Puppet Agent from the PuppetMaster by running the following on your node:
# curl -k https://<puppetmaster-hostname>:8140/packages/current/install.bash | sudo bash
  • Once installed the agent won't work until his certificate is signed.

Register Puppet nodes to a Puppet server:

  •  Go to the PuppetMaster and note on the TOP RIGHT "1 Node Request" 

  • Click on "1 Node Request" and then "Accept" the node
  • Test the agent by running
# puppet agent -t

Create new Puppet manifests:

  •  On the PuppetMaster go to the modules dir 
# cd /etc/puppetlabs/puppet/environments/production/modules/
  • Create a basic module structure
# mkdir -p helloworld/manifest
# cd helloworld/manifest
# vi init.pp

class helloworld{

  notify { 'hello, world!': }

}
 

# vi motd.pp

class helloworld::motd{

file{ '/etc/motd':
  owner   => 'root',
  group   => 'root',
  mode    => 0644,
  content => "hello, world!\n",
  }
}



Tuesday 17 January 2017

No memory cache has been configured.


To fix this error make sure you have latest php5-apcu installed:

sudo apt-get install php5-apcu

edit config.php

sudo vi /nextcloud/config/config.php

add the following line in your directive

'memcache.local' => '\OC\Memcache\APCu',

restart the webserver

sudo service nginx restart

php does not seem to be setup properly to query system environment variables. The test with getenv("PATH") only returns an empty response.

To fix this error edit php5-fpm config file

sudo vi /etc/php5/fpm/pool.d/www.conf

uncomment the following line


env[PATH] = /usr/local/bin:/usr/bin:/bin

and restart php5-fpm

sudo service php5-fpm restart

Thursday 29 December 2016

RPI - Dynamic IP address

Create your own website using a Free Dynamic DNS service ( I used NoIP)

Once registered and installed the client on your Raspberry Pi you can create a startup script to automatically restart the client after a RPI reboot


  • Create a script in /etc/init.d/noip

# sudo vi /etc/init.d/noip

      copy and paste the following:

#! /bin/sh
# /etc/init.d/noip

### BEGIN INIT INFO
# Provides:     noip
# Required-Start: networking
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start noip at boot time
# Description: Start noip at boot time
### END INIT INFO

# . /etc/rc.d/init.d/functions  # uncomment/modify for your killproc

DAEMON=/usr/local/bin/noip2
NAME=noip2
NOIP=`ps -ef|grep -q [n]oip2`
STATUS=$?

test -x $DAEMON || exit 0

case "$1" in
    start)
    echo -n "Starting dynamic address update: "
    start-stop-daemon --start --exec $DAEMON
    echo "noip2."
    ;;
    stop)
    echo -n "Shutting down dynamic address update:"
    start-stop-daemon --stop --oknodo --retry 30 --exec $DAEMON
    echo "noip2."
    ;;

    restart)
    echo -n "Restarting dynamic address update: "
    start-stop-daemon --stop --oknodo --retry 30 --exec $DAEMON
    start-stop-daemon --start --exec $DAEMON
    echo "noip2."
    ;;

    status)
        if [ ${STATUS} -eq "0" ];then
        echo "noip2 running..."
        else
        echo "noip2 Not running..."
        fi
    ;;

    *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
esac
exit 0
  • Set exec permissions
# sudo chmod 755 /etc/init.d/noip
  • Add script to Startup/Shutdown
# sudo update-rc.d noip defaults

Raspberry Pi - quick update script


Quick and easy script to upgrade Raspberry Pi
#! /bin/bash

if [ "$EUID" -ne 0 ]
then
echo "Please run as root"
exit 1
fi

#First Clean Up
echo "First Clean Up old downloaded and no longer required packages......."
apt-get clean
apt-get -y autoremove
echo "Clean Up Done"
echo ""

#Update package list
echo "Update your system's package list....."
apt-get update
echo "Package list updated"
echo ""

#Upgrade all installed packages
echo "Update all installed packages to latest versions....."
apt-get -y dist-upgrade

echo "Update Completed rebooting system...."
reboot

Monday 19 May 2014

Find....

  • Find and compress files older then X days
find /path/to/files/ -type file -mtime 1 -exec gzip {} \;

1 means 24 hours old
-1 means less than 24 hours old
+0 means more than 24 hours old
+1 means more than 48 hours old

  • Find and compress files older then 5 days and exclude files already compressed (ext .gz)

find /path/to/files/ \( ! -name *.gz \) -type file -mtime +5 -exec gzip {} \;

Wednesday 24 October 2012

How to create LVM on HP-UX

HP-UX


  • Create a new LVM
  • Extend an existing LVM

Create a new LVM


         STEPS:

      • Create the Physical Volume
      • Create the Volume Group
      • Create a Logical Volume
      • Create the File System


1.Check the list of devices, look for a new disk. The new devices will have a hardware path, but no device file associated with it  (no /dev/dsk/c*t*d* /dev/rdsk/c*t*d*)

# ioscan - fnkc disk

2.Create the device special file for the new hardware path

# insf

3.Check the list of devices to very the special files have been created

# ioscan -fnkC disk

4.Create the PV

# pvcreate /dev/rdsk/c*t*d*    (use -B to have a PV boot capable)

5.Create the Volume Group directory

# mkdir /dev/vgXX

6.Create the group file

Determine the minor number to use:

# ls -l /dev/*/group | sort +5

Choose the next unused number (0x0X0000)

# mknod /dev/vgXX/group c 64 0x0X0000

7.Create the volume group

# vgcreate -s 16 /dev/vgXX /dev/dsk/cxtxdx /dev/dsk/cxtydx

# vgextend /dev/vgxx /dev/dsk/cxtzdx

8.Create the Logical Volume

Check the space available on the VG

# vgdisplay -v vgXX ( Multiply the "Free PE" by "PE Size (MBytes)" to get spare capacity in MB of the volume group )

create the LV

# lvcreate -L 100 -n LVname /dev/vgXX

check the created LV

# vgdisplay -v LVname 

9.Create the FileSystem

# mkfs -F vxfs -o largefiles /dev/vgXX/LVname

10.Create the Mount Point

# mkdir -p <full path to mountpoint>

11.Set the proper ownership and permissions on the mount point

# chown owner:group /<mount point>
# chmod XXX /<mount point>

12.Mount the File System

Edit /etc/fstab using vi and add the proper entry

/dev/vgXX/LVname  /mountpoint vxfs rw,suid,largefiles 0 2

# mount /mountpoint

Check everything is ok

# bdf

DONE



Extend an existing LVM

          STEPS:
      • Add a disk to VG
      • Extend the LV
      • Extend the FS

1.Any devices that are on the ioscan, but are NOT on the vgdisplay are available for use

To get the list of devices:

# ioscan -fnC disk | sed 1,2d | xargs -n 10 | grep HITACHI

To get the list of disks used in the VG's

# vgdisplay -v | grep  "PV Name"

Compare the two and find unused disks 

2.Add unused disks to VG

# pvcreate /dev/rdsk/unused_cxtxdx

# vgextend /dev/vgxx /dev/dsk/unused_cxtxdx


3.Extend the Logical Volume

# lvextend -L XXXMb /dev/vgXX/LVname

4.Extend File System

First kill all process locking the FS then unmount the FS finally extend the FS and mount again the FS

# fuser -ku /dev/vgXX/LVname
# umount /dev/vgXX/LVname 
# extendfs /mountpoint
# mount /mountpoint


DONE