6

Example on Ubuntu 18.04 reporting distribution info in 'ansible_facts':

$ ansible -i hosts ubuntu1804 -u root -m setup -a "filter=ansible_distribution*"
ubuntu1804 | SUCCESS => {
    "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": "18", 
        "ansible_distribution_release": "bionic", 
        "ansible_distribution_version": "18.04"
    }, 
    "changed": false
}

Example of same command against Ubuntu 20.04:

$ ansible -i hosts ubuntu2004 -u root -m setup -a "filter=ansible_distribution*"
ubuntu2004 | SUCCESS => {
    "ansible_facts": {}, 
    "changed": false
}

Is this an issue with Ubuntu or Ansible? Is there a workaround?

JonB
  • 836
  • 1
  • 11
  • 15

2 Answers2

7

Issue resolved with today's update to ansible 2.9.7.

JonB
  • 836
  • 1
  • 11
  • 15
2

After very research to find out Ubuntu 20.04 version then we have got released a version using ansible version-2.5.1

- hosts: localhost
  become: true
  gather_facts: yes
  tasks:
  - name: System details
    debug:
      msg: "{{ ansible_facts['lsb']['release'] }}"

  - name: ubuntu 18
    shell: echo "hello 18"
    register: ub18
    when: ansible_facts['lsb']['release'] == "18.04"

  - debug:
     msg: "{{ ub18 }}"

  - name: ubuntu 20
    shell: echo "hello 20"
    register: ub20
    when: ansible_facts['lsb']['release'] == "20.04"

  - debug:
     msg: "{{ ub20 }}"