Uploaded image for project: 'Product Technical Learning'
  1. Product Technical Learning
  2. PTL-5026

RH294-194: Example of how to use loops shows a bad practice

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • RH294 - RHEL9.0-en-1-20221012
    • RH294
    • None
    • 4
    • en-US (English)

      URL:
      Reporter RHNID:
      Section: -
      Language: en-US (English)||||||||
      Workaround:

      Description: In ch04s02 GE "Writing Loops and Conditional Tasks", the example of how to write a loop in step 3.2 uses ansible.builtin.dnf to operate on a list of packages.

      While this technically works, it's also terribly inefficient since it essentially runs the ansible.builtin.dnf module once for each package.  This is slower than simply providing a list of package names to the module's name parameter. It's also true that if two of those packages depend upon each other, the task will fail because the dependencies will not be met.

      We used to have an admonition box somewhere telling folks about the negative performance implications of using ansible.builtin.dnf with a loop, but I'm not seeing it offhand.

      We should change this activity so that it does something that is actually a recommended practice as opposed to what it does now, which is not a recommended practice.

              rht-sbonnevi Steven Bonneville
              ricardodacosta Ricardo da Costa (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: