I'm using this to create a symbolic link to a directory, on Windows:
- name: Find OpenJDK directory
ansible.windows.win_find:
paths: C:\Program Files\OpenJDK\
patterns: openjdk*
file_type: directory
recurse: no
register: OpenJDK
- name: Create link to Java
win_command: cmd.exe /k mklink jdk "{{ OpenJDK.files[0].path }}"
args:
chdir: "C:\\Users\\{{ username }}"
vars:
ansible_become_user: "{{ username }}"
ansible_become_password: "{{ password }}"
win_command always returns "changed", even if the symlink already existed and was pointing to the same directory.
How do I change this so that I get "ok" when there was no change?
OR
Does a default Ansible command already exist for mklink? I couldn't find any on Ansible Galaxy.