ansible 将内核版本与 "generic" 进行比较
ansible compare kernel versions with "generic" in them
阅读本文并处理我在那里发现的内容后: 我 运行 遇到了问题。
如果内核版本是这样的怎么办:4.15.0-173-generic
?
如果我这样做:
- name: Compare kernel version
set_fact:
checks_out: "{{ ansible_kernel is version('4.15.0-173.456', '>=') }}"
这给出了一个错误:
FAILED! => {"msg": "Version comparison: '<' not supported between instances of 'str' and 'int'"}
在检查特定内核版本时,例如为了调查主机是否易受 CVE 攻击,这会造成阻碍。
如果我删除 .456
它可以工作,但我觉得这将是通用内核仍然需要更新和重新启动的情况。
我该如何解决这个问题?
- name: Compare kernel version
set_fact:
checks_out: "{{ ansible_facts.kernel | replace('-generic', '') is version('4.15.0-173.456', '>=') }}"
阅读本文并处理我在那里发现的内容后:
如果内核版本是这样的怎么办:4.15.0-173-generic
?
如果我这样做:
- name: Compare kernel version
set_fact:
checks_out: "{{ ansible_kernel is version('4.15.0-173.456', '>=') }}"
这给出了一个错误:
FAILED! => {"msg": "Version comparison: '<' not supported between instances of 'str' and 'int'"}
在检查特定内核版本时,例如为了调查主机是否易受 CVE 攻击,这会造成阻碍。
如果我删除 .456
它可以工作,但我觉得这将是通用内核仍然需要更新和重新启动的情况。
我该如何解决这个问题?
- name: Compare kernel version
set_fact:
checks_out: "{{ ansible_facts.kernel | replace('-generic', '') is version('4.15.0-173.456', '>=') }}"