0

How can I use ansible to detect the specific flavor of Linux, e.g. "Lubuntu" -- a variant of Ubuntu?

On a Lubuntu 22.04, I tried to track ansible_distribution with the following playbook:

---
- hosts: all
  gather_facts: yes
  become: false
  tasks:
  - name: Distribution
    debug: msg="{{ ansible_distribution }}"
  - name: Distribution version
    debug: msg="{{ ansible_distribution_version}}"
  - name: Distribution major version
    debug: msg="{{ ansible_distribution_major_version }}"

But I got Ubuntu as the ansible_distribution, which isn't specific enough (for the task I have):

TASK [Distribution] ************************************************************
ok: [127.0.0.1] => {
    "msg": "Ubuntu"
}
...

In general, how can one get the name of the specific Linux flavor such as Lubuntu?

-- Additional Info --

On the Lubuntu, I have:

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy
4
  • What is the content of /etc/lsb-release ? Commented Oct 12, 2022 at 1:25
  • @VladimirBotka Please see the update I just added.
    – tinlyx
    Commented Oct 12, 2022 at 1:58
  • 3
    Forgetting Ansible for a moment; how would you identify a Lubuntu system vs. a generic Ubuntu system?
    – larsks
    Commented Oct 12, 2022 at 2:34
  • Depending on the target system you may need to construct the information from values gathered on the Remote Node like in Getting full name of the OS using Ansible facts.
    – U880D
    Commented Oct 12, 2022 at 7:00

2 Answers 2

1

There is no standard for recognizing Ubuntu flavors. You can search for the configuration. See Is it possible to know which recognized flavor I am running using terminal?. For example,

shell> cat /var/log/installer/media-info 
Xubuntu 20.04 LTS "Focal Fossa" - Release amd64 (20200423)

Ansible doesn't gather facts about Ubuntu flavors. You'll have to find out on your own. For example,

- hosts: localhost

  vars:

    my_flavor: "{{ media_info.stdout.split()|first }}"

  tasks:

    - command: cat /var/log/installer/media-info
      register: media_info
    - debug:
        var: my_flavor

gives

  my_flavor: Xubuntu
1

You can use ansible_distribution_release

You can easily see available facts on your host by running:

ansible all -m setup -a "filter=ansible_distribution*"

"ansible_facts": {
        "ansible_distribution": "Ubuntu",
        "ansible_distribution_file_parsed": true,
        "ansible_distribution_file_path": "/etc/os-release",
        "ansible_distribution_file_variety": "Debian",
        "ansible_distribution_major_version": "22",
        "ansible_distribution_release": "jammy",
        "ansible_distribution_version": "22.04",
        "discovered_interpreter_python": "/usr/bin/python3"
    },
1
  • This shows the release name, not the flavour.
    – Chris Down
    Commented Jul 12, 2023 at 21:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .