linux-system-roles / network

An ansible role to configure networking
https://linux-system-roles.github.io/network/
BSD 3-Clause "New" or "Revised" License
238 stars 106 forks source link

refactor: improve support for ostree systems #655

Closed richm closed 1 year ago

richm commented 1 year ago

The dependency on ansible.utils.update_fact is causing issue with some users who now must install that collection in order to run the role, even if they do not care about ostree.

The fix is to stop trying to set ansible_facts.pkg_mgr, and instead force the use of the ostree package manager with the package: module use: option. The strategy is - on ostree systems, set the flag __$ROLENAME_is_ostree if the system is an ostree system. The flag will either be undefined or false on non-ostree systems. Then, change every invocation of the package: module like this:

- name: Ensure required packages are present
  package:
    name: "{{ __$ROLENAME_packages }}"
    state: present
    use: "{{ (__$ROLENAME_is_ostree | d(false)) |
      ternary('ansible.posix.rhel_rpm_ostree', omit) }}"

This should ensure that the use: parameter is not used if the system is non-ostree. The goal is to make the ostree support as unobtrusive as possible for non-ostree systems. The user can also set __$ROLENAME_is_ostree: true in the inventory or play if the user knows that ostree is being used and wants to skip the check. Or, the user is concerned about the performance hit for ostree detection on non-ostree systems, and sets __$ROLENAME_is_ostree: false to skip the check. The flag __$ROLENAME_is_ostree can also be used in the role or tests to include or exclude tasks from being run on ostree systems.

This fix also improves error reporting in the get_ostree_data.sh script when included roles cannot be found.

Signed-off-by: Rich Megginson rmeggins@redhat.com

codecov[bot] commented 1 year ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (c7a31e7) 43.31% compared to head (367ab57) 43.31%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #655 +/- ## ======================================= Coverage 43.31% 43.31% ======================================= Files 13 13 Lines 3068 3068 Branches 394 394 ======================================= Hits 1329 1329 Misses 1739 1739 ``` | [Flag](https://app.codecov.io/gh/linux-system-roles/network/pull/655/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=linux-system-roles) | Coverage Δ | | |---|---|---| | [sanity](https://app.codecov.io/gh/linux-system-roles/network/pull/655/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=linux-system-roles) | `19.82% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=linux-system-roles#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

richm commented 1 year ago

[citest]

richm commented 1 year ago

@liangwen12year I've noticed that tests_network_state.yml is failing with recent rhel8 and rhel9 - the task name: "** TEST check resolvectl" fails - example.com is not in the resolvectl output - not sure if something has changed with recent rhel8/rhel9.

richm commented 1 year ago

[citest]