How to get the first element of a list from the output of setup module in Ansible?

Question:

I received the following data from the setup module:

I want to retrieve the 1st value of ansible_processor and use it in a Jinja2 template.

If I use {{ ansible_processor }}, it’s giving me both values:

But I want only the first one.

Answer:

To get first item of the list:

Or:

Leave a Reply