Assigning dynamic values to each node in puppet

How to dynamically assign variable to each node. If I had a 30 nodes and I had a file which is managed by puppet and I need to assign different values for each nodes from a array of values. How to do it other than making it static.

For Example: If I had a array [ 1,2,3,4 ] then node 1 with variable "x" should be 1 and node 2 with "x" variable should assign a value 2.

It's generally much better to state your actual, specific issue rather than try to generalize it to some abstract version of what you think you should be doing. You could be going down the complete wrong path depending on what it is exactly you are attempting to actually do.