Repository: ansible/ansible

Issue:
Ansible_distribution for Ubuntu 10.04 misreported as Mandriva
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
setup

##### ANSIBLE VERSION
```
ansible 2.4.0.0
  config file = None
  configured module search path = ['/home/r2d2/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/r2d2/setup/.venv/lib/python3.5/site-packages/ansible
  executable location = /home/r2d2/setup/.venv/bin/ansible
  python version = 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609]

```

##### CONFIGURATION
```
ANSIBLE_FORCE_COLOR(/home/r2d2/setup/lautus_ansible/ansible.cfg) = True
ANSIBLE_SSH_CONTROL_PATH(/home/r2d2/setup/lautus_ansible/ansible.cfg) = %(directory)s/%%C
ANSIBLE_SSH_PIPELINING(/home/r2d2/setup/lautus_ansible/ansible.cfg) = True
CACHE_PLUGIN(/home/r2d2/setup/lautus_ansible/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/home/r2d2/setup/lautus_ansible/ansible.cfg) = .facts_cache
CACHE_PLUGIN_TIMEOUT(/home/r2d2/setup/lautus_ansible/ansible.cfg) = 86400
DEFAULT_GATHERING(/home/r2d2/setup/lautus_ansible/ansible.cfg) = smart
DEFAULT_HOST_LIST(/home/r2d2/setup/lautus_ansible/ansible.cfg) = ['/home/r2d2/setup/lautus_ansible/inventory']
DEFAULT_MANAGED_STR(/home/r2d2/setup/lautus_ansible/ansible.cfg) = This file is managed by Lautus' Ansible scripts and changes will be overwritten.
DEFAULT_ROLES_PATH(/home/r2d2/setup/lautus_ansible/ansible.cfg) = ['/home/r2d2/setup/lautus_ansible/roles', '/home/r2d2/setup/lautus_ansible/playbook_roles']
DEFAULT_STDOUT_CALLBACK(/home/r2d2/setup/lautus_ansible/ansible.cfg) = debug
DEFAULT_TIMEOUT(/home/r2d2/setup/lautus_ansible/ansible.cfg) = 30
MERGE_MULTIPLE_CLI_TAGS(/home/r2d2/setup/lautus_ansible/ansible.cfg) = True
```

##### OS / ENVIRONMENT
Management node (as per lsb_release -a): 
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.3 LTS
Release:	16.04
Codename:	xenial

Target node (as per lsb_release -a):
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 10.04.4 LTS
Release:        10.04
Codename:       lucid


##### SUMMARY
As of 2.4, the ansible_distribution of all our Ubuntu 10.04 hosts gets reported as Mandriva

##### STEPS TO REPRODUCE
```
ansible -m setup some-ubuntu-10.04-host.somewhere.net | grep ansible_distribution
```

##### EXPECTED RESULTS
An ansible_distribution value of 'Ubuntu'

##### ACTUAL RESULTS
```
        "ansible_distribution": "Mandriva",
        "ansible_distribution_file_parsed": false,
        "ansible_distribution_file_path": "/etc/lsb-release",
        "ansible_distribution_file_variety": "Mandriva",
        "ansible_distribution_major_version": "10",
        "ansible_distribution_release": "lucid",
        "ansible_distribution_version": "10.04",
```



Discussion:
cc @david_obrien
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Can you paste the content of /etc/lsb-release ? 
@alikins could it be also a side effect of the order issue you spoke on #30623 ?
@mscherer

~$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION="Ubuntu 10.04.4 LTS"
If folks seeing this are running from a source checkout, try running:
```
   hacking/tests/gen_distribution_version_testcase.py
``` 

It needs to run locally on the system that is detecting facts incorrectly.

Please paste that output here. And ideally, the current 'actual' fact collected and what it was expected to be.
@mscherer re https://github.com/ansible/ansible/issues/30693#issuecomment-331406825

Shouldn't be, afaict. The distribution facts do not require any shared facts via collected_facts, so it shouldn't matter.
The check for /etc/os-release seems to be getting skipped and the last check that worked ends up being the mandriva lsb-release check.

maybe ansible.module_utils.facts.system.distribution.DistributionFiles.parse_distribution_file_Debian() is failing for some reason? 

What does /etc/os-release look like?
If you have a source checkout on a machine that gets the facts wrong, try running 'hacking/test-module -m lib/ansible/modules/setup.py' on that system and pastebin the output.

And in particular, look for any errors/warnings/exceptions in the output ('exc: some error message', for ex)
I'm guessing Ubuntu 10.04 doesn't have a /etc/os-release ?

I can reproduce a similar fail in test cases if there is just /etc/lsb-release and no /etc/os-release

Resolving patch:
diff --git a/lib/ansible/module_utils/facts/system/distribution.py b/lib/ansible/module_utils/facts/system/distribution.py
--- a/lib/ansible/module_utils/facts/system/distribution.py
+++ b/lib/ansible/module_utils/facts/system/distribution.py
@@ -69,6 +69,7 @@ class DistributionFiles:
         {'path': '/etc/SuSE-release', 'name': 'SUSE'},
         {'path': '/etc/gentoo-release', 'name': 'Gentoo'},
         {'path': '/etc/os-release', 'name': 'Debian'},
+        {'path': '/etc/lsb-release', 'name': 'Debian'},
         {'path': '/etc/lsb-release', 'name': 'Mandriva'},
         {'path': '/etc/altlinux-release', 'name': 'Altlinux'},
         {'path': '/etc/sourcemage-release', 'name': 'SMGL'},


Test patch:
diff --git a/test/units/module_utils/test_distribution_version.py b/test/units/module_utils/test_distribution_version.py
--- a/test/units/module_utils/test_distribution_version.py
+++ b/test/units/module_utils/test_distribution_version.py
@@ -418,6 +418,26 @@
             "distribution_version": "16.04"
         }
     },
+    {
+        'name': "Ubuntu 10.04 guess",
+        'input':
+            {
+                '/etc/lsb-release': """DISTRIB_ID=Ubuntu
+DISTRIB_RELEASE=10.04
+DISTRIB_CODENAME=lucid
+DISTRIB_DESCRIPTION="Ubuntu 10.04.4 LTS
+"""
+            },
+        'platform.dist': ('Ubuntu', '10.04', 'lucid'),
+        'result':
+            {
+                'distribution': u'Ubuntu',
+                'distribution_major_version': u'10',
+                'distribution_release': u'lucid',
+                "os_family": "Debian",
+                'distribution_version': u'10.04'
+            }
+    },
     {
         'name': "Ubuntu 14.04",
         'input': {