---
# "ansible_distribution_file_variety": "RedHat",
# "ansible_distribution_major_version": "7",
# "ansible_distribution_release": "Maipo",
# "ansible_distribution_version": "7.8",

  - debug:
      msg:
        - "host           : {{inventory_hostname}}"
        - "variety        : {{ansible_distribution_file_variety}}"
        - "release        : {{ansible_distribution_release}}"
        - "version majeur : {{ansible_distribution_major_version}}"
        - "version majeur : {{ansible_distribution_version}}"
      verbosity: 2

  - name: Check if the template for the calculated version is present
    stat:
      path: "roles/configure.yum.repo/templates/{{ansible_distribution_file_variety}}_{{ansible_distribution_major_version}}.j2"
    register: template_file
    connection: local

  - name: apply template local.repo
    become: true
    template:
      src: "roles/configure.yum.repo/templates/{{ansible_distribution_file_variety}}_{{ansible_distribution_major_version}}.j2"
      dest: /etc/yum.repos.d/local.repo
      owner: root
      group: root
      mode: u=rw,g=r,o=r
      backup: yes
    when: template_file.stat.exists

    
  - debug:
      msg:
        - "pas de traitement pour {{inventory_hostname}}, template non existant {{ansible_distribution_file_variety}}_{{ansible_distribution_major_version}}.j2"
    when: not template_file.stat.exists
