Ansible 2.7 - what replace yum+with_lines'

710 views
Skip to first unread message

Shlomit Afgin

unread,
Dec 5, 2018, 9:37:00 AM12/5/18
to Ansible Project

Hi,


I update Ansible to 2.7. 

Now when I run it I get deprecated warning.

I trying to install with yum the packages that  list in the file yum_packages.txt

I have:


- name: install Basic Packages to specific version

  yum:

    name: "{{item}}"

    state: present

    skip_broken: yes

  with_lines: cat /etc/ansible/path/files/yum_packages.txt


I got an error:


[DEPRECATION WARNING]: Invoking "yum" only once while using a loop via squash_actions is deprecated.

Instead of using a loop to supply multiple items and specifying `name: {{item}}`, please use `name:

u'cat /etc/ansible/path/files/yum_packages.txt'` and remove the loop. This

feature will be removed in version 2.11. Deprecation warnings can be disabled by setting

deprecation_warnings=False in ansible.cfg.


I tried to rewrite it but I did not success.

How can I replace code so it will work with Ansible 2.7 with no deprecated warning


Thanks.

Jonathan Lozada De La Matta

unread,
Dec 5, 2018, 9:40:36 AM12/5/18
to ansible...@googlegroups.com
check your ansible.cfg there's an option to squash the loop/list in one line. Just remove that.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/25b9a2f6-a5f2-46a5-a52f-719b946dbe99%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Jonathan lozada de la matta

AUTOMATION PRACTICE



 

Matt Martz

unread,
Dec 5, 2018, 10:16:39 AM12/5/18
to ansible...@googlegroups.com
You can pretty much update it to be:

yum:
  name: "{{ lookup('lines', 'cat /etc/ansible/path/files/yum_packages.txt') }}"

The message indicating it looks a little misleading there.  I'll look to see if there is a way to improve it at all.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/25b9a2f6-a5f2-46a5-a52f-719b946dbe99%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages