Skip to content

Commit

Permalink
fix: split vars/main.yml file by distribution (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
antmelekhin authored Jul 27, 2024
1 parent 6882911 commit fae39fc
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 32 deletions.
9 changes: 4 additions & 5 deletions tasks/install-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

- name: 'Debian | Add the Amazon Corretto repository GPG key'
ansible.builtin.apt_key:
url: '{{ java_corretto_repository_gpgkey_url | default(_java_corretto_debian_repository_gpgkey_url) }}'
keyring: '{{ _java_corretto_debian_repository_gpgkey_keyring }}'
url: '{{ java_corretto_repository_gpgkey_url | default(__java_corretto_repository_gpgkey_url) }}'
keyring: '{{ __java_corretto_repository_gpgkey_keyring }}'
state: 'present'

- name: 'Debian | Add the Amazon Corretto repository'
Expand All @@ -30,10 +30,9 @@

- name: "Debian | Install the {{ (java_distribution == 'corretto') | ternary('Amazon Corretto', 'OpenJDK') }} package"
ansible.builtin.apt:
name:
"{{ java_corretto_package_name | default(_java_corretto_debian_package_name)
name: "{{ java_corretto_package_name | default(__java_corretto_package_name)
if java_distribution == 'corretto'
else java_openjdk_package_name | default(_java_openjdk_debian_package_name) }}"
else java_openjdk_package_name | default(__java_openjdk_package_name) }}"
update_cache: true
state: 'present'
ignore_errors: '{{ ansible_check_mode }}'
Expand Down
5 changes: 2 additions & 3 deletions tasks/install-RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@

- name: "RedHat | Install the {{ (java_distribution == 'corretto') | ternary('Amazon Corretto', 'OpenJDK') }} package"
ansible.builtin.package:
name:
"{{ java_corretto_package_name | default(_java_corretto_redhat_package_name)
name: "{{ java_corretto_package_name | default(__java_corretto_package_name)
if java_distribution == 'corretto' or ansible_distribution == 'Amazon'
else java_openjdk_package_name | default(_java_openjdk_redhat_package_name) }}"
else java_openjdk_package_name | default(__java_openjdk_package_name) }}"
state: 'present'
become: true
3 changes: 3 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
---
- name: 'Load the Java OS-specific variables'
ansible.builtin.include_vars: '{{ ansible_os_family }}.yml'

- name: 'Install the Java package'
ansible.builtin.include_tasks: 'install-{{ ansible_os_family }}.yml'

Expand Down
2 changes: 1 addition & 1 deletion templates/corretto.list.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{{ ansible_managed | comment }}

deb [signed-by={{ _java_corretto_debian_repository_gpgkey_keyring }}] {{ java_corretto_repository | default(_java_corretto_debian_repository) }}
deb [signed-by={{ __java_corretto_repository_gpgkey_keyring }}] {{ java_corretto_repository | default(__java_corretto_repository) }}
4 changes: 2 additions & 2 deletions templates/corretto.repo.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[AmazonCorretto]
name=Amazon Corretto
baseurl={{ java_corretto_repository | default(_java_corretto_redhat_repository) }}
baseurl={{ java_corretto_repository | default(__java_corretto_repository) }}
enabled=1
gpgcheck=1
gpgkey={{ _java_corretto_redhat_repository_gpgkey_url }}
gpgkey={{ java_corretto_repository_gpgkey_url | default(__java_corretto_repository_gpgkey_url) }}
16 changes: 16 additions & 0 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
# Default OpenJDK package
__java_openjdk_package_name: "{{ (ansible_distribution_major_version == '10') | ternary('openjdk-11-jre', 'openjdk-17-jre') }}"

# Default Amazon Corretto mirror
__java_corretto_repository_mirror_url: 'https://apt.corretto.aws'

# Default Amazon Corretto GPG key
__java_corretto_repository_gpgkey_url: '{{ __java_corretto_repository_mirror_url }}/corretto.key'
__java_corretto_repository_gpgkey_keyring: '/usr/share/keyrings/corretto-archive-keyring.gpg'

# Default Amazon Corretto repository
__java_corretto_repository: '{{ __java_corretto_repository_mirror_url }} stable main'

# Default Amazon Corretto package
__java_corretto_package_name: 'java-17-amazon-corretto-jdk'
15 changes: 15 additions & 0 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
# Default OpenJDK package
__java_openjdk_package_name: "{{ (ansible_distribution_major_version == '7') | ternary('java-11-openjdk', 'java-17-openjdk') }}"

# Default Amazon Corretto mirror
__java_corretto_repository_mirror_url: 'https://yum.corretto.aws'

# Default Amazon Corretto GPG key
__java_corretto_repository_gpgkey_url: '{{ __java_corretto_repository_mirror_url }}/corretto.key'

# Default Amazon Corretto repository
__java_corretto_repository: '{{ __java_corretto_repository_mirror_url }}/$basearch'

# Default Amazon Corretto package
__java_corretto_package_name: 'java-17-amazon-corretto-devel'
21 changes: 0 additions & 21 deletions vars/main.yml

This file was deleted.

0 comments on commit fae39fc

Please sign in to comment.