Skip to content

Instantly share code, notes, and snippets.

@emilio2hd
Last active January 3, 2023 10:48
Show Gist options
  • Save emilio2hd/c910661bff37246bee17 to your computer and use it in GitHub Desktop.
Save emilio2hd/c910661bff37246bee17 to your computer and use it in GitHub Desktop.
Ansible role to install sdkman and gradle
---
sdkman_script_install_url: http://get.sdkman.io
sdkman_folder: '/home/vagrant/.sdkman'
gradle_version: 2.3
---
- 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
@emilio2hd
Copy link
Author

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