daily pastebin goal
4%
SHARE
TWEET

Untitled

a guest May 16th, 2018 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## root@junglist /tmp# cat /var/lib/puppet/lib/puppet/parser/functions/interface_alias.rb
  2. module Puppet::Parser::Functions
  3.         newfunction(:interface_alias, :type => :rvalue) do |args|
  4.                 interface_alias = args[0]
  5.                 $stderr = File.open("/tmp/plugin.output","w")
  6.                  interface_data = `/sbin/ip address show label #{interface_alias}`.split
  7.                  if interface_data[1].nil?
  8.                      "_default_"
  9.                  else
  10.                      interface_data[1].gsub(/\/\d+/, '')
  11.                  end
  12.         end
  13. end
  14.  
  15. ## root@junglist /tmp# cat ./test.pp
  16. ## #!/usr/bin/env puppet
  17. ## $foo = interface_alias("eth0:0")
  18. ## notify { $foo: }
  19.  
  20. ## root@junglist /tmp# ./test.pp
  21. ## notice: 123.100.70.2
  22. ## root@junglist /tmp# ip addr show label eth0:0
  23. ##     inet 123.100.70.2/29 brd 123.100.70.7 scope global secondary eth0:0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top