is there any way in puppet to do while loop for shell command until it gets particular string?

asked 2018-04-20 16:53:29 -0600

madhu22 gravatar image

Give any shell command and check continuously in loop to get a particular string.

Is it possible in puppet?

edit retag flag offensive close merge delete



Can you please explain more on what exactly you looking for?

Mr_Sharma gravatar imageMr_Sharma ( 2018-04-21 08:38:29 -0600 )edit

More information is needed, but it depends where you need to use this information. If you need some information to feed your logic, the best way to do that is with a custom fact, which can execute any code that you wish, as long as it returns information. This is done before the puppet run, ...

DarylW gravatar imageDarylW ( 2018-04-22 20:24:05 -0600 )edit

.. not during, so if you need it to respond to some of the actions that were done earlier in your run, that can't be done.

DarylW gravatar imageDarylW ( 2018-04-22 20:24:38 -0600 )edit

You can create your own custom resource types, and in theory part of the resource type could run a command to gather information that it needs, and that runs on the client during the application of the catalog, but that can't be used to drive other resource logic.

DarylW gravatar imageDarylW ( 2018-04-22 20:25:38 -0600 )edit

If something is just needed as a general input, you can create a custom heira backend, that could potentially run your command to get the answer you are looking for, but that would run from the master.

DarylW gravatar imageDarylW ( 2018-04-22 20:26:16 -0600 )edit