Ask Your Question

Reference parent defined type variables in a defined type

asked 2014-11-15 21:36:19 -0600

Pindish gravatar image

I have a defined type that calls another defined type. How do I reference parent defined type variables?

define mymod::manage_data (
  $time   = undef,
  $wday   = undef,
  $region = 'useast',
  $users  = undef,
) {
  $datapath = "/data/${title}"

  if $users {
    create_resource(mymod::manage_users, $users)

I need to reference mymod::managedata::datapath in mymod::manageusers:

define mymod::manage_users(
  $action = 'add',
  $name  = undef,
  $age   = undef,
) {
  notify { "datapath = $mymod::manage_data::datapath": }

This works for class, does not seem to work for defined type. Any idea?


edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2014-11-17 17:29:08 -0600

lupin gravatar image

Per, this link, you need to capitalize.

when you make a resource reference to an instance of a defined type, you have to capitalize every namespace segment in the type’s name. That means an instance of the foo::bar::baz type would be referenced like Foo::Bar::Baz['mybaz'].

edit flag offensive delete link more


Thanks lupin. It is not clear to me how I can reference "datapath" in this case. $datapath is a file resource defined in the parent defined type, mymod::manage_data, which calls defined type mymod::manage_users. Do I reference it like this: Mymod::Manage_data['what-do-I-use-here']::Datapath?

Pindish gravatar imagePindish ( 2014-11-19 01:04:09 -0600 )edit

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


Asked: 2014-11-15 21:36:19 -0600

Seen: 230 times

Last updated: Nov 17 '14