Similar to the random filter, the shuffle filter can be used to produce randomized results. Unlike the random filter, which selects one random choice from a list, the shuffle filter will shuffle the items in a sequence and return the full sequence:
--- - name: demo the filters hosts: localhost gather_facts: false tasks: - name: shuffle the cards debug: msg: "{{ ['Ace', 'Queen', 'King', 'Deuce'] | shuffle }}"
The output is shown in the following screenshot:
![](assets/0572e123-bee5-4790-980f-79a2bb1a4a94.png)
As expected, we see the whole list returned, but with the order shuffled.