java_install.yml 773 Bytes

- name: install JRE
  apt: 
    name: default-jre
    autoclean: yes
    cache_valid_time: 3600

- name: Download JDK binaries 
  get_url: 
    url: https://download.oracle.com/java/18/archive/jdk-18.0.2.1_linux-aarch64_bin.tar.gz
    dest: /opt/jdk-18.0.2.1_linux-aarch64_bin.tar.gz

- name: unzip the downloaded jdk 
  unarchive: 
    src: /opt/jdk-18.0.2.1_linux-aarch64_bin.tar.gz
    dest: /opt
    remote_src: yes

- name: set the java home in /etc/profile file
  lineinfile: 
    path: /etc/profile
    state: present
    line: "{{item}}"
  with_items: 
    - 'export JAVA_HOME="/opt/jdk-18.0.2.1"'
    - 'export PATH=$JAVA_HOME/bin'


#--- mouad work -----------------

#- name: install JDK
#  become: yes
#  package: 
#    name: openjdk-8-jdk
#    state: present