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

查看:591
本文介绍了如何在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 value, but is there an easy way to compare this to other versions? I thought I might manually explode the version string on the '.'s & compare the numbers, but I can't even find a friendly filter to explode the version string out, so I'm at a loss.

谢谢.

T

推荐答案

有一个为此进行测试:

{{ ansible_distribution_version | version_compare('12.04', '>=') }}

{{ sample_version_var | version_compare('1.0', operator='lt', strict=True) }}

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

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