angstwad/docker.ubuntu

Ubuntu 16.04 error: 'ansible_lsb' is undefined

sylnsr opened this issue · 3 comments

  • New Ubuntu 16.04 EC2 instance with all packages updated
  • Ansible 2.3
fatal: [org-mas.dev-odoo._______________.com]: FAILED! => {"failed": true, "msg": 
"The conditional check 'ansible_lsb.id|lower == \"ubuntu\" and ( ansible_distribution_version|version_compare('12.04', '<') or ansible_distribution_version|version_compare('12.10', '=') )' failed. 
The error was: error while evaluating conditional (ansible_lsb.id|lower == \"ubuntu\" 
and ( ansible_distribution_version|version_compare('12.04', '<') or ansible_distribution_version|version_compare('12.10', '=') )): 'ansible_lsb' is undefined
The error appears to have been in '/etc/ansible/roles/angstwad.docker_ubuntu/tasks/main.yml': 
line 6, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:

- name: Fail if not a new release of Ubuntu
  ^ here
"}

I cannot replicate this on a 16.04 EC2 instance fully updated running Ansible 2.3.1.0.

t4ec commented

Just in case. I had the same problem. It turned out that EC2 Ubuntu 16.04 does not have pre-installed Python, so I had to set

gather_facts: False

and install Python with raw command

and because of gather_facts: False ansible_lsb variable was undefined. Removing described flag from playbook had solved the issue.

@t4ec , I concur this solution. I think my report was misunderstood when I indicated that my target was "updated". So to be clear, "updated" simply means existing packages from a fresh install are updated. Updated does not mean extra packages are installed from a non-standard (default) install. That seems to have been assumed, and by reflection of this attitude, its also assumed in this project. So either add the following task before executing this role:

  tasks:

    - name: Add missing modules for Ubuntu 16.04
      raw: apt-get install aptitude -y

    - name: Install Python if missing
      raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)

.. or I guess, just use a different project, which I am doing.