Category: Puppet

Using Vim to edit Puppet code

# yum -y install vim-enhanced # vi /etc/profile # add at the last line alias vi=’vim’ # source /etc/profile # reload # cat .vimrc ” vimrc: Managed by puppet – DO NOT EDIT ” Changes manually to this file can, and will, be lostset nocompatibleif has(“syntax”) syntax on set background=dark endif if has(“autocmd”) au BufReadPost

Puppet – Custom Facts – Check SAP Oracle version

REMARK – use ***  puppet facts find <servername> –render-as yaml | grep sap_ora Make a custom fact (ruby code) that determins the Oracle version SAP is using. Under  modules tree /modules/<module_name>/lib/oracleversion.rb   Facter.add("sap_oracleversion") do confine :operatingsystem => 'SLES' if Facter.value(:sapprepsids) != nil setcode do result = "none" sapprep_sid = Facter.value(:sapprepsids) first_sid = sapprep_sid.to_s.split(',')[0] second_sid =

Puppet – external data – Hiera

Hiera is nothing, but a key value look up tool, which can be ordered and organized nicely without meddling with the actual code. Just give hiera the data that your modules need, and you are ready to go. “Hiera makes your data separate from the module’s, so that the module code remains untouched. This helps

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.*/ {

▶ Package Management from command line with Puppet

Just on the command line with puppet apply [root@server1 ~]# puppet apply –verbose –execute ‘package { openssl: ensure => latest }’ Info: Loading facts Notice: Compiled catalog for in environment production in 0.57 seconds Warning: The package type’s allow_virtual parameter will be changing its default value from false to true in a future release.

▶ Hello EC2, Part 1: Bootstrapping Instances with cloud-init, git, and puppet

Hello EC2, Part 1: Bootstrapping Instances with cloud-init, git, and puppet This is the first of a series of posts about setting up a scalable and robust ”Hello Word” web server using Amazon EC2—an exercise I am working through. The target audience is developers with some experience using EC2. This first installment looks at how