Ask Your Question
0

using variables on include role statement in nodes.pp

asked 2017-03-11 17:40:38 -0500

stratmajik gravatar image

Hello,

I'm running puppet 4.9.4 on linux in a master-agent set up. I'm trying to assign my envtype variable to the include statement. Below is what my nodes.pp looks like.

node /(puppetagent)/ { notify {"Running node configuration for '${fqdn}'":} $envgroups = "dev" notify {"Setting envgroup variable to '${envgroups}'":} $envtype = "agents" notify {"Setting envtype variable to '${envtype}'":} include role::puppetagents::"${envtype}" }

When I run puppet agent --test on an agent server, I get this error.

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Could not parse for environment production: Illegal fully qualified name at /etc/puppetlabs/code/environments/production/manifests/nodes.pp:11:33 on node puppetagent1.sandbox.local Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run

However, when I hard code the envtype to the actual value like this below, the puppet agent --test works.

Below is for puppet agents app servers

node /(puppetagent)/ { notify {"Running node configuration for '${fqdn}'":} $envgroups = "dev" notify {"Setting envgroup variable to '${envgroups}'":} $envtype = "agents" notify {"Setting envtype variable to '${envtype}'":} include role::puppetagents::agents }

Is there way to use my envtype variable in the include role so I don't have to hard code?

Thanks, Mike

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2017-03-12 11:42:06 -0500

stratmajik gravatar image

I got it working like this below.

include "role::puppetagents::${envtype}"

Mike

edit flag offensive delete link more
0

answered 2017-03-12 07:31:40 -0500

Hyder gravatar image

updated 2017-03-12 07:32:41 -0500

remove include and try

   $role::puppetagents::envtype
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

1 follower

Stats

Asked: 2017-03-11 17:40:38 -0500

Seen: 102 times

Last updated: Mar 12