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
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

On Mon, 21 Jan 2019 at 09:54, ashok kumar penumudi <[email protected]> wrote:
>
> 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
> ---
> - hosts: cloudera
>   become: true
>   tasks:
>    - name: Download Java
>      get_url: url=http://10.85.16.186/cm/cm5.14.2-centos7.tar.gz 
> dest=/home/cdhadmin/Downloads
>    - name: Extract & install Java
>      command: tar zxvf /home/cdhadmin/Downloads/cm5.14.2-centos7.tar.gz -C 
> /usr
>    - name: Update Profile
>      copy: content="export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk \n" 
> dest=/etc/profile
>      # lineinfile is used to add additional or append lines to existing files.
>      - lineinfile :
>        path: /etc/profile
>        line: 'JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk'
>        create: yes
>    - name: Source profile
>      shell: source /etc/profile.d
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/32ee6a20-2f7c-4af0-9793-e542fbfd7636%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwOa3Mz6Dx-V8dsGqg0bRGGNweqqegGjmHLB1_ztQ-8qpQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to