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,10 +1,11 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2014, GeekChimp - Franck Nijhof <franck@geekchimp.com> (DO NOT CONTACT!)
# Copyright: (c) 2019, Ansible project
# Copyright: (c) 2019, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2014, GeekChimp - Franck Nijhof <franck@geekchimp.com> (DO NOT CONTACT!)
# Copyright (c) 2019, Ansible project
# Copyright (c) 2019, Abhijeet Kasurde <akasurde@redhat.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
@@ -21,6 +22,13 @@ description:
- macOS applications and other programs use the defaults system to record user preferences and other
information that must be maintained when the applications are not running (such as default font for new
documents, or the position of an Info panel).
extends_documentation_fragment:
- community.general.attributes
attributes:
check_mode:
support: full
diff_mode:
support: none
options:
domain:
description:
@@ -30,7 +38,7 @@ options:
host:
description:
- The host on which the preference should apply.
- The special value C(currentHost) corresponds to the C(-currentHost) switch of the defaults commandline tool.
- The special value V(currentHost) corresponds to the C(-currentHost) switch of the defaults commandline tool.
type: str
key:
description:
@@ -46,17 +54,16 @@ options:
description:
- Add new elements to the array for a key which has an array as its value.
type: bool
default: no
default: false
value:
description:
- The value to write.
- Only required when C(state=present).
- Only required when O(state=present).
type: raw
state:
description:
- The state of the user defaults.
- If set to C(list) will query the given parameter specified by C(key). Returns 'null' is nothing found or mis-spelled.
- C(list) added in version 2.8.
- If set to V(list) will query the given parameter specified by O(key). Returns V(null) is nothing found or mis-spelled.
type: str
choices: [ absent, list, present ]
default: present
@@ -70,49 +77,54 @@ notes:
'''
EXAMPLES = r'''
# TODO: Describe what happens in each example
- community.general.osx_defaults:
- name: Set boolean valued key for application domain
community.general.osx_defaults:
domain: com.apple.Safari
key: IncludeInternalDebugMenu
type: bool
value: true
state: present
- community.general.osx_defaults:
- name: Set string valued key for global domain
community.general.osx_defaults:
domain: NSGlobalDomain
key: AppleMeasurementUnits
type: string
value: Centimeters
state: present
- community.general.osx_defaults:
- name: Set int valued key for arbitrary plist
community.general.osx_defaults:
domain: /Library/Preferences/com.apple.SoftwareUpdate
key: AutomaticCheckEnabled
type: int
value: 1
become: yes
become: true
- community.general.osx_defaults:
- name: Set int valued key only for the current host
community.general.osx_defaults:
domain: com.apple.screensaver
host: currentHost
key: showClock
type: int
value: 1
- community.general.osx_defaults:
- name: Defaults to global domain and setting value
community.general.osx_defaults:
key: AppleMeasurementUnits
type: string
value: Centimeters
- community.general.osx_defaults:
- name: Setting an array valued key
community.general.osx_defaults:
key: AppleLanguages
type: array
value:
- en
- nl
- community.general.osx_defaults:
- name: Removing a key
community.general.osx_defaults:
domain: com.geekchimp.macable
key: ExampleKeyToRemove
state: absent
@@ -256,7 +268,7 @@ class OSXDefaults(object):
# If the RC is not 0, then terrible happened! Ooooh nooo!
if rc != 0:
raise OSXDefaultsException("An error occurred while reading key type from defaults: %s" % out)
raise OSXDefaultsException("An error occurred while reading key type from defaults: %s" % err)
# Ok, lets parse the type from output
data_type = out.strip().replace('Type is ', '')
@@ -267,9 +279,9 @@ class OSXDefaults(object):
# Strip output
out = out.strip()
# An non zero RC at this point is kinda strange...
# A non zero RC at this point is kinda strange...
if rc != 0:
raise OSXDefaultsException("An error occurred while reading key value from defaults: %s" % out)
raise OSXDefaultsException("An error occurred while reading key value from defaults: %s" % err)
# Convert string to list when type is array
if data_type == "array":
@@ -303,16 +315,17 @@ class OSXDefaults(object):
if not isinstance(value, list):
value = [value]
rc, out, err = self.module.run_command(self._base_command() + ['write', self.domain, self.key, '-' + self.type] + value)
rc, out, err = self.module.run_command(self._base_command() + ['write', self.domain, self.key, '-' + self.type] + value,
expand_user_and_vars=False)
if rc != 0:
raise OSXDefaultsException('An error occurred while writing value to defaults: %s' % out)
raise OSXDefaultsException('An error occurred while writing value to defaults: %s' % err)
def delete(self):
""" Deletes defaults key from domain """
rc, out, err = self.module.run_command(self._base_command() + ['delete', self.domain, self.key])
if rc != 0:
raise OSXDefaultsException("An error occurred while deleting key from defaults: %s" % out)
raise OSXDefaultsException("An error occurred while deleting key from defaults: %s" % err)
# /commands ----------------------------------------------------------- }}}