ansible-role-tailscale icon indicating copy to clipboard operation
ansible-role-tailscale copied to clipboard

The conditional check 'tailscale_original_distribution_major_version == \"NA\"' failed

Open itinfserv opened this issue 2 years ago • 5 comments

Hi, when running the role using role_include it throws an error:

fatal: [localhost]: FAILED! => {"msg": "The conditional check 'tailscale_original_distribution_major_version == \"NA\"' failed. The error was: error while evaluating conditional (tailscale_original_distribution_major_version == \"NA\"): {{ ansible_distribution_major_version }}: 'ansible_distribution_major_version' is undefined\n\nThe error appears to be in '/home/xxx/.ansible/roles/artis3n.tailscale/tasks/main.yml': line 42, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n block:\n - name: Install lsb_release\n ^ here\n"}

  - name: Install Tailscale
    include_role:
      name:  artis3n.tailscale
    vars:
      tailscale_authkey: "xxxx"

I have tried adding become: true and false wondering if its a user context thing but same error occurs.

itinfserv avatar Mar 30 '23 09:03 itinfserv

Sorry I should add that using roles works fine, its just include_roles

this works:

- hosts: localhost
  roles:
    - role: artis3n.tailscale
      vars:
        tailscale_authkey: "xxxx"

I need to use roles_include rather than roles because the roles method doesnt seem to work with an include file and I dont want the tailscale playbook in the main playbook as I want to encrypt it using vault

itinfserv avatar Mar 30 '23 09:03 itinfserv

What operating system distro are you targeting?

artis3n avatar Apr 02 '23 19:04 artis3n

Any additional details you can provide would be helpful. The role works with include_role and that is part of the regularly run CI tests, e.g. https://github.com/artis3n/ansible-role-tailscale/blob/3adbf143a8b35b5888de69b4f0d8af6e4f8ac26c/molecule/state-absent/converge.yml#L12-L16

artis3n avatar Apr 02 '23 19:04 artis3n

This failure is happening for me when Ansible can't gather facts or can't connect to a host.

I worked around it by tricking Ansible into coercing the value to something that is not undefined but still falsey. I threw the following line into my role's defaults:

# roles/{role_name}/defaults/main.yml
ansible_distribution_major_version: ansible_facts['ansible_distribution_major_version'] || false

JonathanPorta avatar May 04 '23 11:05 JonathanPorta

I'm confused - if Ansible can't gather facts, then it won't know what distro's install instructions to use. But, particularly, if it can't connect to the host, then it can't do anything.

So far, situations I've encountered where ansible is unable to gather facts is due to missing lsb_release, so we install it here - https://github.com/artis3n/ansible-role-tailscale/blob/main/tasks/main.yml#L38 and then re-run a 'gather facts.'

Can you elaborate on what distro and situation you were in where Ansible failed to gather facts? We may want to improve this section.

artis3n avatar May 06 '23 13:05 artis3n

I had gather_facts: no set. Once I enabled facts gathering it worked like a charm.

utamas avatar May 09 '24 07:05 utamas