Guest User

Untitled

a guest
May 16th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  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
Add Comment
Please, Sign In to add comment