Month: September 2015

Custom Facts in Puppet

  ================== CUSTOM FACT ================= puppet@testserver:/opt/puppetserver/conf/environments/test/modules/helloworld/lib/facter> cat dhcp_dnsdomain.rb     Facter.add(“dhcp_dnsdomain”) do       confine :operatingsystem => ‘SLES’       setcode do         Facter::Core::Execution.exec(‘/usr/sbin/dhcpcd-test eth0 | grep DNSDOMAIN | cut -d$”\'” -f 2 | rev | cut -d”.” -f 1,2 | rev’)       end     end ==================== PUPPET MANIFEST ============ puppet@testserver:/opt/puppetserver/conf/environments/test/modules> cat helloworld/manifests/init.pp class helloworld { notify {

Puppet practical: check $interfaces for IP address

EXAMPLE on checking IP Address on available network interfaces (via Puppet) $ifs = split($interfaces, ‘,’) notify {” Interface list: $ifs “: } defines::show_ip_test { $ifs: } define show_ip_test { $inf = “ipaddress_${name}” $ip = inline_template(‘<%= scope.lookupvar(inf) %>’) #            notify {“IP ${name} :  $ip”: } if $ip =~ /^153\.100\.[3-6]{1}\.*/ { #             if $ip =~ /10\.182\.42.*/ {