community.general.mas 模块 – 使用 mas-cli 管理 Mac App Store 应用程序
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。您需要其他要求才能使用此模块,请参阅 要求 了解详细信息。
要在剧本中使用它,请指定:community.general.mas
。
community.general 0.2.0 中的新增功能
概要
使用
mas-cli
从 Mac App Store 安装、卸载和更新 macOS 应用程序。
要求
以下要求需要在执行此模块的主机上满足。
macOS 10.11+
mas-cli (https://github.com/mas-cli/mas) 1.5.0+ 可作为 bin 路径中的
mas
使用需要使用的 Apple ID 已经登录到 Mac App Store(使用
mas account
检查)。对于任何使用 macOS 12.0+ 的用户,“检查用户是否已登录”的功能将被禁用。
对于任何使用 macOS 12.0+ 的用户,由于 https://github.com/mas-cli/mas/issues/417,需要事先通过 Mac App Store GUI 登录。
参数
参数 |
注释 |
---|---|
您要管理的应用程序的 Mac App Store 标识符。 可以通过在您的机器上运行 |
|
应用程序安装的所需状态。
选项
|
|
升级所有已安装的 Mac App Store 应用程序。 选项
|
属性
属性 |
支持 |
描述 |
---|---|---|
支持:完全 |
可以在 |
|
支持:无 |
在差异模式下,将返回有关已更改的内容(或可能需要在 |
示例
- 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: true
- name: Install specific apps and also upgrade all others
community.general.mas:
id:
- 409183694 # Keynote
- 413857545 # Divvy
state: present
upgrade_all: true
- name: Uninstall Divvy
community.general.mas:
id: 413857545
state: absent
become: true # Uninstallation requires root permissions