- Newest
- Most votes
- Most comments
It seems like the Ansible Playbook is trying to install the OpenJDK 8 package using the yum module, but the package is not found in the available repositories. This can happen if the required repository is not enabled or the package name is incorrect for the particular distribution you are using.
Since you're working with Amazon Linux, you can try the following steps to resolve the issue:
- Update the Package Name: The package name might be different based on the distribution you are using. If you are using Amazon Linux 2, the correct package name might be java-1.8.0-openjdk-devel. Update the playbook accordingly:
- name: Install Java.
yum:
name: java-1.8.0-openjdk-devel
state: present
- Ensure the Correct Repository is Enabled: Amazon Linux 2 uses the amzn2-core repository for OpenJDK 8. You might need to enable this repository if it's not already enabled. You can add a task to enable the repository before installing Java:
pre_tasks:
- name: Enable amzn2-core repository
command: amazon-linux-extras enable java-openjdk11
when: ansible_distribution == "Amazon" and ansible_distribution_major_version == "2"
- name: Update yum cache if needed.
yum:
update_cache: true
- Consider Using the package Module: Instead of using the yum module, you can use the package module, which is more abstract and works with different package managers. This might help if there's something specific to the yum module causing the issue:
- name: Install Java.
package:
name: java-1.8.0-openjdk-devel
state: present
- Debugging: If the issue persists, you can add a debug task to print the available repositories and packages. This might give you more insights into what's going wrong:
- name: List yum repos
command: yum repolist
register: repos
- debug: var=repos.stdout_lines
- name: Search for Java packages
command: yum search java-1.8.0-openjdk
register: java_packages
- debug: var=java_packages.stdout_lines
Make sure to adapt the package name or repository based on the exact version and distribution of Amazon Linux you are using. Testing the commands manually on the EC2 instance might help you determine the correct package name and repository.
The solution provided above didn't work, however the Amazon Linux version which I am having is 2023 and it uses Corretto 8. Here is the link: https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/amazon-linux-install.html
Relevant content
- asked 5 years ago
- Accepted Answerasked 5 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated 2 months ago