Puppet + hiera file backend problem

243 views
Skip to first unread message

Christian Charpentier

unread,
Jun 6, 2014, 12:10:12 PM6/6/14
to puppet...@googlegroups.com
Hi,

I'm using hiera with puppet and i want to store my resources out from the modules, in hieradata directory.

Here is my hiera.yaml file:

---
:hierarchy:
    - common
#    - %{operatingsystem}
    - %{::hostname}

:backends:
    - yaml
    - file

:yaml:
    :datadir: '/etc/puppet/hieradata'
   
:file:
    :datadir: '/etc/puppet/hieradata'
   
:logger: console

The common.yaml file:

---
apache_packages_list:
 - apr-1.4.8
 - apr-devel-1.4.8
 - apr-util-1.5.2
 - apr-util-devel-1.5.2
 - distcache-1.4.5
 - distcache-devel-1.4.5
 - httpd-2.4.6
 - httpd-tools-2.4.6
 - mod_ssl-2.4.6
 
accounts_conf_filename: accounts.victorbuckservices.com.conf
accounts_conf_balancer_filename: accounts.victorbuckservices.com.balancer.conf
certificate_filename: all.dev.victorbuckservices.com.crt
key_filename: all.dev.victorbuckservices.com.key


My site.pp call a role which call itself a profile which uses a module to install apache.
Here is the config..p of apache module:

class apache::config {
    $accounts_conf_filename           = hiera('accounts_conf_filename')
    $accounts_conf_balancer_filename  = hiera('accounts_conf_balancer_filename')
    $crt_filename                     = hiera('certificate_filename')
    $key_filename                     = hiera('key_filename')
   
    file {'/etc/httpd/conf.d/accounts.victorbuckservices.com.conf':
        ensure   => file,
        content  => template($accounts_conf_filename),
    }
 
    file {'/etc/httpd/conf.d/$accounts_conf_balancer_filename':
        ensure   => file,
        content  => template($accounts_conf_balancer_filename),
    }
   
    file {'/etc/pki/tls/certs/$crt_filename':
        ensure   => file,
        content  => template($crt_filename),
    }

    file {'/etc/pki/tls/private/$key_filename':
        ensure   => file,
        content  => template($key_filename),
    }

}

I put data and resource files in /etc/puppet/hieradata/ and when i use the command line on the client:
puppet agent --server=d0puppet.victor-buck.com --debug --verbose --noop --test
I got the following error :
Error 400 on Server: could not find template 'accounts.victorbuckservices.com.conf' at /etc/puppet/modules/apache/manifests/config.pp:9 on node puppetclient

Someone to help to figure out what happen?
If there are some information missing to make easier to understand what's going on feel free to ask me.

Thanks.

Christian

Doug Forster

unread,
Jun 6, 2014, 12:29:29 PM6/6/14
to puppet...@googlegroups.com
Look at the error.
Error 400 on Server: could not find template 'accounts.victorbuckservices.com.conf' at /etc/puppet/modules/apache/manifests/config.pp:9 on node puppetclient

Do you have a file in /etc/puppet/templates/accounts.victorbuckservices.com.conf Or does it have a .erb ending?


--
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/00bf537c-6ac1-4351-b4c3-e4f99bdda189%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christian Charpentier

unread,
Jun 10, 2014, 3:37:42 AM6/10/14
to puppet...@googlegroups.com
I have a file accounts.victorbuckservices.com.conf and not an .erb template.
It seems a little weird to me that we have to use template function either for .erb template or file backend.

jcbollinger

unread,
Jun 10, 2014, 11:14:31 AM6/10/14
to puppet...@googlegroups.com


On Tuesday, June 10, 2014 2:37:42 AM UTC-5, Christian Charpentier wrote:
I have a file accounts.victorbuckservices.com.conf and not an .erb template.


Actually, it probably is a trivial ERB template, even though it was not written as one.  As long as it does not contain the two-character sequence "<%", it can be construed as an ERB template containing only template text.

 
It seems a little weird to me that we have to use template function either for .erb template or file backend.



You don't have to do so.  If you want specifically to put the verbatim contents of a file into a resource property, then you can use the file() function instead.

If you want to provide both the option of using all static content and the option of providing dynamic, templated content, however, then using the template() function is a pretty simple way of doing so.  Few files that are not ERB or similar templates will be misinterpreted by ERB, so you can point your resource at either, and it will just work.  This is a question of the implementation of your class, which is under your control.

Note also that as far as I know, using the ".erb" file extension is purely a convention.  I do not think the template() function requires templates to be named that way (and certainly no such requirement seems to be documented).  On the other hand, template() does implement some magic around modules' 'templates/' directories.  In this case, I think that's where the problem resides.  The templating docs describe how the template() function resolves template file names.


John

Reply all
Reply to author
Forward
0 new messages