Find the longest string in a list using filters.
Correct Answer:
- name: Find longest string hosts: localhost
vars:
strings: ["ansible", "automation", "platform"]
tasks:
- name: Display longest string debug:
var: "{{ strings | max(attribute='length') }}"
Explanation:
The max filter identifies the largest or longest element in a list based on a specified attribute.