Comments (14)
Instead of running uname -r
, the same value is in the ansible_kernel
fact.
Additionally, is this just doing a string comparison? Maybe something like this...?
---
# This playbook checks kernel version
- name: Check Kernel Version
hosts: all
gather_facts: yes
vars:
required_kernel_version: '3.13.0'
required_kernel_patch: '34'
required_kernel_variant: 'generic'
tasks:
- name: Get Kernel Parts
set_fact:
kernel_version: "{{ ansible_kernel.split('-')[0] }}"
kernel_patch: "{{ ansible_kernel.split('-')[1] }}"
kernel_variant: "{{ ansible_kernel.split('-')[2] }}"
- name: Check Kernel Version
fail:
msg: >
Wrong kernel Version found
[ {{ ansible_kernel }} < {{ [required_kernel_version, required_kernel_patch, required_kernel_variant]|join('-') }} ]
Resolve this issue before continuing.
when: kernel_version | version_compare(required_kernel_version, '<') or kernel_patch | version_compare(required_kernel_patch, '<') or kernel_variant != required_kernel_variant
from ansible-lxc-rpc.
That fail...when
won't work when the kernel revs to 3.14.0-0-generic
. Stupid version numbers.
Breaking into three separate checks:
- name: Check Kernel Version
fail:
msg: >
Wrong kernel Version found
[ {{ ansible_kernel }} < {{ [required_kernel_version, required_kernel_patch, required_kernel_variant]|join('-') }} ]
Resolve this issue before continuing.
when: kernel_version | version_compare(required_kernel_version, '<')
- name: Check Kernel Patch
fail:
msg: >
Wrong kernel Version found
[ {{ ansible_kernel }} < {{ [required_kernel_version, required_kernel_patch, required_kernel_variant]|join('-') }} ]
Resolve this issue before continuing.
when: kernel_patch | version_compare(required_kernel_patch, '<')
- name: Check Kernel Variant
fail:
msg: >
Wrong kernel Version found
[ {{ ansible_kernel }} < {{ [required_kernel_version, required_kernel_patch, required_kernel_variant]|join('-') }} ]
Resolve this issue before continuing.
when: kernel_variant != required_kernel_variant
from ansible-lxc-rpc.
@byronmccollum any reason we have to check all 3 individually?
If we just do a ">" check it seems to do that for you.
Adjusted to use the ansible_kernel fact though - saves on the "uname -r"
from ansible-lxc-rpc.
If it's a string compare...wouldn't 3.13.34
be less than 3.4.34
?
from ansible-lxc-rpc.
ahh true. it seems really inefficient to have to make 3 checks for 1 simple check though.
from ansible-lxc-rpc.
Well, you need to check if kernel_version > required_kernel_version
, and if so, you really don't care about kernel_patch
.
But when kernel_version == required_kernel_version
, then you need to check the kernel_patch
.
from ansible-lxc-rpc.
http://docs.ansible.com/playbooks_variables.html#version-comparison-filters is what we really want; this is common enough it's already been solved with a single comparison filter.
from ansible-lxc-rpc.
version_compare
trips up on the variant. Unless you don't care about that.
from ansible-lxc-rpc.
>>> from distutils.version import LooseVersion
>>> LooseVersion("3.13.0-34") < LooseVersion("3.13.0-36")
True
>>> LooseVersion("3.13.0-12") < LooseVersion("3.13.0-2")
False
>>> LooseVersion("3.13.0-2") < LooseVersion("3.13.0-12")
True
>>> LooseVersion("3.13.0-2-generic") < LooseVersion("3.13.0-12-generic")
True
>>> LooseVersion("3.13.0-2-generic") < LooseVersion("3.13.0-1-generic")
False
>>> LooseVersion("3.13.0-2-generic") < LooseVersion("3.4.0-1-generic")
False
Variants don't break the loose version_compare (which uses distutils.version.LooseVersion, according to this: https://github.com/ansible/ansible/blob/devel/lib/ansible/runner/filter_plugins/core.py#L30), and IMO we definitely don't care about comparing variants because A) versioning across variants makes no sense, they're different types of kernels, and B) I can't imagine we have any interest whatsoever in using !generic Ubuntu kernels.
So I say use the version_compare filter without strict=True and call it a job welld one.
from ansible-lxc-rpc.
Well hot damn. Problem solved.
from ansible-lxc-rpc.
You could recreate and pad out with 0's up to 3chars using zfill - ensuring that 014 > 004 in a string comparison, but thats probably more effort than its worth. I can't think of another sensible way to do this, do you want to make a PR against master with this changed to do the 3 checks.
from ansible-lxc-rpc.
as pointed out by @Apsu...
when: ansible_kernel | version_compare(required_kernel, '<')
...should do the trick.
from ansible-lxc-rpc.
I still feel like it needs to account for the variant in some manner.
@Apsu, do you think that it should also fail if the kernel is not generic
?
from ansible-lxc-rpc.
PR #100
from ansible-lxc-rpc.
Related Issues (20)
- XML Tempest tests are failing
- Please add the DiskFilter to the nova default scheduler option HOT 1
- Jenkins jobs queuing indefinitely HOT 2
- deployment takes ~20mins to create containers HOT 2
- rsyslog container safe_upgrade tasks add ~5 mins to deployment time
- openjdk-7-jre installation into multiple containers adds ~20mins to deployment time
- ansible logging: keystone user/tenant/role changes could do with improvement
- Automatically register swift monitors HOT 1
- jenkins: add ansible timestamp callback plugin HOT 1
- jenkins: build fresh container base image(s) on a daily basis
- The container build/setup process is slow and clunky HOT 1
- Update glance policy.json with new permissions defaults.
- glance module doesn't allow for non-public endpoint types.
- neutron module doesn't allow for non-public endpoint types.
- Ansible lint'ing
- Keystone is not using the proper cache vip for dogpile cache
- tempest_resources role creates subnet w/ no name
- kibana: add more dashboards with different user viewpoints
- holland-commvault deb has a dependency on holland HOT 1
- Instance of hardcoded secret HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible-lxc-rpc.