I want to execute the following command to install Amazon Corretto 8 in Ansible.
$ sudo rpm --import https://yum.corretto.aws/corretto.key
$ sudo curl -L -o /etc/yum.repos.d/corretto.repo https://yum.corretto.aws/corretto.repo
$ sudo yum install -y java-1.8.0-amazon-corretto-devel
You can install it by writing as follows.
playbooks/roles/server/tasks/main.yml
- name: Import rpm key.
rpm_key:
key: https://yum.corretto.aws/corretto.key
- name: Add corretto repository.
yum_repository:
name: corretto
description: "Amazon Corretto repository"
baseurl: https://yum.corretto.aws/$basearch
- name: Install Amazon Corretto 8.
yum:
name: java-1.8.0-amazon-corretto-devel
state: present
enablerepo: corretto
Installation confirmation
$ docker exec -it server_container bash
[root@target /]# java -version
openjdk version "1.8.0_275"
OpenJDK Runtime Environment Corretto-8.275.01.1 (build 1.8.0_275-b01)
OpenJDK 64-Bit Server VM Corretto-8.275.01.1 (build 25.275-b01, mixed mode)
I didn't notice the baseurl and enablerepo settings and was a little addicted to it. Also, inside CentOS 8, [dnf is running] instead of yum [https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts/system/pkg_mgr.py#L94 ).
Recommended Posts