collection 교체

This commit is contained in:
정훈 변
2024-02-23 16:37:40 +09:00
parent b494779b5b
commit 3fd554eee9
38862 changed files with 220204 additions and 6600073 deletions

View File

@@ -1,9 +1,10 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2020, Lukas Bestle <project-ansible@lukasbestle.com>
# Copyright: (c) 2017, Michael Heap <m@michaelheap.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2020, Lukas Bestle <project-ansible@lukasbestle.com>
# Copyright (c) 2017, Michael Heap <m@michaelheap.com>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import absolute_import, division, print_function
__metaclass__ = type
@@ -18,6 +19,13 @@ version_added: '0.2.0'
author:
- Michael Heap (@mheap)
- Lukas Bestle (@lukasbestle)
extends_documentation_fragment:
- community.general.attributes
attributes:
check_mode:
support: full
diff_mode:
support: none
options:
id:
description:
@@ -28,7 +36,7 @@ options:
state:
description:
- Desired state of the app installation.
- The C(absent) value requires root permissions, also see the examples.
- The V(absent) value requires root permissions, also see the examples.
type: str
choices:
- absent
@@ -39,14 +47,14 @@ options:
description:
- Upgrade all installed Mac App Store apps.
type: bool
default: "no"
default: false
aliases: ["upgrade"]
requirements:
- macOS 10.11+
- "mas-cli (U(https://github.com/mas-cli/mas)) 1.5.0+ available as C(mas) in the bin path"
- The Apple ID to use already needs to be signed in to the Mac App Store (check with C(mas account)).
notes:
- This module supports C(check_mode).
- The feature of "checking if user is signed in" is disabled for anyone using macOS 12.0+.
- Users need to sign in via the Mac App Store GUI beforehand for anyone using macOS 12.0+ due to U(https://github.com/mas-cli/mas/issues/417).
'''
EXAMPLES = '''
@@ -76,7 +84,7 @@ EXAMPLES = '''
- name: Upgrade all installed Mac App Store apps
community.general.mas:
upgrade_all: yes
upgrade_all: true
- name: Install specific apps and also upgrade all others
community.general.mas:
@@ -84,23 +92,25 @@ EXAMPLES = '''
- 409183694 # Keynote
- 413857545 # Divvy
state: present
upgrade_all: yes
upgrade_all: true
- name: Uninstall Divvy
community.general.mas:
id: 413857545
state: absent
become: yes # Uninstallation requires root permissions
become: true # Uninstallation requires root permissions
'''
RETURN = r''' # '''
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.text.converters import to_native
import os
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
import platform
NOT_WORKING_MAC_VERSION_MAS_ACCOUNT = '12.0'
class Mas(object):
@@ -110,6 +120,7 @@ class Mas(object):
# Initialize data properties
self.mas_path = self.module.get_bin_path('mas')
self._checked_signin = False
self._mac_version = platform.mac_ver()[0] or '0.0'
self._installed = None # Populated only if needed
self._outdated = None # Populated only if needed
self.count_install = 0
@@ -151,14 +162,16 @@ class Mas(object):
def check_signin(self):
''' Verifies that the user is signed in to the Mac App Store '''
# Only check this once per execution
if self._checked_signin:
return
rc, out, err = self.run(['account'])
if out.split("\n", 1)[0].rstrip() == 'Not signed in':
self.module.fail_json(msg='You must be signed in to the Mac App Store')
if LooseVersion(self._mac_version) >= LooseVersion(NOT_WORKING_MAC_VERSION_MAS_ACCOUNT):
# Checking if user is signed-in is disabled due to https://github.com/mas-cli/mas/issues/417
self.module.log('WARNING: You must be signed in via the Mac App Store GUI beforehand else error will occur')
else:
rc, out, err = self.run(['account'])
if out.split("\n", 1)[0].rstrip() == 'Not signed in':
self.module.fail_json(msg='You must be signed in to the Mac App Store')
self._checked_signin = True
@@ -273,7 +286,7 @@ def main():
if mas.is_installed(app):
# Ensure we are root
if os.getuid() != 0:
module.fail_json(msg="Uninstalling apps requires root permissions ('become: yes')")
module.fail_json(msg="Uninstalling apps requires root permissions ('become: true')")
mas.app_command('uninstall', app)