0

因此,我正在使用 RHEL8,并且在我们的私有存储库下拥有许多 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_broken: yes标志来避免这种情况,并简单地管理 ansible 之外的模块依赖项并安装知道无论如何我都会满足依赖项,但它仍然会因此失败。这样做的唯一方法是在角色之外同时禁用/启用依赖模块(在其自己的迷你角色中或仅作为任务)并执行以下操作:

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

这是最好的方法吗?

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

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

4

0 回答 0