Search code examples
puppet

puppet style, what does "prefer metaparameters to relationship declarations" *mean*?


Looking at the Relationship Declarations section in the Puppet Style Guide about the '->' arrows, where 'x->y' means that y requires x to be installed before y, it says:

When possible, you should prefer metaparameters to relationship declarations.

that's a lot of syllables. Is that saying that you should prefer this

file { "/home/${user}/.ssh":
    require => User[$user],
    ...
}

and not use the arrows like this?

User[$user] -> file { "/home/${user}/.ssh":
    ...
}

Solution

  • file { "/home/${user}/.ssh":
        require => User[$user],
        ...
    }
    

    1.The above code even works with different manifests, when they are part of same catalog. So if you use metaparameters you have less work when you get a modification in future(unfortunately).

    2.Chaining arrows is best used for Resource collectors, when you have to make relationship more than one resource, you can have this instead of putting require/before in all the resources.