skip to Main Content

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?

2

Answers


  1. Chosen as BEST ANSWER

    Issue resolved with today's update to ansible 2.9.7.


  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 }}"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search