can anyone help me out writing ansible playbook for the upgradation of java in slave machines depending on os_family

Hi Everyone,

Please can anyone solve this issue
I need help its urgent

I have written playbook in ansible but while i am running it is throwing error.
Below is the syntax for playbook

Put the data into a dictionary and test it

  - hosts: localhost
    gather_facts: true
    vars:
      java_pkg:
        Debian: default-jre
        Ubuntu: default-jre
        Fedora: java-1.8.0-openjdk
    tasks:
      - debug:
          msg: "{{ ansible_distribution }}:
                Install {{ java_pkg[ansible_distribution] }}"

If this is what you want install the package

      - package:
          name: "{{ java_pkg[ansible_distribution] }}"
          state: present
        when: install|default(false)|bool

See "package - Generic OS package manager"
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/package_module.html

Fit the dictionary to your needs.