Mercurial > repos > other > Puppet
comparison modules/apache/lib/puppet/parser/functions/enclose_ipv6.rb @ 257:675c1cc61eaf
Update Apache module to get CentOS 8 support
Unfortunately it only fixes some bits. mod_wsgi still needs
other approaches
This also overrides the vhost modification to make them come last
in the import order (after module loading)
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 22 Dec 2019 14:43:29 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
252:47750947f4dc | 257:675c1cc61eaf |
---|---|
1 # | |
2 # enclose_ipv6.rb | |
3 # | |
4 | |
5 module Puppet::Parser::Functions | |
6 newfunction(:enclose_ipv6, :type => :rvalue, :doc => <<-EOS | |
7 Takes an array of ip addresses and encloses the ipv6 addresses with square brackets. | |
8 EOS | |
9 ) do |arguments| | |
10 | |
11 require 'ipaddr' | |
12 | |
13 rescuable_exceptions = [ ArgumentError ] | |
14 if defined?(IPAddr::InvalidAddressError) | |
15 rescuable_exceptions << IPAddr::InvalidAddressError | |
16 end | |
17 | |
18 if (arguments.size != 1) then | |
19 raise(Puppet::ParseError, "enclose_ipv6(): Wrong number of arguments "+ | |
20 "given #{arguments.size} for 1") | |
21 end | |
22 unless arguments[0].is_a?(String) or arguments[0].is_a?(Array) then | |
23 raise(Puppet::ParseError, "enclose_ipv6(): Wrong argument type "+ | |
24 "given #{arguments[0].class} expected String or Array") | |
25 end | |
26 | |
27 input = [arguments[0]].flatten.compact | |
28 result = [] | |
29 | |
30 input.each do |val| | |
31 unless val == '*' | |
32 begin | |
33 ip = IPAddr.new(val) | |
34 rescue *rescuable_exceptions | |
35 raise(Puppet::ParseError, "enclose_ipv6(): Wrong argument "+ | |
36 "given #{val} is not an ip address.") | |
37 end | |
38 val = "[#{ip.to_s}]" if ip.ipv6? | |
39 end | |
40 result << val | |
41 end | |
42 | |
43 return result.uniq | |
44 end | |
45 end |