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
- 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.
- 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.