# I am trying to install Java and set path by using Java tar file, I am getting error can anyone please suggest ASAP (Urgent)

**URL:** <https://forum.ansible.com/t/i-am-trying-to-install-java-and-set-path-by-using-java-tar-file-i-am-getting-error-can-anyone-please-suggest-asap-urgent/29479>\
**Category:** Ansible Project\
**Created:** [January 21, 2019, 8:54am UTC](https://forum.ansible.com/t/i-am-trying-to-install-java-and-set-path-by-using-java-tar-file-i-am-getting-error-can-anyone-please-suggest-asap-urgent/29479 "2019-01-21T08:54:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashok\_kumar\_penumudi](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@ashok\_kumar\_penumudi](https://forum.ansible.com/u/ashok_kumar_penumudi)\
**Post date:** [January 21, 2019, 8:54am UTC](https://forum.ansible.com/t/i-am-trying-to-install-java-and-set-path-by-using-java-tar-file-i-am-getting-error-can-anyone-please-suggest-asap-urgent/29479/1 "2019-01-21T08:54:50Z")

</div>

When i run below playbook getting error i am trying to set Java path. Please suggest ASAP

> > > > > > [cdhadmin@vboacisbs13 ansible]$ ansible-playbook java.yml --syntax -check
> 
> > > > > > ERROR! Syntax Error while loading YAML.
> 
> > > > > > did not find expected key
> 
> > > > > >
> 
> > > > > > The error appears to have been in ‘/etc/ansible/java.yml’: line 12, column 6, but may
> 
> > > > > > be elsewhere in the file depending on the exact syntax problem.
> 
> > > > > >
> 
> > > > > > The offending line appears to be:
> 
> > > > > >
> 
> > > > > > # lineinfile is used to add additional or append lines to existing files.
> 
> > > > > > - lineinfile :
> 
> > > > > > ^ here

[cdhadmin@vboacisbs13 ansible]$ sudo vi java.yml

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [January 21, 2019, 2:00pm UTC](https://forum.ansible.com/t/i-am-trying-to-install-java-and-set-path-by-using-java-tar-file-i-am-getting-error-can-anyone-please-suggest-asap-urgent/29479/2 "2019-01-21T14:00:58Z")

</div>

The indentation of your lineinfile task is off.  
Also, to be consistent, you probably want to start that task by giving  
it a "name:".

But once you've solved that, the rest of your playbook needs work, too.  
Instead of having two command tasks (get\_url + command), you should  
use a single unarchive task.

A more serious problem is the last task (shell: source  
/etc/profile.d). That does not do what you think it does.  
Read [https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_environment.html](https://docs.ansible.com/ansible/latest/user_guide/playbooks_environment.html)  
for how to work with this  
Each task has its own set of environment vars - they do not magically  
carry over to subsequent tasks (which I suspect there are - the task  
so far seems to just get and extract an archive).

Dick

---

<div class="post-metadata">

**Author:** ![goforawalktwice](https://avatars.discourse-cdn.com/v4/letter/g/c5a1d2/32.png) [@goforawalktwice](https://forum.ansible.com/u/goforawalktwice)\
**Post date:** [January 21, 2019, 6:20pm UTC](https://forum.ansible.com/t/i-am-trying-to-install-java-and-set-path-by-using-java-tar-file-i-am-getting-error-can-anyone-please-suggest-asap-urgent/29479/3 "2019-01-21T18:20:45Z")

</div>

You also have a space between lineinfile and colon

---

<div class="post-metadata">

**Author:** ![ashok\_kumar\_penumudi](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@ashok\_kumar\_penumudi](https://forum.ansible.com/u/ashok_kumar_penumudi)\
**Post date:** [January 22, 2019, 12:21pm UTC](https://forum.ansible.com/t/i-am-trying-to-install-java-and-set-path-by-using-java-tar-file-i-am-getting-error-can-anyone-please-suggest-asap-urgent/29479/4 "2019-01-22T12:21:12Z")

</div>

the whole content is replacing by one line (PATH=/usr/java/jdk1.8.0\_171-amd64/bin:$PATH’)? could you please suggest how to append?
