Module 由于周期性依赖关系,模块不工作的单独ansible角色dnf enablerepo

Module 由于周期性依赖关系,模块不工作的单独ansible角色dnf enablerepo,module,ansible,dnf,Module,Ansible,Dnf,因此,我正在与RHEL8合作,在我们的私有repos下有许多galaxy角色,这些角色可以安装和配置nginx、php、solr等。因此,在我们的nginx角色中,例如,有一个函数,因为我们希望更新的版本1.18,而不是默认的1.14: - name: "Disable - Reset Stream Modules Not Wanted" dnf: disablerepo: "{{ item.stream }}:{{ item.version }}&qu

因此,我正在与RHEL8合作,在我们的私有repos下有许多galaxy角色,这些角色可以安装和配置nginx、php、solr等。因此,在我们的nginx角色中,例如,有一个函数,因为我们希望更新的版本1.18,而不是默认的1.14:

- name: "Disable - Reset Stream Modules Not Wanted"
  dnf:
    disablerepo: "{{ item.stream }}:{{ item.version }}"
    state: absent
  when: item.stream == "nginx"
  with_items: "{{ disable_module_streams }}"
这很好,但由于启用的模块依赖关系(未安装软件包)导致故障,导致无法启用其他nginx流

TASK [foo.nginx : Disable - Reset Stream Modules Not Wanted] ***************************************************************************************
ok: [localhost] => (item={'stream': 'nginx', 'version': 1.14})
skipping: [localhost] => (item={'stream': 'php', 'version': 7.2})

TASK [foo.nginx : Enable - Stream Module Packages] *************************************************************************************************
failed: [localhost] (item={'stream': 'nginx', 'version': 1.18}) => {"ansible_loop_var": "item", "changed": false, "failures": ["nginx:1.18 Problems in request:\nModular dependency problems with Defaults:\n\n Problem: conflicting requests\n  - module php:7.2:820181215112050:76554e01-0.x86_64 requires module(nginx:1.14), but none of the providers can be installed\n  - module nginx:1.14:820181214004940:9edba152-0.x86_64 conflicts with module(nginx:1.18) provided by nginx:1.18:8030020200529144723:30b713e6-0.x86_64\n  - module nginx:1.18:8030020200529144723:30b713e6-0.x86_64 conflicts with module(nginx:1.14) provided by nginx:1.14:820181214004940:9edba152-0.x86_64\n  - module nginx:1.14:8000020190830002848:f8e95b4e-0.x86_64 conflicts with module(nginx:1.18) provided by nginx:1.18:8030020200529144723:30b713e6-0.x86_64\n  - module nginx:1.18:8030020200529144723:30b713e6-0.x86_64 conflicts with module(nginx:1.14) provided by nginx:1.14:8000020190830002848:f8e95b4e-0.x86_64"], "item": {"stream": "nginx", "version": 1.18}, "msg": "Failed to install some of the specified packages", "rc": 1, "results": []}
skipping: [localhost] => (item={'stream': 'php', 'version': 7.4})
我想我可以使用
skip\u breaked:yes
标志来避免这种情况,并在ansible和install之外简单地管理模块依赖项,因为我知道我无论如何都会满足依赖项,但结果仍然失败。 要做到这一点,唯一的方法是在角色之外同时禁用/启用依赖模块(在其自己的迷你角色中或作为任务),并执行以下操作:

这是最好的方法吗

注意:对于这种特定情况,nginx和php模块流彼此有一些依赖关系,因此更改ansible角色的顺序没有任何效果。我确信还有其他模块存在类似问题

更新:标题编辑,希望能更有意义

- name: "Enable - Enable Stream Modules Needed"
  dnf:
    enablerepo: "@nginx:1.18,@php:7.4"
    state: present
  with_items: "{{ enable_module_streams }}"