Ah okay, cool :) Hmm, well, does my solution above still not stand? I mean, with your above pseudo code, the second task will install the package if it's not present, in doing so, it will install the latest package. The third task will just ensure any packages in the list installed are at their latest available version.
This achieves exactly the same as my suggested task above, also making the initial task (the rpm command) pointless. Kind Regards, Calum On Tuesday, 15 December 2015 16:14:17 UTC, 张斌 wrote: > > > Thanks Calum. I already went through the docs, and googled. I know how > to loop with items and install with yum. > > But i want to a list of RPMs to be check and install/upgrade, not sure if > there is a way to do so. > > how to loop with_items: for the three steps ? Perhaps something like the > following > > with_items: {{items}} > > - name: Check if Package is installed > command: rpm -q {{item}} > register: rpm_check > failed_when: rpm_check.rc > 1 > changed_when: no > > - name: Install Package only if not installed > yum: name={{item}} state=present > when: rpm_check.rc == 1 > > - name: Update Package only if installed > yum: name={{item}} state=latest update_cache=yes > when: rpm_check.rc == 0 > -- 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-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/98fea921-bbf5-461e-8e3f-3a7b5b3c75c6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.