Last active
January 3, 2023 10:48
-
-
Save emilio2hd/c910661bff37246bee17 to your computer and use it in GitHub Desktop.
Ansible role to install sdkman and gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
sdkman_script_install_url: http://get.sdkman.io | |
sdkman_folder: '/home/vagrant/.sdkman' | |
gradle_version: 2.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Check if sdkman is installed | |
shell: test -d {{sdkman_folder}} && echo "yes" || echo "no" | |
register: is_sdkman_installed | |
- name: Install SDKMAN! | |
when: is_sdkman_installed.stdout == "no" | |
shell: curl -s {{sdkman_script_install_url}} | bash executable=/bin/bash | |
sudo: no | |
- name: Ensure presence of bashrc | |
file: state=touch path={{user_home_path}}/.bashrc | |
sudo: no | |
- name: Add sdkman in .bashrc | |
lineinfile: dest={{user_home_path}}/.bashrc regexp="\/.sdkman/bin\/sdkman\-init\.sh" line='[[ -s "{{sdkman_folder}}/bin/sdkman-init.sh" && ! $(which sdkman-init.sh) ]] && source "{{sdkman_folder}}/bin/sdkman-init.sh"' | |
sudo: no | |
- name: Installing gradle | |
# This will read your bash profile file, which would setup sdkman-init.sh. | |
command: bash -lc "sdk install gradle {{gradle_version}}" | |
sudo: no |
Hey Timo.
It's been a while since the last time I touched on this.
Thank you for your contribution!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I used a modified version of this, this is what worked for me for anyone interested:
playbook/gradle.yml
This goes in your vars:
This part depends on your username.