Skip to content

ansible_distribution error #8

@Jessie-Lazo

Description

@Jessie-Lazo

I've been facing an issue with my code, I'm not sure if it's because of the version of my ansible, which is 2.5.1. I am not able to upgrade further, it is not allowing me. So, I am looking for alternatives solutions how to fix the error I get.

  • hosts: all
    become: true
    gather_facts: yes
    pre_tasks:

    • name: install update and repositories (CentOS)
      tags: always
      dnf:
      name: "*"
      update_cache: yes
      state: latest
      changed_when: false
      when: ansible_distribution == "CentOS"

    • name: install update and repositories (Ubuntu)
      tags: always
      apt:
      upgrade: yes
      update_cache: yes
      cache_valid_time: 86400
      changed_when: false
      when: ansible_distribution == "Ubuntu"

The error is ansible_distribution == "CentOS" undefined.
My centos is using python3 which I already included in my inventory as interpreter.
my ubuntu does not have any problem. I also check ansible setup and see that under my ubuntu server there is ansible_distribution while under centos server it is not appearing.

Thank you for any response that can help resolve this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions