Deciding when to use static code or dynamic data
Having viewed all the possibilities of managing data structure and looking over the code examples covered in this book, it probably raises the question about when to write code and when to use data. Figure 9.1 highlights a decision tree to follow:
Figure 9.1 – Data or code decision tree
The first key thing is if the data doesn’t vary over nodes and it’s only used once, the simplest thing is to hardcode the data in Puppet code – for example, just directly setting the owner of a file as exampleuser
in a file resource attribute.
If a value is used multiple times, then there is clearly a value in assigning a variable and using this variable where it is required. This simplifies maintenance if the value needs to be changed but does mean you have to keep track of variables when reading the code.
If, on the other hand, there is variation across nodes and overriding the value on...