example42 / puppet-tp

Tiny Puppet - The Universal Installer
http://tiny-puppet.com
Apache License 2.0
68 stars 21 forks source link

malformed format string - %{ at /etc/puppet/env/testing/modules/tp/manifests/install3.pp:140 #30

Closed major0 closed 8 years ago

major0 commented 8 years ago

Expected Behavior

Expect tp::install3 to work on Puppet3/4.

Actual Behaviour

tp::install3 failing with an error, possibly due to obscure hiera lookups within the hiera data.

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: malformed format string - %{ at /etc/puppet/env/testing/modules/tp/manifests/install3.pp:140

Steps to Reproduce the Problem

Trying to narrow down the exact trigger for this, but I suspect it is our use of %%{}[label] macros within our data/common.yaml. See: https://tickets.puppetlabs.com/browse/HI-127

Examples:

profiles::example::hierarchy:
  - "%{::fqdn}"
  - '"host/%%{}{::hostdata}"'

Specifications

operatingsystem => Ubuntu
operatingsystemmajrelease => 16.04
operatingsystemrelease => 16.04
os => {"name"=>"Ubuntu", "family"=>"Debian", "release"=>{"major"=>"16.04", "full"=>"16.04"}, "lsb"=>{"distcodename"=>"xenial", "distid"=>"Ubuntu", "distdescription"=>"Ubuntu 16.04.1 LTS", "distrelease"=>"16.04", "majdistrelease"=>"16.04"}}
osfamily => Debian
# puppet --version
3.8.5
  "name": "example42-tp",
  "version": "1.1.0",
  "summary": "Tiny Puppet",
  "license": "Apache-2.0",
  "author": "Alessandro Franceschi",
alvagante commented 8 years ago

What version of ruby are you using? Tp doesn't work on Ruby 1.8.7 https://github.com/example42/puppet-tp#prerequisites-and-limitations

major0 commented 8 years ago
# ruby --version
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
alvagante commented 8 years ago

Sorry, I didn't read properly your extra info. The reason of your issue is that variable interpolation is currently not supported by TP when lookup into data files. Consider that tp does NOT actually uses hiera for lookups, it just emulates its behaviour (check a file called hiera.yaml for hiearchy and they traverse the hierarchy).

Also I don't fully understand what you expect to do in data/common.yaml with :

profiles::example::hierarchy:
  - "%{::fqdn}"
  - '"host/%%{}{::hostdata}"'

In any case those variables can't be interpolated by tp (edit: actually tp interpolates variables only in hiera.yaml, but not every possible variable, only the ones expected by the tp_lookup function. It does not interpolate variables in data files) and that's not a useful file for anything related to tiny puppet.

There could be some confusion among hiera, data in modules and tiny puppet.

Tiny Puppet has basically nothing to do with both of them but (probably to add confusion):

Hope to have clarified things a bit

major0 commented 8 years ago

Yes, that clarifies things. I had looked up the error and ran across a similar error, and advice to solving it in this post: https://ttboj.wordpress.com/2013/08/25/finding-yaml-errors-in-puppet/

The commands listed in the post found no direct parse error with our YAML data, and based on the output of the error I "assumed" that the error had something to do with TP's handling of data as it was returned from the Hiera data during automatic parameter expansion.

In this case assuming we have profiles::foo::bar defined in the hiera data and we have something like the following profile:

class profiles::foo ($bar = 'boo')
{
  tp::install3 { 'foo': }
  tp::conf3 { 'foo':
    template         => 'site/foo/config.erb',
    options_hash => {
      bar => $bar,
    }
  }
}

Any advice on how to narrow down what is causing the error?

major0 commented 8 years ago

I have located the problem, it was the wrong ruby version as you stated. I had a derp moment and collected data from the puppet agent as opposed to the server.