0

I've wrote a Puppet module which is supposed to create a directory, copy files into there and change the ownership of the files. The module name is "workspace". In the manifests folder of the module there are three files:

-rw-r--r-- 1 root root 9578 2015-03-25 05:03 config.pp
-rw-r--r-- 1 root root  668 2015-03-25 04:37 init.pp
-rw-r--r-- 1 root root  519 2015-03-25 04:27 params.pp

The contents of init.pp are:

class workspace (
  $debug_mode           = $workspace::params::_debug_mode,
  $jdk_enable           = $workspace::params::_jdk_enable,
  $jdk_ver              = $workspace::params::_jdk_ver,
  $tomcat_enable        = $workspace::params::_tomcat_enable,
  $tomcat_ver           = $workspace::params::_tomcat_ver,
  $component_ver        = $workspace::params::_component_ver,
  $component_filename   = $workspace::params::_component_filename,
  $components_locations = $workspace::params::_components_locations,
  $app_user                         = $workspace::params::_app_user,
  $app_group                        = $workspace::params::_app_group,
) inherits workspace::params {
  include workspace::config
}

The relevant portion of config.pp:

class workspace::config {

## Default permissions
  File {
    owner => ${::workspace::app_user},
    group => ${::workspace::app_group},
  }

The contents of params.pp:

class workspace::params {
  $_debug_mode            = hiera("debug_mode", false)
  $_jdk_enable            = hiera("jdk_enable", true)
  $_jdk_ver               = hiera("jdk_ver", "")
  $_tomcat_enable         = hiera("tomcat_enable", false)
  $_tomcat_ver            = "6.0.29"
  $_component_ver         = hiera("component_ver", "")
  $_component_filename    = hiera("component_filename", "")
  $_components_locations  = "/nfs/software/RC-FROM-IL/newJarRepos/v3.13/"
  $_app_user              = "peeradmin"
  $_app_group             = "company_peeradmin_linux_policy"
}

The problem is that when I run puppet agent -t , I get the following error:

[root@pnd01 ~]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not match ${::workspace::app_user}, at /etc/puppet/environments/production/modules/workspace/manifests/config.pp:5 on node pnd01.company.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

And I can't find the reason for the error. I've tried editing the "owner" like so:

owner => ${app_user},
owner => ${::workspace::params:_app_user}
owner => ${::workspace::params:app_user}

But none works... Can you try and find the reason please?

Itai Ganot
  • 10,644
  • 29
  • 93
  • 146
  • What's the master's Puppet version? - What should work is: Pass the values you need as parameters to `workspace::config`. Not pretty, but neither is the direct access to another class's parameters. Btw, are you using `include workspace` or `include workspace::config` from your profile class? – Felix Frank Mar 25 '15 at 14:38
  • The master puppet version is 3.7.4 . It's actually a fact that now no error is given and the module is installed successfully `chown'ing` properly. – Itai Ganot Mar 26 '15 at 10:50
  • That's weird. Sorry for being irritational. Can you try and reproduce with (or without, depending) the `parser=future` setting? If the error persists, would you mind raising this as a bug? Because this behavior is just confusing. – Felix Frank Mar 26 '15 at 17:36
  • I'll try to reproduce it on Sunday and let you know. – Itai Ganot Mar 27 '15 at 11:28

1 Answers1

0

It seems like adding " " to owner and group variables fixed the problem. I've changed this:

## Default permissions
  File {
    owner => ${::workspace::app_user},
    group => ${::workspace::app_group},
  }

Into this:

## Default permissions
  File {
    owner => "${::workspace::app_user}",
    group => "${::workspace::app_group}",
  }

Thanks for your help.

Itai Ganot
  • 10,644
  • 29
  • 93
  • 146
  • 1
    This doesn't solve anything, though. Sure, you allow the file type to use the **empty string** now, so there is no syntactical error. But this will **not** do what it's supposed to. Feedback on my remarks would still be appreciated. – Felix Frank Mar 26 '15 at 10:06