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.
^ here
[cdhadmin@vboacisbs13 ansible]$ sudo vi java.yml
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
You also have a space between lineinfile and colon
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?