infrastructure
infrastructure copied to clipboard
UnixPB: Ansible request for JDK install role
Please put the name of the software product (and affected platforms if relevant) in the title of this issue
Delete as appropriate from this list:
- Bug in ansible playbook
Details: If there are multiple matches in /usr/lib/jvm then ansible fails to create the appropriate symbolic link e.g.
root@test-marist-ubuntu1804-s390x-3:/usr/lib/jvm# ls -ld /usr/lib/jvm/jdk-11*
drwxr-xr-x 9 root root 4096 Aug 16 07:53 /usr/lib/jvm/jdk-11.0.16.1+1
drwxr-xr-x 9 root root 4096 Jul 19 20:30 /usr/lib/jvm/jdk-11.0.16+8
drwxr-xr-x 9 root root 4096 Jul 15 2020 /usr/lib/jvm/jdk-11.0.8+10
Results in fatal: [test-marist-ubuntu1804-s390x-3]: FAILED! => {"changed": false, "msg": "src file does not exist, use \"force=yes\" if you really want to create the link: /usr/lib/jvm/jdk-11.0.16.1+1\n/usr/lib/jvm/jdk-11.0.16+8\n/usr/lib/jvm/jdk-11.0.8+10", "path": "/usr/lib/jvm/jdk-11", "src": "/usr/lib/jvm/jdk-11.0.16.1+1\n/usr/lib/jvm/jdk-11.0.16+8\n/usr/lib/jvm/jdk-11.0.8+10"}
related https://github.com/adoptium/infrastructure/issues/2624
Relevant ansible file https://github.com/adoptium/infrastructure/blob/master/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml
hi @Haroon-Khel @smlambert i would like to take up this issue
Hi @lumuchris256 I have assigned it to you
@Haroon-Khel according to issue #2624 , what is the expected outcome of the issue?
Conversation continued in slack
At https://github.com/adoptium/infrastructure/blob/95fb017b04f8921bfa08ff923e8a3d77f5a2a3d7/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml#L117 (between the two tasks) there should be a task which checks for a jdk without a symlink (perhaps the task can search for {{ path }}.*
) and removes it if present then installs the jdk completely
Another solution would be to check if a non symlinked jdk exists and then tries to symlink it, but this might get long. And it would be better to install a newer jdk anyway
So something along the lines of
- name: Check if jdk-{{ jdk_version }} binary is present but not symlinked
shell: ls -ld {{ path }}.* >/dev/null 2>&1
failed_when: false
register: adoptopenjdk_installed_not_symlinked
changed_when: false
when: adoptopenjdk_installed.rc != 0
tags:
- adoptopenjdk_install
- skip_ansible_lint
- name: Remove non symlinked jdk-{{ jdk_version }} binary
file:
path: {{ path }}.*
state: absent
when:
- adoptopenjdk_installed_not_symlinked.rc == 0
- adoptopenjdk_installed.rc != 0
tags:
- adoptopenjdk_install
- skip_ansible_lint
It should only remove the non linked binary if it doesnt detect a symlink. If it does detect a symlink then this task should not run (it will delete the binary that is linked which we dont want)