# yum exclude & loop with ansible 2.5

**URL:** <https://forum.ansible.com/t/yum-exclude-loop-with-ansible-2-5/26018>\
**Category:** Ansible Project\
**Created:** [November 14, 2017, 1:28pm UTC](https://forum.ansible.com/t/yum-exclude-loop-with-ansible-2-5/26018 "2017-11-14T13:28:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shlomit\_Afgin](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@Shlomit\_Afgin](https://forum.ansible.com/u/Shlomit_Afgin)\
**Post date:** [November 14, 2017, 1:28pm UTC](https://forum.ansible.com/t/yum-exclude-loop-with-ansible-2-5/26018/1 "2017-11-14T13:28:22Z")

</div>

Hi,

I start to work with Ansible lately.

I would like to run ‘yum install’ on a list of packages. I have:

> _- name: install these items_  
> _yum:_  
> _name: “{{item}}”_  
> _exclude: package4\*_  
> _update\_cache: yes_  
> _state: present_  
> _skip\_broken: yes_  
> _with\_lines: cat “path\_to\_file/yum\_packages.txt”_

File yum\_packages.txt contain:

> package1
> 
> package2
> 
> package3
> 
> package4

1. The exclude ignored, it trying to install package4 even that it in the exclude line.  
I tried also to read the package in different way:  
_with\_items:_

_- package1_  
_- package2_  
_- package3_

_- package4_

Still dont work.

1. It give me a message that ‘with\_lines’ & ‘with\_items’ deprecation and should use the ‘loop’ instead. when I change it to ‘loop’ if said that :

> Invalid data passed to ‘loop’ it requires a list, got this instead: cat "/path/to/file/yum\_packages.txt"

‘loop’ work okay with a fix list like:  
loop:

- package1
- package2  
…  
How can I read with ‘loop’ data from a file?

Thanks.
