I received the following data from the setup module:
\"ansible_nodename\": \"3d734bc2a391\",
\"ansible_os_family\": \"RedHat\",
\"ansible_pkg_mgr\": \"yum\",
To get first item of the list:
- debug:
msg: "First item: {{ ansible_processor[0] }}"
Or:
- debug:
msg: "First item: {{ ansible_processor | first }}"
Try this for common handle this situation:
Ref: get-first-n-elements-of-a-list-in-jinja2-template-in-ansible
# from list
- debug:
msg: "First item: {{ ansible_processor[0] }}"
# from output, like 'https://xxx.xx/xxx/xxx.git'
- debug:
msg: "git repo's name: {{ (item| urlsplit('path')| basename | splitext)[0] }}"