Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## root@junglist /tmp# cat /var/lib/puppet/lib/puppet/parser/functions/interface_alias.rb
- module Puppet::Parser::Functions
- newfunction(:interface_alias, :type => :rvalue) do |args|
- interface_alias = args[0]
- $stderr = File.open("/tmp/plugin.output","w")
- interface_data = `/sbin/ip address show label #{interface_alias}`.split
- if interface_data[1].nil?
- "_default_"
- else
- interface_data[1].gsub(/\/\d+/, '')
- end
- end
- end
- ## root@junglist /tmp# cat ./test.pp
- ## #!/usr/bin/env puppet
- ## $foo = interface_alias("eth0:0")
- ## notify { $foo: }
- ## root@junglist /tmp# ./test.pp
- ## notice: 123.100.70.2
- ## root@junglist /tmp# ip addr show label eth0:0
- ## inet 123.100.70.2/29 brd 123.100.70.7 scope global secondary eth0:0
Add Comment
Please, Sign In to add comment