Literal URIs in templates

92 views
Skip to first unread message

Grant Byers

unread,
Mar 23, 2014, 8:29:24 PM3/23/14
to puppet...@googlegroups.com
Hi,

I'm having some trouble using a template to construct URIs in a target file. How can I prevent the puppet templating engine from trying to interpret the URIs?

For example, I've got the following class ;

class ldap::config {
  $ldap_sizelimit = extlookup("ldap_sizelimit", "500")
  $ldap_timelimit = extlookup("ldap_timelimit", "15")
  $ldap_deref = extlookup("ldap_deref", "never")
  $ldap_uri = extlookup("ldap_uri", "ldap://<host1> ldap://<host2> ldap://<host3>")
  $ldap_basedn = extlookup("<basedn>")
  $ldap_referrals = extlookup("ldap_referrals", "off")

  file { '/etc/openldap/ldap.conf':
    ensure  => file,
    source  => template('ldap/ldap.conf.erb'),
    require => Class["ldap::install"],
  }
}


And my template ;

#
# LDAP Defaults
#

# See ldap.conf(5) for details
# This file should be world readable but not world writable.

SIZELIMIT       <%= @ldap_sizelimit %>
TIMELIMIT       <%= @ldap_timelimit %>

REFERRALS       <%= @ldap_referrals %>
DEREF           <%= @ldap_deref %>

URI             <%= @ldap_uri %>
BASE            <%= @ldap_basedn %>

TLS_CACERTDIR   /etc/pki/tls/certs



However, this barfs when I attempt to apply ;

err: Failed to apply catalog: Parameter source failed on File[/etc/openldap/ldap.conf]: Could not understand source #
# LDAP Defaults
#

# See ldap.conf(5) for details
# This file should be world readable but not world writable.

SIZELIMIT       500
TIMELIMIT       15

REFERRALS       off
DEREF           never

URI             ldap://<host1> ldap://<host2> ldap://<host3>
BASE            <basedn>

TLS_CACERTDIR   /etc/pki/tls/certs
: bad URI(is not URI?): %23%0A%23%20LDAP%20Defaults%0A%23%0A%0A%23%20See%20ldap.conf(5)%20for%20details%0A%23%20This%20file%20should%20be%20world%20readable%20but%20not%20world%20writable.%0A%0ASIZELIMIT%09500%0ATIMELIMIT%0915%0A%0AREFERRALS%09off%0ADEREF%09%09never%0A%0AURI%09%09ldap://<host1>%20ldap://<host2>%20ldap://<host3>%0ABASE%20%09%09<basedn>%0A%0ATLS_CACERTDIR%09/etc/pki/tls/certs%0A at /etc/puppet/environments/testing/modules/ldap/manifests/config.pp:16


Thanks,
Grant

Grant Byers

unread,
Mar 23, 2014, 8:35:16 PM3/23/14
to puppet...@googlegroups.com
Scrap that. I'm an idiot.

Michael Burling

unread,
Aug 29, 2017, 8:59:53 AM8/29/17
to Puppet Users
Me, too! How did you fix the above? I'm running into the same error.

Ken Barber

unread,
Aug 29, 2017, 9:02:41 AM8/29/17
to Puppet Users
The appropriate attribute in this case should be 'content' instead of
'source' ... so instead of this:

file { '/etc/openldap/ldap.conf':
ensure => file,
source => template('ldap/ldap.conf.erb'),
require => Class["ldap::install"],
}

Use this:

file { '/etc/openldap/ldap.conf':
ensure => file,
content => template('ldap/ldap.conf.erb'),
require => Class["ldap::install"],
}

See: https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-content

ken.
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/7275ae03-e70d-46d1-aaa0-15cb3a73a87c%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Michael Burling

unread,
Aug 29, 2017, 10:30:04 AM8/29/17
to Puppet Users
Thanks very much. I am an idiot.
Reply all
Reply to author
Forward
0 new messages