ansible lookup pipe what does this pipe means?


In ansible, I can use something like:

This can work, but what does the ‘pipe’ mean? cannot find any detail explanation for this in ansible document, want to understand what happens when this statement run.

For example, is the ‘date’ means run ‘date’ command from shell? and then use pipe-like way to format the date in the specified way?


The pipe is an ansible lookup plugin that will calculate the output of the shell command you specify in lookup’s second parameter, and pipe it to the left side of your lookup. You can specify any shell command there.

Therefore in your example, the output of shell command date +%Y%m%d should be pipe’d to the debug module and var should be set to this output value.

I generally use pipe lookup to set a fact for timestamp so that I can append timestamp in a variable at the end for any resource names, like this:

Official documentation on Lookups, and specific example that includes pipe.

Leave a Reply