Getting full name of the OS using Ansible facts
06:40 08 Feb 2022

I used gather_facts to get the OS details of each instance that I'm dealing with. For Amazon Linux OS, it just says Amazon 2 or Amazon 2018.

Use case: I'm dynamically constructing the file name for a task. The file name is nothing but the name of the OS. When I see the contents of /etc/os-release, it says Amazon Linux only but Ansible facts returns:

"ansible_facts": {
    "discovered_interpreter_python": "/usr/bin/python2.7",
    "distribution": "Amazon",
    "distribution_file_parsed": true,
    "distribution_file_path": "/etc/os-release",
    "distribution_file_variety": "Amazon",
    "distribution_major_version": "2",
    "distribution_minor_version": "NA",
    "distribution_release": "NA",
    "distribution_version": "2",
    "gather_subset": [
        "distribution",
        "!all",
        "!min"
    ],
    "module_setup": true,
    "os_family": "RedHat",
}

Is there a way to get the full name of the distribution? I personally feel Amazon 2 doesn't set the proper context.

ansible ansible-facts