如何在 Ansible 中比较内核(或其他)版本号 [英] How to compare kernel (or other) version numbers in Ansible

查看:23
本文介绍了如何在 Ansible 中比较内核(或其他)版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我正在开发的角色,我需要验证内核版本是否大于特定版本.

For a role I'm developing I need to verify that the kernel version is greater than a particular version.

我已经找到了 ansible_kernel 事实,但是有没有一种简单的方法可以将其与其他版本进行比较?我想我可能会手动分解 . 上的版本字符串并比较数字,但我什至找不到友好的过滤器来分解版本字符串,所以我不知所措.

I've found the ansible_kernel fact, but is there an easy way to compare this to other versions? I thought I might manually explode the version string on the .'s and compare the numbers, but I can't even find a friendly filter to explode the version string out, so I'm at a loss.

推荐答案

有一个 测试:

{{ ansible_distribution_version is version('12.04', '>=') }}

{{ sample_version_var is version('1.0', operator='lt', strict=True) }}

这篇关于如何在 Ansible 中比较内核(或其他)版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆