Trouble using type Stdlib::Windowspath

176 views
Skip to first unread message

Tiago Delboni

unread,
Jan 9, 2017, 7:02:54 AM1/9/17
to Puppet Users
Hi!

I'm having trouble using type Stdlib::Windowspath, from module puppetlabs/stdlib, as a parameter type in a manifest. Is this "custom type" really available? In https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/types/windowspath.pp it is defined using the "type" word, which, according to the latest doc (https://docs.puppet.com/puppet/latest/lang_reserved.html#reserved-words), is "reserved for future use".

1. Puppet version (Windows 7):

C:\>puppet --version
4.2.1

2. puppetlabs/stdlib version

C:\>puppet module list --modulepath=c:\git\winpuppet\test\modules
c:/git/winpuppet/test/modules
+-- mymodule (???)
+-- puppetlabs-stdlib (v4.14.0)


3. Manifest (%MODULEPATH%\mymodule\manifests\mymanifest.pp):

class mymodule::mymanifest (
 
String $string_param = 'a string',
 
Stdlib::Windowspath $windowspath_param = 'C:\a\valid\path') {

  notice
($string_param)
  notice
($windowspath_param)

}

4. Execution/error message:

C:\>puppet apply --modulepath=c:\git\winpuppet\test\modules -e "include mymodule::mymanifest"
Error: Evaluation Error: Error while evaluating a Function Call, Expected parameter 'windowspath_param' of 'Class[Mymodule::Mymanifest]' to have type Stdlib::Windowspath, got String  at line 1:1 on node xxx.yyy.zzz


If, instead, I use a nonexistent type in the manifest, such as "My_nonexistent_type", I got the same error message:

C:\>puppet apply --modulepath=c:\git\winpuppet\test\modules -e "include mymodule::mymanifest"
Error: Evaluation Error: Error while evaluating a Function Call, Expected parameter 'windowspath_param' of 'Class[Mymodule::Mymanifest]' to have type My_nonexistent_type, got String  at line 1:1 on node xxx.yyy.zzz



Henrik Lindberg

unread,
Jan 9, 2017, 8:16:09 AM1/9/17
to puppet...@googlegroups.com
On 09/01/17 13:02, Tiago Delboni wrote:
> Hi!
>
> I'm having trouble using type Stdlib::Windowspath, from module
> puppetlabs/stdlib, as a parameter type in a manifest. Is this "custom
> type" really available? In
> https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/types/windowspath.pp
> it is defined using the "type" word, which, according to the latest doc
> (https://docs.puppet.com/puppet/latest/lang_reserved.html#reserved-words),
> is "reserved for future use".
>

The documentation is behind. The `type` keyword has been operational in
3.x when used with future parser since some time as well as in puppet 4.x.


> *1. Puppet version (Windows 7):*
>
> C:\>puppet --version
> 4.2.1
>
> *2. puppetlabs/stdlib version*
>
> C:\>puppet module list --modulepath=c:\git\winpuppet\test\modules
> c:/git/winpuppet/test/modules
> +-- mymodule (???)
> +-- puppetlabs-stdlib (v4.14.0)
>
> *3. Manifest (%MODULEPATH%\mymodule\manifests\mymanifest.pp):*
>
> |
> classmymodule::mymanifest (
> String$string_param ='a string',
> Stdlib::Windowspath$windowspath_param ='C:\a\valid\path'){
>
> notice($string_param)
> notice($windowspath_param)
>
> }
> |
>
> *4. Execution/error message:*
>
> C:\>puppet apply --modulepath=c:\git\winpuppet\test\modules -e "include
> mymodule::mymanifest"
> Error: Evaluation Error: Error while evaluating a Function Call,
> Expected parameter 'windowspath_param' of 'Class[Mymodule::Mymanifest]'
> to have type Stdlib::Windowspath, got String at line 1:1 on node
> xxx.yyy.zzz
>
> If, instead, I use a nonexistent type in the manifest, such as
> "My_nonexistent_type", I got the same error message:
>
> C:\>puppet apply --modulepath=c:\git\winpuppet\test\modules -e "include
> mymodule::mymanifest"
> Error: Evaluation Error: Error while evaluating a Function Call,
> Expected parameter 'windowspath_param' of 'Class[Mymodule::Mymanifest]'
> to have type My_nonexistent_type, got String at line 1:1 on node
> xxx.yyy.zzz
>

A non-existent type will in some versions of puppet be taken as being a
resource type.

One thing you can check is that your module (where you are using
Stdlib::XXX types have declared a dependency on Stdlib in its metadata.
If it does not have this it will not find types in Stdlib.

Regards
- henrik

--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

Martin Alfke

unread,
Jan 9, 2017, 8:22:27 AM1/9/17
to puppet...@googlegroups.com
Hi Henrik,


> A non-existent type will in some versions of puppet be taken as being a resource type.
>
> One thing you can check is that your module (where you are using Stdlib::XXX types have declared a dependency on Stdlib in its metadata. If it does not have this it will not find types in Stdlib.

do I get that right:

Self defined data types (in Modules) are only working when adding a metdata.json file to the module which makes use of the self defined data type?
Or with other words: self defined data types are not autoloaded?

Best,
Martin

Tiago Delboni

unread,
Jan 10, 2017, 7:57:12 AM1/10/17
to Puppet Users
Hi Henrik, thanks for helping.

I didn't have a "metadata.json" so I created one with "puppet module generate". Unfortunately, it is still not working - puppet apply is showing the same error: "Expected parameter 'windowspath_param' of 'Class[Mymodule::Mymanifest]' to have type Stdlib::Windowspath, got String".

{
  "name": "almg-mymodule",
  "version": "0.1.0",
  "author": "almg",
  "summary": "Test module.",
  "license": "Apache-2.0",
  "source": "",
  "project_page": null,
  "issues_url": null,
  "dependencies": [
    {"name":"puppetlabs-stdlib","version_requirement":">= 4.14.0"}
  ]

Henrik Lindberg

unread,
Jan 11, 2017, 12:34:34 PM1/11/17
to puppet...@googlegroups.com
Self defined data types are autoloaded. If you are referencing types in
another module, your module must have that other module as a dependency
in its meta data. This is true for self defined data types as well as
for functions written against the 4.x API.

For references to entities in the same module there is no need to
declare anything. Everything in a module is visible to that same module.

Does that help?
- henrik

> Best,
> Martin

Henrik Lindberg

unread,
Jan 11, 2017, 12:38:28 PM1/11/17
to puppet...@googlegroups.com
On 10/01/17 13:57, Tiago Delboni wrote:
> Hi Henrik, thanks for helping.
>
> I didn't have a "metadata.json" so I created one with "puppet module
> generate". Unfortunately, it is still not working - puppet apply is
> showing the same error: "Expected parameter 'windowspath_param' of
> 'Class[Mymodule::Mymanifest]' to have type Stdlib::Windowspath, got String".
>
> {
> "name": "almg-mymodule",
> "version": "0.1.0",
> "author": "almg",
> "summary": "Test module.",
> "license": "Apache-2.0",
> "source": "",
> "project_page": null,
> "issues_url": null,
> "dependencies": [
> {"name":"puppetlabs-stdlib","version_requirement":">= 4.14.0"}
> ]
> }
>

Maybe there is something wrong with that type.
What does this give you:

notice('C:\a\valid\path' =~ Stdlib::Windowspath)

If that fails, please report the issue against stdlib.
(Or I am blind and there is something not right about the path).

Best,
- henrik

> Em segunda-feira, 9 de janeiro de 2017 11:16:09 UTC-2, Henrik Lindberg
> escreveu:
>
> On 09/01/17 13:02, Tiago Delboni wrote:
> > Hi!
> >
> > I'm having trouble using type Stdlib::Windowspath, from module
> > puppetlabs/stdlib, as a parameter type in a manifest. Is this "custom
> > type" really available? In
> >
> https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/types/windowspath.pp
> <https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/types/windowspath.pp>
>
> > it is defined using the "type" word, which, according to the
> latest doc
> >
> (https://docs.puppet.com/puppet/latest/lang_reserved.html#reserved-words
> <https://docs.puppet.com/puppet/latest/lang_reserved.html#reserved-words>),
> <http://puppet-on-the-edge.blogspot.se/>
>
> --
> 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
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/a5e005fc-728b-4948-84af-4d18435ea277%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/a5e005fc-728b-4948-84af-4d18435ea277%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Tiago Delboni

unread,
Jan 13, 2017, 6:16:18 AM1/13/17
to Puppet Users
Em quarta-feira, 11 de janeiro de 2017 15:38:28 UTC-2, Henrik Lindberg escreveu:

Maybe there is something wrong with that type. 
What does this give you: 

    notice('C:\a\valid\path' =~ Stdlib::Windowspath) 

If that fails, please report the issue against stdlib. 
(Or I am blind and there is something not right about the path). 


Hi Henrik

The first notice bellow returns FALSE and the second, that uses Stdlib::Windowspath definition from "puppetlabs-stdlib\types\windowspath.pp" returns TRUE.

notice('C:\temp' =~ Stdlib::Windowspath)  

notice('C:\temp' =~ Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/])

I also defined my own Windowspath type in "mymodule\types\windowspath.pp" and the following test returns FALSE:

notice('C:\temp' =~ Mymodule::Windowspath)  

I guess it all points to a "type loading" issue - I can't use types, even those defined inside my own module. :(




Henrik Lindberg

unread,
Jan 13, 2017, 4:32:28 PM1/13/17
to puppet...@googlegroups.com
Sounds like they are in the wrong location, or that you are using a
version of Puppet that does not support loading of types.

- henrik

>
>
>
> --
> 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
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/beb5380e-76a4-41b3-bf8b-1b3b2f825665%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/beb5380e-76a4-41b3-bf8b-1b3b2f825665%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages