homelab/roles/minecraft/tasks/java.yml

37 lines
1.1 KiB
YAML
Raw Normal View History

- name: Install GPG
2023-05-04 03:27:03 +00:00
ansible.builtin.apt:
name: gpg
state: present
- name: Add AdoptOpenJDK's signing key
2023-05-04 03:27:03 +00:00
ansible.builtin.apt_key:
id: 8ED17AF5D7E675EB3EE3BCE98AC3B29174885C03
url: https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public
- name: Install AdoptOpenJDK repository
2023-05-04 03:27:03 +00:00
ansible.builtin.apt_repository:
repo: deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ buster main
mode: 0644
state: present
- name: Install Java
2023-05-04 03:27:03 +00:00
ansible.builtin.apt:
name: "adoptopenjdk-{{ item.java.version }}-hotspot"
state: present
when: item.java.version is defined
loop: "{{ minecraft }}"
- name: "Install default Java, version {{ minecraft_java }}"
2023-05-04 03:27:03 +00:00
ansible.builtin.apt:
name: "{{ minecraft_java_pkg }}"
state: present
when: item.java.version is not defined
loop: "{{ minecraft }}"
register: minecraft_java_default
- name: "Activate default Java, version {{ minecraft_java }}"
2023-05-04 03:27:03 +00:00
community.general.alternatives:
name: java
path: "/usr/lib/jvm/{{ minecraft_java_pkg }}-amd64/bin/java"
when: minecraft_java_default.changed