March 2019
Intermediate to advanced
412 pages
9h 49m
English
The count filter will return the length of a sequence or hash. In fact, length is an alias of count to accomplish the same thing. This filter can be useful for performing any sort of math around the size of a set of hosts, or any other case where the count of some set needs to be known. Let's create an example where we set a max_threads configuration entry to match the count of hosts in the play:
max_threads: {{ play_hosts | count }}
This provides us with a nice, concise way of getting the number of hosts contained within the play_hosts variable, and assigning the answer to the max_threads variable.
Read now
Unlock full access