The playbook might look this way. I have not tested the code, it's just off the cuff...
---
- hosts: all
tasks:
- name: Install the {{ srv }} server package
yum:
name: "{{ item }}"
state: present
loop: "{{ srv }"
- name: Check for the installed package
yum:
list: "{{ srv }}"
loop: "{{ srv }"
register: yumout
- debug:
msg: yumout