Comcast / ansible-sdkman

An Ansible role that installs, configures, and manages SDKMAN
https://galaxy.ansible.com/Comcast/sdkman/
Apache License 2.0
58 stars 28 forks source link

Cleanup Handler is failing if sdkman_user is 'root' #66

Open martin-huber opened 2 years ago

martin-huber commented 2 years ago

the main-handler currently is:

- name: Cleanup SDKMAN script
  file:
    path: '{{ sdkman_tmp_dir }}/sdkman_script'
    state: absent

and fails, if sdkman_user is 'root', because the sdkman_script then is owned by 'root' but attempted to be deleted by the ansible user.

It should be

- name: Cleanup SDKMAN script
  file:
    path: '{{ sdkman_tmp_dir }}/sdkman_script'
    state: absent
  become: '{{ sdkman_user != ansible_user_id }}'
  become_user: '{{ sdkman_user }}'

Using ansible-sdkman 1.7.0 with ansible [core 2.11.9]