distribution: Add Amazon Linux distribution facts (#73767)

* Update Amazon Linux Distribution facts gathering logic
* Update tests

Fixes: #73742

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/73805/head
Abhijeet Kasurde 4 years ago committed by GitHub
parent 78d3810fdf
commit fb66b4ffbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
minor_changes:
- distribution - add facts about Amazon Linux Distribution facts (https://github.com/ansible/ansible/issues/73742).

@ -59,6 +59,7 @@ class DistributionFiles:
{'path': '/etc/redhat-release', 'name': 'RedHat'},
{'path': '/etc/vmware-release', 'name': 'VMwareESX', 'allowempty': True},
{'path': '/etc/openwrt_release', 'name': 'OpenWrt'},
{'path': '/etc/os-release', 'name': 'Amazon'},
{'path': '/etc/system-release', 'name': 'Amazon'},
{'path': '/etc/alpine-release', 'name': 'Alpine'},
{'path': '/etc/arch-release', 'name': 'Archlinux', 'allowempty': True},
@ -222,9 +223,17 @@ class DistributionFiles:
if 'Amazon' not in data:
return False, amazon_facts
amazon_facts['distribution'] = 'Amazon'
version = [n for n in data.split() if n.isdigit()]
version = version[0] if version else 'NA'
amazon_facts['distribution_version'] = version
if path == '/etc/os-release':
version = re.search(r"VERSION_ID=\"(.*)\"", data)
if version:
amazon_facts['distribution_version'] = version.group(1)
amazon_facts['distribution_major_version'] = version.group(1).split('.')[0]
amazon_facts['distribution_minor_version'] = version.group(1).split('.')[1]
else:
version = [n for n in data.split() if n.isdigit()]
version = version[0] if version else 'NA'
amazon_facts['distribution_version'] = version
return True, amazon_facts
def parse_distribution_file_OpenWrt(self, name, data, path, collected_facts):

@ -0,0 +1,34 @@
{
"platform.dist": [
"",
"",
""
],
"input": {
"/etc/system-release": "Amazon Linux release 2",
"/etc/os-release": ""
},
"name": "Amazon Linux 2",
"result": {
"distribution_release": "NA",
"distribution": "Amazon",
"distribution_major_version": "2",
"os_family": "RedHat",
"distribution_version": "2"
},
"distro": {
"id": "amzn",
"version": "2",
"codename": "",
"os_release_info": {
"name": "Amazon Linux AMI",
"ansi_color": "0;33",
"id_like": "rhel fedora",
"version_id": "2",
"pretty_name": "Amazon Linux release 2",
"version": "2",
"home_url": "",
"id": "amzn"
}
}
}

@ -0,0 +1,40 @@
{
"name": "Amazon 2016.03",
"platform.release": "4.14.94-73.73.amzn1.x86_64",
"result": {
"distribution_release": "NA",
"distribution": "Amazon",
"distribution_major_version": "2016",
"distribution_minor_version": "03",
"os_family": "RedHat",
"distribution_version": "2016.03"
},
"platform.dist": [
"amzn",
"2016.03",
""
],
"input": {
"/etc/os-release": "NAME=\"Amazon Linux AMI\"\nVERSION=\"2016.03\"\nID=\"amzn\"\nID_LIKE=\"rhel fedora\"\nVERSION_ID=\"2016.03\"\nPRETTY_NAME=\"Amazon Linux AMI 2016.03\"\nANSI_COLOR=\"0;33\"\nCPE_NAME=\"cpe:/o:amazon:linux:2016.03:ga\"\nHOME_URL=\"http://aws.amazon.com/amazon-linux-ami/\"\n",
"/etc/system-release": "Amazon Linux AMI release 2016.03\n"
},
"distro": {
"version_best": "2016.03",
"os_release_info": {
"name": "Amazon Linux AMI",
"ansi_color": "0;33",
"id_like": "rhel fedora",
"version_id": "2016.03",
"pretty_name": "Amazon Linux AMI 2016.03",
"version": "2016.03",
"home_url": "http://aws.amazon.com/amazon-linux-ami/",
"cpe_name": "cpe:/o:amazon:linux:2016.03:ga",
"id": "amzn"
},
"version": "2016.03",
"codename": "",
"lsb_release_info": {},
"id": "amzn",
"name": "Amazon Linux AMI"
}
}

@ -0,0 +1,40 @@
{
"name": "Amazon 2018.03",
"platform.release": "4.14.94-73.73.amzn1.x86_64",
"result": {
"distribution_release": "NA",
"distribution": "Amazon",
"distribution_major_version": "2018",
"distribution_minor_version": "03",
"os_family": "RedHat",
"distribution_version": "2018.03"
},
"platform.dist": [
"amzn",
"2018.03",
""
],
"input": {
"/etc/os-release": "NAME=\"Amazon Linux AMI\"\nVERSION=\"2018.03\"\nID=\"amzn\"\nID_LIKE=\"rhel fedora\"\nVERSION_ID=\"2018.03\"\nPRETTY_NAME=\"Amazon Linux AMI 2018.03\"\nANSI_COLOR=\"0;33\"\nCPE_NAME=\"cpe:/o:amazon:linux:2018.03:ga\"\nHOME_URL=\"http://aws.amazon.com/amazon-linux-ami/\"\n",
"/etc/system-release": "Amazon Linux AMI release 2018.03\n"
},
"distro": {
"version_best": "2018.03",
"os_release_info": {
"name": "Amazon Linux AMI",
"ansi_color": "0;33",
"id_like": "rhel fedora",
"version_id": "2018.03",
"pretty_name": "Amazon Linux AMI 2018.03",
"version": "2018.03",
"home_url": "http://aws.amazon.com/amazon-linux-ami/",
"cpe_name": "cpe:/o:amazon:linux:2018.03:ga",
"id": "amzn"
},
"version": "2018.03",
"codename": "",
"lsb_release_info": {},
"id": "amzn",
"name": "Amazon Linux AMI"
}
}

@ -0,0 +1,34 @@
{
"platform.dist": [
"",
"",
""
],
"input": {
"/etc/system-release": "Amazon Linux release 2 (Karoo)",
"/etc/os-release": ""
},
"name": "Amazon Linux 2 - Karoo",
"result": {
"distribution_release": "NA",
"distribution": "Amazon",
"distribution_major_version": "2",
"os_family": "RedHat",
"distribution_version": "2"
},
"distro": {
"id": "amzn",
"version": "2",
"codename": "",
"os_release_info": {
"name": "Amazon Linux AMI",
"ansi_color": "0;33",
"id_like": "rhel fedora",
"version_id": "2",
"pretty_name": "Amazon Linux release 2 (Karoo)",
"version": "2",
"home_url": "https://amazonlinux.com/",
"id": "amzn"
}
}
}
Loading…
Cancel
Save