From the course: Ansible: From Basics to Guru by Pearson

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Using the fileglob plugin

Using the fileglob plugin

In this video, we'll talk about the FileGlob plugin. The FileGlob lookup plugin can be used to iterate over a list of files according to a globbing pattern. When you use it as lookup FileGlob star, it will provide a string of comma-separated values for all files in the output. And to force the lookup plugin to return a list of values instead of a string, you can use query instead of lookup, like query FileGlob on star. And in the output, you will see that it's a list because the data is encapsulated by brackets. That's how you normally recognize your lists. Let's check out an example. So here we have FileGlob list, which is basically showing what we have just seen on the slide. your Ansible playbook on FileGlobeList. It's getting all the different files in a list. We also have a FileGlobeString. And here we are using lookup instead of query. And let's see how that is making it different. And as you can see, one string, which is a comma separated list of files. Now you may wonder how…

Contents