Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-22793

ansible-core dependencies skipped

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Undefined Undefined
    • None
    • rhel-8.9.0
    • ansible-core
    • None
    • None
    • Important
    • rhel-sst-ansible
    • None
    • False
    • Hide

      None

      Show
      None
    • None
    • Red Hat Enterprise Linux
    • None
    • None
    • None
    • x86_64
    • None

      ansible-core 2.15.3

      Recently upgrade to ansible-core 2.15 and some of my roles are no longer included even though they are in the meta dependencies list.

      To demonstrate this, I have 3 role
      role1
      role2
      role3

      all three roles have a single task

      • name: Now in {{ role_name }}
        debug:
        msg: “running tasks in {{ role_name }}”

      role1 has meta/main.yml contents

      dependencies:

      • role: role2
        when: doit|default(True)
      • role: role3

      role2 has meta/main.yml contents
      dependencies:

      • role: role3

      running a playbook that includes role1 I get the following

      playbook.yml -e ‘{ doit: True }’
      TASK [role3 : Now in role3] ******************
      ok: [myhost] =>

      { “msg”: “running tasks in role3” }

      TASK [role2 : Now in role2] ****************
      ok: [myhost] =>

      { “msg”: “running tasks in role2” }

      TASK [role1 : Now in role1] ****************
      ok: [myhost] =>

      { “msg”: “running tasks in role1” }

      I think this occurs for the following logic

      1. role1 is invoked due to role1 being specified in the playbook.yml
      2. role1 dependencies are invoked prior to role1 tasks
      3. role2 is invoked because doit is True
      4. role2 dependencies are invoked prior to role2 tasks
      5. role3 is invoked
      6. role3 tasks are run (first task)
      7. role2 tasks are run (second task)
      8. role3 would be invoked from the role1 dependencies, but since it has already been invoked from the role2 dependecies, it is ignored
      9. role1 tasks are run (third task)

      This is what I would expect, and is what happened before I upgraded to ansible-core 2.15
      The issue is that if doit is False, role3 is never invoked.

      playbook.yml -e ‘{ doit: False }’

      TASK [role3 : Now in role3] ****************
      skipping: [myhost]
      TASK [role2 : Now in role2] ****************
      skipping: [myhost]
      TASK [role1 : Now in role1] ****************
      ok: [myhost] =>

      { “msg”: “running tasks in role1” }

      It seems that the dependencies in role1 where role3 is included is masked by role2 being skipped. what used to happen is

      playbook.yml -e ‘{ doit: False }’

      TASK [role3 : Now in role3] ****************
      skipping: [myhost]
      TASK [role2 : Now in role2] ****************
      skipping: [myhost]
      TASK [role3 : Now in role3] ******************
      ok: [myhost] =>

      { “msg”: “running tasks in role3” }

      TASK [role1 : Now in role1] ****************
      ok: [myhost] =>

      { “msg”: “running tasks in role1” }

      The dependency of role3 from the meta/main.yml of role1 has no when clause, and since it has not been invoked yet, it gets invoked and its dependencies AND tasks are run.

       

      Up stream fix in 2.15.5
      Community forum 
      https://forum.ansible.com/t/role-dependencies-not-being-fulfilled/3437

      git pull request
      https://github.com/ansible/ansible/pull/81668

              dsavinea@redhat.com Dimitri Savineau
              erempel@uvic.ca Evan Rempel (Inactive)
              Dimitri Savineau Dimitri Savineau
              Matt Clay Matt Clay
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: