---
- name: "Register the MAS installed apps"
  become: false
  environment:
    PATH: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:{{ ansible_env.PATH }}
  command: mas list
  register: mas_list
  changed_when: false

- name: "Ensure Microsoft Remote Desktop is installed"
  become: false
  environment:
    PATH: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:{{ ansible_env.PATH }}
  command: "mas install '{{ microsoft_remote_desktop_mas_id }}'"
  when: (microsoft_remote_desktop_mas_id | string) not in mas_list.stdout
