# can anyone help me out writing ansible playbook for the upgradation of java in slave machines depending on os\_family

**URL:** <https://forum.ansible.com/t/can-anyone-help-me-out-writing-ansible-playbook-for-the-upgradation-of-java-in-slave-machines-depending-on-os-family/34289>\
**Category:** Ansible Project\
**Created:** [December 6, 2020, 6:10am UTC](https://forum.ansible.com/t/can-anyone-help-me-out-writing-ansible-playbook-for-the-upgradation-of-java-in-slave-machines-depending-on-os-family/34289 "2020-12-06T06:10:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![prathyusha](https://avatars.discourse-cdn.com/v4/letter/p/5e9695/32.png) [@prathyusha](https://forum.ansible.com/u/prathyusha)\
**Post date:** [December 6, 2020, 6:10am UTC](https://forum.ansible.com/t/can-anyone-help-me-out-writing-ansible-playbook-for-the-upgradation-of-java-in-slave-machines-depending-on-os-family/34289/1 "2020-12-06T06:10:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [December 6, 2020, 7:57am UTC](https://forum.ansible.com/t/can-anyone-help-me-out-writing-ansible-playbook-for-the-upgradation-of-java-in-slave-machines-depending-on-os-family/34289/2 "2020-12-06T07:57:15Z")

</div>

Put the data into a dictionary and test it

&nbsp;&nbsp;- hosts: localhost  
&nbsp;&nbsp;&nbsp;&nbsp;gather\_facts: true  
&nbsp;&nbsp;&nbsp;&nbsp;vars:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;java\_pkg:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Debian: default-jre  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ubuntu: default-jre  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fedora: java-1.8.0-openjdk  
&nbsp;&nbsp;&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg: "{{ ansible\_distribution }}:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Install {{ java\_pkg[ansible\_distribution] }}"

If this is what you want install the package

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- package:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name: "{{ java\_pkg[ansible\_distribution] }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state: present  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when: install|default(false)|bool

See "package - Generic OS package manager"  
[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/package\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/package_module.html)

Fit the dictionary to your needs.
