puppet search function deprecation

With the release of puppet 3.7, the search function is now deprecated, and will be removed in 4.0. This is a feature that I had used by recommendation of a puppet cookbook when creating virtual resources and managing users that I have now removed.

Using the search function basically added the namespace of an existing class to another class to allow the second class access to the existing classes resources; virtual resources in this scenario. E.g, using the search function:

# /etc/puppet/modules/user/manifests/virtual.pp
class user::virtual {
  @user { "cacti":
    ensure => present,
    uid    => 999,
}

# /etc/puppet/modules/user/manifests/system.pp
class user::system {
  search user::virtual

  realize( User["cacti"])
}

# /etc/puppet/manifests/site.pp

class base {
  include user::system
}

In the above example I created a virtual user that I could then include anywhere and any number of times, and then realize that user where appropriate.

To fix the problem and stop using the search function, I simply included the user::virtual class everywhere that I included the user::system class, e.g.:

# /etc/puppet/modules/user/manifests/virtual.pp
class user::virtual {
  @user { "cacti":
    ensure => present,
    uid    => 999,
}

# /etc/puppet/modules/user/manifests/system.pp
class user::system {
  realize( User["cacti"])
}

# /etc/puppet/manifests/site.pp

class base {
  include user::virtual
  include user::system
}

This resolved my issue. Let me know in the comments if you have other uses of search and how this change might impact you.

– josh


Posted

in

, ,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *