Puppet modules

Puppet module repository
http://forge.puppetlabs.com/

# search for module
puppet module search ntp

# install module
puppet module install ntp

Links
http://docs.puppetlabs.com/references/latest/type.html

Puppet: Configure repository

# add reposiory
wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb
dpkg -i puppetlabs-release-precise.deb
apt-get update
 
# OR
cat <<EOF> /etc/apt/sources.list.d/puppetlabs.list 
deb http://apt.puppetlabs.com precise main
deb-src http://apt.puppetlabs.com precise main
deb http://apt.puppetlabs.com precise dependencies
deb-src http://apt.puppetlabs.com precise dependencies
EOF
 
# Links
http://docs.puppetlabs.com/guides/puppetlabs_package_repositories.html#for-debian-and-ubuntu
http://docs.puppetlabs.com/guides/puppetlabs_package_repositories.html#for-debian-and-ubuntu

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 <<EOF>> /etc/puppet/fileserver.conf
 
[modules]
allow *
EOF
 
# configure clients
cat <<EOF> /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)
wget https://raw.githubusercontent.com/panticz/installit/master/install.puppet-client.sh -O - | bash -

#!/bin/bash

# ensure that this script is run by root
if [ $(id -u) -ne 0 ]; then
  sudo $0
  exit
fi

# install
apt-get install -qq -y puppet
 
# configure to autostart puppet on boot
if [ $(puppet --version | cut -d "." -f1) -ge 3 ]; then
  # puppet 3.x
  /etc/init.d/puppet stop
  puppet agent --enable
else
  # puppet 2.x
  [ -f /etc/default/puppet ] && sed -i 's|START=no|START=yes|g' /etc/default/puppet
fi

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
Download: http://www.panticz.de/sites/default/files/magento/home/top-category.phtml

<?php
$offer = array(
    array('TVs', '/shop/tv.html', 24231),
    array('Computer', '/shop/computer.html', 24238),
    array('Cameras', '/shop/cameras.html', 24245),
    array('RAM', '/shop/ram.html', 24244),
    array('HDD', '/shop/hdd.html', 24243)
);
?>

<div class="category-products">
    <ul class="products-grid">
    <?php for($i = 0; $i < count($offer); $i++): ?>
        <li class="item <?php if($i == 0): ?> first <?php elseif($i - 1 == count($offer)): ?> last <?php endif; ?>">
            <?php $offer_name = $offer[$i][0]; ?>
            <?php $offer_url = $offer[$i][1]; ?>
            <?php $offer_category = $offer[$i][2]; ?>

            <h4><a href="<?php echo $offer_url; ?>"><?php echo $offer_name; ?></a></h4>
            <?php
                $catagory_model = Mage::getModel('catalog/category')->load($offer_category);
                $collection = Mage::getResourceModel('catalog/product_collection');
                $collection->addCategoryFilter($catagory_model);
                $collection->addAttributeToFilter('status', 1);
                $collection->getSelect()->order('rand()');   
                $collection->addStoreFilter();
                $collection->setPageSize(1);
                $collection->setCurPage(1);
            ?>
            <?php if(!empty($collection)): ?>
                <?php foreach ($collection as $_product): ?>
                    <?php $_product = Mage::getModel('catalog/product')->setStoreId($this->store_id)->load($_product->getId()); ?>
                    <?php $_url = $_product->getSku(); ?>
                    <a href="/<?php echo $_url ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135,73); ?>" width="135" height="73" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" /></a>
                    <h2 class="product-name">
                        <a href="/<?php echo $_url ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a>
                    </h2>
                <?php endforeach ?>
            <?php endif ?>
        </li>
    <?php endfor ?>
    </ul>
</div>

sipphone1.cfg

# /etc/icinga/objects/sipphone1.cfg
 
define host {
    host_name sip.phone1
    alias VoIP Phone 1
    address pako.sip
    use generic-host
    contact_groups admins
    hostgroups snom
}

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

service.cfg

wget -q https://raw.githubusercontent.com/panticz/icinga/master/objects/service.cfg -O /etc/icinga/objects/service.cfg

define service {
  use generic-service
  hostgroup_name snom 
  service_description check_snom_registration_status
  check_command check_snom_registration_status!1
}

define service {
  use generic-service
  hostgroup_name snom
  service_description check_snom_firmware_version
  check_command check_snom_firmware_version!8.7.3.19 1.1.3-u
}

define service {
  use generic-service
  hostgroup_name mx
  service_description check_imap
  check_command check_imap
}

define service {
  use generic-service
  hostgroup_name mx
  service_description check_smtp
  check_command check_smtp
}

define service {
  use generic-service
  hostgroup_name mx
  service_description ssh_check_mailq
  check_command ssh_check_mailq!3!10
}

define service {
  use generic-service
  hostgroup_name raid1
  check_interval 1
  service_description ssh_check_raid
  check_command ssh_check_raid
}

define service {
  use generic-service
  hostgroup_name raid1
  service_description ssh_check_ide_smart_sda
  check_command ssh_check_ide_smart!sda
}

define service {
  use generic-service
  hostgroup_name raid1
  service_description ssh_check_ide_smart_sdb
  check_command ssh_check_ide_smart!sdb
}

define service {
  use generic-service
  name ssh_check_hddtemp_sda
  hostgroup_name raid1, raid5
  service_description ssh_check_hddtemp_sda
  check_command ssh_check_hddtemp!sda!42!50
}

define service {
  use generic-service
  name ssh_check_hddtemp_sdb
  hostgroup_name raid1, raid5
  service_description ssh_check_hddtemp_sdb
  check_command ssh_check_hddtemp!sdb!42!50
  #_HDDTEMP_W 30
  #check_command ssh_check_hddtemp!sdb!$_HOSTHDDTEMP_W$!50
}

#define service {
#use generic-service
#hostgroup_name raid5
#service_description ssh_check_hddtemp_sdc
#check_command ssh_check_hddtemp!sdb!44!50
#register 0
#}

#define service {
#use generic-service
#hostgroup_name raid5
#service_description ssh_check_hddtemp_sdc
#check_command ssh_check_hddtemp!sdb!44!50
#}

define service {
  use generic-service
  hostgroup_name debian
  process_perf_data 1
  service_description ssh_check_apt
  check_command ssh_check_apt
}

define service {
  use generic-service
  hostgroup_name debian
  service_description ssh_check_disk_root
  check_command ssh_check_disk!/!20%!10%
}

define service {
  use generic-service
  hostgroup_name debian
  service_description ssh_check_swap
  check_command ssh_check_swap!99%!89%
}

define service {
    use generic-service
    host_name foo.example.com
    service_description http://foo.example.com:8080/dir1
    check_command check_url!foo.example.com!8080!/dir1!test text 1
}

define service {
    use generic-service
    normal_check_interval 60
    retry_check_interval 15
    service_description SSH server
    check_command check_ssh
    hostgroup_name server
    contact_groups admins
}

Syndicate content