community.general icon indicating copy to clipboard operation
community.general copied to clipboard

Make mas more robust to deal with app installs on new Macs more gracefully

Open Sergong opened this issue 3 years ago • 6 comments

SUMMARY

mas currently does not handle installation of Apps from the App Store gracefully when the app has never been installed (such as as is the case typically for a new Mac). If mas install [id] fails, the module should not fail but instead try to use mas purchase [id] first. This stands a good chance of succeeding depending to the user's App Store Media & Purchase preferences.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

mas

ADDITIONAL INFORMATION

Ideally the module would be used as is today but would handle failures in case of apps never before installed on this Mac, more gracefully by retrying with the mas-cli command mas purchase [id] . Alternatively the module could have another option to control how apps are installed as per playbook example below.

---
- name: Install Mac Apps from App Store
  hosts: localhost

  vars:
    apps:
      - name: Test
        id: 123456789

  tasks:
    - name: install all apps
      community.general.mas:
        id: "{{ item.id }}"
        state: present
        install_method: purchase # choose from install or purchase
     loop: "{{ apps }}"

Sergong avatar Jan 17 '21 21:01 Sergong

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot avatar Jan 17 '21 21:01 ansibullbot

cc @lukasbestle @mheap click here for bot help

ansibullbot avatar Jan 17 '21 21:01 ansibullbot

As there is an option to never ask for the Apple ID password even for paid apps, I think it would be very risky to purchase apps by default. If you have a typo in your app IDs or if you run a third-party playbook that includes apps, you will get billed for something you didn't want.

So I don't think this should be the default behavior. But I'm open for an option, PR welcome. Please note that this will increase the minimum requirement for the mas-cli to v1.7.0 (not a big deal, but needs to be documented).

lukasbestle avatar Jan 18 '21 09:01 lukasbestle

Fair enough but then at least the second suggested alternative of adding the install_method option to override the default behaviour would be good. As it stand today this module is unusable for setting up new Macs because it always errors out if the App has never been installed.I would have thought automating new Mac installs would actually be the main use case of this module.

Sergong avatar Jan 20 '21 20:01 Sergong

Fair enough but then at least the second suggested alternative of adding the install_method option to override the default behaviour would be good.

As I wrote: "So I don't think this should be the default behavior. But I'm open for an option, PR welcome."

As it stand today this module is unusable for setting up new Macs because it always errors out if the App has never been installed.

It's not about new Macs, it's about new Apple IDs. If I set up a new Mac for myself, it all works fine. This is the use-case that's currently covered by the module. Your use-case of setting up the Macs of new employees etc. can be covered with the option you propose.

lukasbestle avatar Jan 20 '21 20:01 lukasbestle

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot avatar Nov 11 '22 01:11 ansibullbot