community.general.mas – Manage Mac App Store applications with mas-cli

Note

This plugin is part of the community.general collection (version 3.8.3).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.mas.

New in version 0.2.0: of community.general

Synopsis

  • Installs, uninstalls and updates macOS applications from the Mac App Store using the mas-cli.

Requirements

The below requirements are needed on the host that executes this module.

  • macOS 10.11+

  • mas-cli (https://github.com/mas-cli/mas) 1.5.0+ available as mas in the bin path

  • The Apple ID to use already needs to be signed in to the Mac App Store (check with mas account).

Parameters

Parameter

Comments

id

list / elements=integer

The Mac App Store identifier of the app(s) you want to manage.

This can be found by running mas search APP_NAME on your machine.

state

string

Desired state of the app installation.

The absent value requires root permissions, also see the examples.

Choices:

  • absent

  • latest

  • present ← (default)

upgrade_all

aliases: upgrade

boolean

Upgrade all installed Mac App Store apps.

Choices:

  • no ← (default)

  • yes

Notes

Note

  • This module supports check_mode.

Examples

- name: Install Keynote
  community.general.mas:
    id: 409183694
    state: present

- name: Install Divvy with command mas installed in /usr/local/bin
  community.general.mas:
    id: 413857545
    state: present
  environment:
    PATH: /usr/local/bin:{{ ansible_facts.env.PATH }}

- name: Install a list of apps
  community.general.mas:
    id:
      - 409183694 # Keynote
      - 413857545 # Divvy
    state: present

- name: Ensure the latest Keynote version is installed
  community.general.mas:
    id: 409183694
    state: latest

- name: Upgrade all installed Mac App Store apps
  community.general.mas:
    upgrade_all: yes

- name: Install specific apps and also upgrade all others
  community.general.mas:
    id:
      - 409183694 # Keynote
      - 413857545 # Divvy
    state: present
    upgrade_all: yes

- name: Uninstall Divvy
  community.general.mas:
    id: 413857545
    state: absent
  become: yes # Uninstallation requires root permissions

Authors

  • Michael Heap (@mheap)

  • Lukas Bestle (@lukasbestle)