Puppet Function: domain2dn
- Defined in:
- lib/puppet/parser/functions/domain2dn.rb
- Function type:
- Ruby 3.x API
Overview
Converts a DNS style domain string into a string suitable for use as a LDAP DN by constructing ‘dc=’ elements for each domain component.
Example:
foo.example.org
Would become:
dc=foo,dc=example,dc=org
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/puppet/parser/functions/domain2dn.rb', line 2 newfunction(:domain2dn, :type => :rvalue, :doc => <<-EOS Converts a DNS style domain string into a string suitable for use as a LDAP DN by constructing 'dc=' elements for each domain component. *Example:* foo.example.org Would become: dc=foo,dc=example,dc=org EOS ) do |args| if (args.size != 1) then raise(Puppet::ParseError, "port389_domain2dn(): Wrong number of arguments "+ "given #{args.size} for 1") end args[0].split('.').map{ |x| "dc=" + x }.join(',') end |