Distribution Version detection: please test and add more test cases

Hello,

the code that fills the ‘ansible_distribution_*’ variables grew fairly complex, so I cleaned it up. This was merged to devel (for 2.2) today, see https://github.com/ansible/ansible/pull/15221
While cleaning it up I started some test cases to make refactoring the code easier, see https://github.com/ansible/ansible/pull/15420

Please check your old/rare distributions still give the same result with the new code and add (or send me) more testcases so whatever you run won’t be broken by further refactoring. So far there are ubuntu/debian/opensuse/SLES/coreos, but it would be good to have more, especially different versions of RHEL/Oracle/ec2/…
To generate test cases, there is a script in hacking/tests/gen_distribution_version_testcase.py that outputs the format needed for the tests, assuming it runs locally on the machine with working ansible.

Depending on the number of tests and input it might be an option to further simplify the code. Currently the logic is still funny and reads some files under /etc several times, depending which distribution it does or does not find.

Cheers,
Robin

I had to patch your script to be able to run it on rhel-6.x (python2.6) and also on MacOSX some ansible_facts are not available, so i added a try-block.
I attach the results and the patch.

(attachments)

centos-6.7 (629 Bytes)
macosx-10.11.4 (306 Bytes)
rhel-6.7 (691 Bytes)
rhel-7.2 (1.04 KB)
patch.txt (897 Bytes)

Hi Bernhard,

thanks for the tests and patch!

MacOSX is different in the implementation, so it doesn’t fix the current test structure. That code there is much cleaner and needs less refactoring, so I wouldn’t rewrite the test-structure for that.

RedHat parsing is broken in devel, I just pushed a fix together with the tests to https://github.com/ansible/ansible/pull/15663

There is also a patch that (probably) fixes Arch and VMwareESX. Testcases for those would be nice as well.

Cheers,

Robin