---
- hosts: cloudera
tasks:
- name: Download Java
get_url: url=http://10.85.16.186/cm/ansible-2.7.5.tar.gz
dest=/home/cdhadmin/Downloads
- name: Extract Java
command: tar zxvf /home/cdhadmin/Downloads/ansible-2.7.5.tar.gz
- name: set path for java file
lineinfile:
dest: /etc/environment
state: present
regexp: 'JAVA_HOME'
line: 'JAVA_HOME: /usr/java/jdk1.8.0_171-amd64/'
dest: /etc/environment
state: present
regexp: 'PATH'
line: 'PATH=/usr/java/jdk1.8.0_171-amd64/bin:$PATH'
~
When i run above script
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?
On Monday, January 21, 2019 at 2:24:51 PM UTC+5:30, ashok kumar penumudi
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/07fca9bd-5782-4ed5-9044-1db496fec339%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.