Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor distro detection #645

Merged
merged 2 commits into from
Dec 6, 2024
Merged

Conversation

Revalioli
Copy link
Contributor

The ansible fact ansible_distribution work fine to detect if a Seapath distribution is Debian or CentOS, but doesn't work well for Yocto Seapath.
With Yocto, ansible_distribution will be set to the value of DISTRO_NAME. As it is usual to have multiple distro configurations in a Yocto project, with different DISTRO_NAME values, ansible_distribution wouldn't have a deterministic value for every Yocto Seapath build.

With yocto scarthgap, the /etc/os-release file has a field CPE_NAME which will always contains "openembedded".
It can then be used as a reliable way to detect a Yocto Seapath distribution.

This PR propose a new role, detect_seapath_distro, that will set a fact seapath_distro with a value of either Yocto, Debian or CentOS. To detect the correct distro, is uses ansible_distribution* facts and the /etc/os-release file.
The new fact is then used everywhere a task needs to know the seapath distribution of the host.

@Revalioli Revalioli added the enhancement New feature or request label Nov 29, 2024
@Revalioli
Copy link
Contributor Author

Note: currently only the last two commits are for this PR. Other commits belongs to #643, and will be removed when #643 is merged.

@Revalioli Revalioli force-pushed the refactor-distro-detection branch 3 times, most recently from 816fd8b to 24eb966 Compare December 5, 2024 11:25
@Revalioli Revalioli marked this pull request as ready for review December 5, 2024 11:26
@Revalioli
Copy link
Contributor Author

PR is now rebased on the latest debiancentos commits.

Note that the change from ansible_distribution to seapath_distro variable was done everywhere in the repo except for specific Debian playbooks and templates (examples: debian_physical_machine role, seapath_setup_prerequisdebian.yaml playbook, groups and users configuration template files). Only playbooks and roles that are explicitly made for Debian or CentOS are concerned.

If you think ansible_distribution should be changed anyway don't hesitate to comment

Revalioli added a commit to seapath/ansible-role-systemd-networkd that referenced this pull request Dec 5, 2024
Use new seapath_distro fact, added in [1], instead of
ansible_distribution fact.

[1]: seapath/ansible#645

Signed-off-by: Elinor Montmasson <[email protected]>
@insatomcat
Copy link
Member

Can you create the meta/main.yml file in this new role so that it's uploadable to galaxy? thx.

roles/add_livemigration_user/README.md Outdated Show resolved Hide resolved
roles/ceph_prepare_installation/README.md Outdated Show resolved Hide resolved
@Revalioli Revalioli force-pushed the refactor-distro-detection branch from 24eb966 to bee5516 Compare December 5, 2024 13:50
@Revalioli
Copy link
Contributor Author

Can you create the meta/main.yml file in this new role so that it's uploadable to galaxy? thx.

@insatomcat Thanks, done
Note that I kept the platforms section to match other roles, but it seems that recent version of Ansible Galaxy doesn't use this metadata anymore, see ansible/galaxy#3292

@Revalioli Revalioli force-pushed the refactor-distro-detection branch from bee5516 to 900a3a6 Compare December 5, 2024 14:08
@ebail
Copy link
Member

ebail commented Dec 5, 2024

Hi @insatomcat ! Have you got some comments on that ? Thanks

eroussy
eroussy previously approved these changes Dec 5, 2024
eroussy
eroussy previously approved these changes Dec 5, 2024
Add role to detect which Seapath distribution each host is running.
It will set a "seapath_distro" fact that can then be used in subsequent
plays for conditional behaviour depending on the distro.

Signed-off-by: Elinor Montmasson <[email protected]>
Use the new detect_seapath_distro role to detect the Seapath
distribution and conditionally execute distro specific tasks.
This replaces the use of the ansible_distribution fact. This fact cannot
be used with Yocto Seapath as it depends on the DISTRO_NAME configured
during build.

This new role sets a seapath_distro fact to use by playbooks and roles.
* Replace the use of ansible_distribution in roles by seapath_distro.
  Also add detect_seapath_distro as requirement for these roles
  to make sure seapath_distro is always set.
* Call the detect_seapath_distro role and use seapath_distro
  in playbooks needing it.
* Rename "Seapath_host_Yocto_distribution.yml" vars files to "Yocto.yml"
  to match and use seapath_distro.
* Modify the ceph-ansible patches to use detect_seapath_distro.

Signed-off-by: Elinor Montmasson <[email protected]>
@Revalioli Revalioli merged commit 711a16f into debiancentos Dec 6, 2024
4 checks passed
@Revalioli Revalioli deleted the refactor-distro-detection branch December 6, 2024 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants