Puppet: Icinga SSH client module

Enable Pluginsync on client
sed -i '/\[main\]/a\pluginsync=true\' /etc/puppet/puppet.conf

create Nullmailer module
http://www.panticz.de/Puppet-Nullmailer-module

create module structure
mkdir -p /etc/puppet/modules/icinga_ssh_client/manifests
mkdir -p /etc/puppet/modules/icinga_ssh_client/files

download module definiction
<?php
$URL="https://raw.githubusercontent.com/panticz/puppet/master/modules/icinga_ssh_client/init.pp";
echo "wget -q $URL -O /etc/puppet/modules/icinga_ssh_client/manifests/init.pp";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

add include to your client in /etc/puppet/manifests/site.pp
node "client1.local" inherits default {
...
include icinga_ssh_client
include nullmailer
...
}

Example: /etc/puppet/modules/icinga_ssh_client/files/id_rsa.pub
ssh-rsa ADAAB3NzaC3yc2EAAAADAEulgMUFyT9y2DaZYXHUdLWvkE9TKE+OVO8jYhmGG2BMmL5Ad3D+flpTMQfpp7EVJg2vTBSiVG4kCVicvb nagios@icinga

# (auto) create new host / object on icinga
cat /etc/icinga/objects/puppet.cfg
define host {
host_name puppet
address 192.168.1.173
use generic-host
hostgroups debian
}

TODO
# (auto) remove old hosts from /var/lib/nagios/.ssh/known_hosts on icinga
# (auto) import new host to /var/lib/nagios/.ssh/known_hosts on icinga

# add raid check
#apt-get install -y hddtemp
#wget -q "http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=341&cf_id=24" -O /usr/lib/nagios/plugins/check_hddtemp
#chmod go+x /usr/lib/nagios/plugins/check_hddtemp

Links
http://serverfault.com/questions/411245/puppetlabs-file-line-type-not-working
http://serverfault.com/questions/238708/adding-lines-to-etc-profile-with-puppet

Linux: Install Puppet server (puppetmaster)

# configure DNS to resolve "puppet" to your puppetmaster

# install
apt-get install -y puppetmaster

# allow acces to files (TODO)
sed -i 's|\# allow \*.example.com| allow \*|g' /etc/puppet/fileserver.conf
cat <> /etc/puppet/fileserver.conf

[modules]
allow *
EOF

# configure clients
cat < /etc/puppet/manifests/site.pp
node default {
notify { "Your are connected to puppet.lab": }
}

node "dev2.lab" inherits default {
include ntp
include apache
include php5
include icinga_ssh_client
}
EOF

# configure client autosign in
echo "*.lab" >>

Debian: Install Puppet on client

Install Puppet client (agent)
<?php
$URL="https://raw.githubusercontent.com/panticz/installit/master/install.puppet-client.sh";
echo "wget $URL -O - | bash -";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

enabling pluginsync
sed -i '/\[main\]/a\pluginsync=true\' /etc/puppet/puppet.conf
sed -i '/\[main\]/a\runinterval=10\' /etc/puppet/puppet.conf

test connection to pupet server
puppet agent --test
OR
puppet agent --test --server puppet.lab --waitforcert 60 --verbose
#--no-daemonize

change update interwal in seconds (default 30min.)
vi /etc/puppet/puppet.conf
[main]
runinterval=300

puppet version
puppet --version

Links
http://docs.puppetlabs.com/learning/agent_master_basic.html

Puppet

Installation
1. Install and configure Puppet on server (/etc/puppet/fileserver.conf)
http://www.panticz.de/install-puppet-server-puppetmaster
2. On client: Install Puppet client
http://www.panticz.de/install-puppet-client
3. On client: apply for certificate (puppet agent --test)
4. On server: confirm certificate (puppet cert sign dev2.lab)
5. On server: configure modules (/etc/puppet/modules/MODULE_NAME/manifests/init.pp)
6. On server: prepare files (/etc/puppet/modules/MODULE_NAME/files)
7. Configure clients (/etc/puppet/manifests/site.pp)

Magento: Create top category offer box

Create a top category offer box on Magento front page linked to a category and filled with one of selected products from a hidden category.

/var/www/app/design/frontend/default/default/template/catalog/product/top-category.phtml
<?php
$URL="http://www.panticz.de/sites/default/files/magento/home/top-category.phtml";
echo "Download: $URL";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

debian_xen_host.cfg

# /etc/icinga/objects/debian_xen_host.cfg

define host {
host_name srv1
address 192.168.1.1
use generic-host
hostgroups raid1, debian
}

define service {
use generic-service
host_name srv1
service_description ssh_check_mem
check_command ssh_check_mem!20!10
}

define service {
use generic-service
host_name srv1
service_description ssh_check_load
check_command ssh_check_load!15!10!5!30!25!20
}

define service {
use generic-service
host_name srv1
service_description ssh_check_procs
check_command ssh_check_p

extinfo_icinga.cfg

# /etc/icinga/objects/extinfo_icinga.cfg

# icon path
# /usr/share/icinga/htdocs/images/logos/base/

define hostextinfo{
hostgroup_name snom
icon_image base/phone.png
icon_image_alt VoIP phone
}

define hostextinfo{
hostgroup_name mx
icon_image base/mail.png
icon_image_alt Mailserver
}

define hostextinfo{
hostgroup_name printer
icon_image base/printer.png
icon_image_alt Printer
}

define hostextinfo{
hostgroup_name debian
icon_image base/debi