Apache mod_rewrite URL redirect script


I wrote a bash script to automate the Apache (mod_rewrite) URL redirection. It supports 3 types of redirection: - One to One: eg. From http://jackiechen.local/mylab To http://jackiechen.org./mylab - Any to One: eg. From http://jackiechen.local/* To http://jackiechen.org - Any to Any: eg. From http://jackiechen.local/$1 to http://jackiechen.org/$1 The script can be downloaded from here Note: I tested … Continue reading Apache mod_rewrite URL redirect script

Puppet push Nagios


With the storeconfigs enabled, I am able to push Naigos via Puppet. It is really simple and straighforward, as Puppet already support nagios_* type. How it works? Below is my sample codes. It can be downloaded from here. sys_nagios::client is the class for Nagios client, it sends the hosts' facts to Puppet master then the data … Continue reading Puppet push Nagios

Puppet motd template


1) Create the manifest of sys_motd module/etc/puppet/environments/development/modules/sys_motd/manifests/init.ppclass sys_motd { file { '/etc/motd': ensure => file, content => template('sys_motd/motd.erb'), }}2) Create a ERB file as the motd template/etc/puppet/environments/development/modules/sys_motd/templates/motd.erb#################################HOST: <%= fqdn %> OS: <%= operatingsystem %> VERSION: <%= operatingsystemrelease %> ENVIRONMENT: <%= environment %>#################################

Puppet custom facter


In my lab, I added a custom facter 'environment', which tells me the box is in either development or production.Here are the steps1) Create a new module and associated file: /etc/puppet/modules/mylab/lib/facter/environment.rb2) Add the ruby code:# Add puppet facter environmentFacter.add("environment") do setcode do result = case Facter.hostname when /^dev/: "development" else "production" end result endendReference:https://docs.puppetlabs.com/facter/2.2/custom_facts.html