Ask Your Question

Puppet error in node variable

asked 2018-08-02 09:06:18 -0600

Hello everyone!

I have this manifest:

$foremanlogin = file('/etc/puppetlabs/code/environments/production/manifests/foremanlogin.txt')
$foremanpass = file('/etc/puppetlabs/code/environments/production/manifests/foremanpass.txt')

$query = foreman({foreman_user => "$foremanlogin",
                  foreman_pass => "$foremanpass",
                  item         => 'hosts',
                  search       => 'hostgroup = "Web Servers"',
filter_result => 'name',

$quoted = regsubst($query, '(.*)', '"\1"')
$query6 = join($quoted, ",")

notify{"The value is: ${query6}": }

node ${query6} {

package { 'atop':
    ensure => 'installed',


When I execute this on agent I got error:

Server Error: Could not parse for environment production: Syntax error at ''

Error in my node block

node ${query6}

Now if I remove this from code:

node ${query6} {

package { 'atop':
    ensure => 'installed',


I see correct output from notify, my variable looks like this:


Variable in correct node manifest format.

I don't understand whats wrong? variable query6 is correct.

How to fix that?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-08-27 13:54:05 -0600

XeRO gravatar image

It seems like node definitions don't support variables at the moment, see Language: Node definitions, saying:

A node statement’s name must be one of the following:

  • A quoted string containing only letters, numbers, underscores (_), hyphens (-), and periods (.).
  • A regular expression.
  • The bare word default.

So it doesn't mention variables. I believe not even the regular expression takes variables.

A way to solve the problem could be External Node Classifiers. Haven't used them yet, but it sounds like you can find the answer to your problem with ENC's.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2018-08-02 09:06:18 -0600

Seen: 24 times

Last updated: Aug 02