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,6 +1,7 @@
# -*- coding: utf-8 -*-
# (c) 2018 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2018 Matt Martz <matt@sivel.net>
# 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
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
@@ -15,23 +16,23 @@ DOCUMENTATION = '''
- cgroups
short_description: Profiles maximum memory usage of tasks and full execution using cgroups
description:
- This is an ansible callback plugin that profiles maximum memory usage of ansible and individual tasks, and displays a recap at the end using cgroups
- This is an ansible callback plugin that profiles maximum memory usage of ansible and individual tasks, and displays a recap at the end using cgroups.
notes:
- Requires ansible to be run from within a cgroup, such as with C(cgexec -g memory:ansible_profile ansible-playbook ...)
- This cgroup should only be used by ansible to get accurate results
- To create the cgroup, first use a command such as C(sudo cgcreate -a ec2-user:ec2-user -t ec2-user:ec2-user -g memory:ansible_profile)
- Requires ansible to be run from within a cgroup, such as with C(cgexec -g memory:ansible_profile ansible-playbook ...).
- This cgroup should only be used by ansible to get accurate results.
- To create the cgroup, first use a command such as C(sudo cgcreate -a ec2-user:ec2-user -t ec2-user:ec2-user -g memory:ansible_profile).
options:
max_mem_file:
required: True
description: Path to cgroups C(memory.max_usage_in_bytes) file. Example C(/sys/fs/cgroup/memory/ansible_profile/memory.max_usage_in_bytes)
required: true
description: Path to cgroups C(memory.max_usage_in_bytes) file. Example V(/sys/fs/cgroup/memory/ansible_profile/memory.max_usage_in_bytes).
env:
- name: CGROUP_MAX_MEM_FILE
ini:
- section: callback_cgroupmemrecap
key: max_mem_file
cur_mem_file:
required: True
description: Path to C(memory.usage_in_bytes) file. Example C(/sys/fs/cgroup/memory/ansible_profile/memory.usage_in_bytes)
required: true
description: Path to C(memory.usage_in_bytes) file. Example V(/sys/fs/cgroup/memory/ansible_profile/memory.usage_in_bytes).
env:
- name: CGROUP_CUR_MEM_FILE
ini:

View File

@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# (C) 2012, Michael DeHaan, <michael.dehaan@gmail.com>
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (C) 2012, Michael DeHaan, <michael.dehaan@gmail.com>
# Copyright (c) 2017 Ansible Project
# 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
@@ -12,8 +13,8 @@ DOCUMENTATION = '''
type: aggregate
short_description: demo callback that adds play/task context
description:
- Displays some play and task context along with normal output
- This is mostly for demo purposes
- Displays some play and task context along with normal output.
- This is mostly for demo purposes.
requirements:
- whitelist in configuration
'''

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# (c) 2018, Ivan Aragones Muniesa <ivan.aragones.muniesa@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2018, Ivan Aragones Muniesa <ivan.aragones.muniesa@gmail.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
'''
Counter enabled Ansible callback plugin (See DOCUMENTATION for more information)
'''
@@ -20,13 +21,12 @@ DOCUMENTATION = '''
extends_documentation_fragment:
- default_callback
requirements:
- set as stdout callback in ansible.cfg (stdout_callback = counter_enabled)
- set as stdout callback in C(ansible.cfg) (C(stdout_callback = counter_enabled))
'''
from ansible import constants as C
from ansible.plugins.callback import CallbackBase
from ansible.utils.color import colorize, hostcolor
from ansible.template import Templar
from ansible.playbook.task_include import TaskInclude

View File

@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# (c) 2016, Dag Wieers <dag@wieers.com>
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2016, Dag Wieers <dag@wieers.com>
# Copyright (c) 2017 Ansible Project
# 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
@@ -13,7 +14,7 @@ short_description: minimal stdout output
extends_documentation_fragment:
- default_callback
description:
- When in verbose mode it will act the same as the default callback
- When in verbose mode it will act the same as the default callback.
author:
- Dag Wieers (@dagwieers)
requirements:
@@ -232,13 +233,13 @@ class CallbackModule(CallbackModule_default):
# Remove non-essential attributes
for attr in self.removed_attributes:
if attr in result:
del(result[attr])
del result[attr]
# Remove empty attributes (list, dict, str)
for attr in result.copy():
if isinstance(result[attr], (MutableSequence, MutableMapping, binary_type, text_type)):
if not result[attr]:
del(result[attr])
del result[attr]
def _handle_exceptions(self, result):
if 'exception' in result:

View File

@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright: (c) 2019, Trevor Highfill <trevor.highfill@outlook.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2019, Trevor Highfill <trevor.highfill@outlook.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
@@ -17,7 +18,7 @@ DOCUMENTATION = r'''
extends_documentation_fragment:
- default_callback
notes:
- Uses the C(default) callback plugin output when a custom callback message(C(msg)) is not provided.
- Uses the P(ansible.builtin.default#callback) callback plugin output when a custom callback V(message(msg\)) is not provided.
- Makes the callback event data available via the C(ansible_callback_diy) dictionary, which can be used in the templating context for the options.
The dictionary is only available in the templating context for the options. It is not a variable that is available via the other
various execution contexts, such as playbook, play, task etc.
@@ -39,8 +40,8 @@ DOCUMENTATION = r'''
if value C(is not None and not omit and length is greater than 0),
then the option is being used with output.
**Effect**: render value as template and output"
- "Valid color values: C(black), C(bright gray), C(blue), C(white), C(green), C(bright blue), C(cyan), C(bright green), C(red), C(bright cyan),
C(purple), C(bright red), C(yellow), C(bright purple), C(dark gray), C(bright yellow), C(magenta), C(bright magenta), C(normal)"
- "Valid color values: V(black), V(bright gray), V(blue), V(white), V(green), V(bright blue), V(cyan), V(bright green), V(red), V(bright cyan),
V(purple), V(bright red), V(yellow), V(bright purple), V(dark gray), V(bright yellow), V(magenta), V(bright magenta), V(normal)"
seealso:
- name: default default Ansible screen output
description: The official documentation on the B(default) callback plugin.
@@ -61,7 +62,7 @@ DOCUMENTATION = r'''
on_any_msg_color:
description:
- Output color to be used for I(on_any_msg).
- Output color to be used for O(on_any_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -85,7 +86,7 @@ DOCUMENTATION = r'''
runner_on_failed_msg_color:
description:
- Output color to be used for I(runner_on_failed_msg).
- Output color to be used for O(runner_on_failed_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -109,7 +110,7 @@ DOCUMENTATION = r'''
runner_on_ok_msg_color:
description:
- Output color to be used for I(runner_on_ok_msg).
- Output color to be used for O(runner_on_ok_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -133,7 +134,7 @@ DOCUMENTATION = r'''
runner_on_skipped_msg_color:
description:
- Output color to be used for I(runner_on_skipped_msg).
- Output color to be used for O(runner_on_skipped_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -157,7 +158,7 @@ DOCUMENTATION = r'''
runner_on_unreachable_msg_color:
description:
- Output color to be used for I(runner_on_unreachable_msg).
- Output color to be used for O(runner_on_unreachable_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -181,7 +182,7 @@ DOCUMENTATION = r'''
playbook_on_start_msg_color:
description:
- Output color to be used for I(playbook_on_start_msg).
- Output color to be used for O(playbook_on_start_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -205,7 +206,7 @@ DOCUMENTATION = r'''
playbook_on_notify_msg_color:
description:
- Output color to be used for I(playbook_on_notify_msg).
- Output color to be used for O(playbook_on_notify_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -229,7 +230,7 @@ DOCUMENTATION = r'''
playbook_on_no_hosts_matched_msg_color:
description:
- Output color to be used for I(playbook_on_no_hosts_matched_msg).
- Output color to be used for O(playbook_on_no_hosts_matched_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -253,7 +254,7 @@ DOCUMENTATION = r'''
playbook_on_no_hosts_remaining_msg_color:
description:
- Output color to be used for I(playbook_on_no_hosts_remaining_msg).
- Output color to be used for O(playbook_on_no_hosts_remaining_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -277,7 +278,7 @@ DOCUMENTATION = r'''
playbook_on_task_start_msg_color:
description:
- Output color to be used for I(playbook_on_task_start_msg).
- Output color to be used for O(playbook_on_task_start_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -301,7 +302,7 @@ DOCUMENTATION = r'''
playbook_on_handler_task_start_msg_color:
description:
- Output color to be used for I(playbook_on_handler_task_start_msg).
- Output color to be used for O(playbook_on_handler_task_start_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -325,7 +326,7 @@ DOCUMENTATION = r'''
playbook_on_vars_prompt_msg_color:
description:
- Output color to be used for I(playbook_on_vars_prompt_msg).
- Output color to be used for O(playbook_on_vars_prompt_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -349,7 +350,7 @@ DOCUMENTATION = r'''
playbook_on_play_start_msg_color:
description:
- Output color to be used for I(playbook_on_play_start_msg).
- Output color to be used for O(playbook_on_play_start_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -373,7 +374,7 @@ DOCUMENTATION = r'''
playbook_on_stats_msg_color:
description:
- Output color to be used for I(playbook_on_stats_msg).
- Output color to be used for O(playbook_on_stats_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -397,7 +398,7 @@ DOCUMENTATION = r'''
on_file_diff_msg_color:
description:
- Output color to be used for I(on_file_diff_msg).
- Output color to be used for O(on_file_diff_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -421,7 +422,7 @@ DOCUMENTATION = r'''
playbook_on_include_msg_color:
description:
- Output color to be used for I(playbook_on_include_msg).
- Output color to be used for O(playbook_on_include_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -445,7 +446,7 @@ DOCUMENTATION = r'''
runner_item_on_ok_msg_color:
description:
- Output color to be used for I(runner_item_on_ok_msg).
- Output color to be used for O(runner_item_on_ok_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -469,7 +470,7 @@ DOCUMENTATION = r'''
runner_item_on_failed_msg_color:
description:
- Output color to be used for I(runner_item_on_failed_msg).
- Output color to be used for O(runner_item_on_failed_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -493,7 +494,7 @@ DOCUMENTATION = r'''
runner_item_on_skipped_msg_color:
description:
- Output color to be used for I(runner_item_on_skipped_msg).
- Output color to be used for O(runner_item_on_skipped_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -517,7 +518,7 @@ DOCUMENTATION = r'''
runner_retry_msg_color:
description:
- Output color to be used for I(runner_retry_msg).
- Output color to be used for O(runner_retry_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -541,7 +542,7 @@ DOCUMENTATION = r'''
runner_on_start_msg_color:
description:
- Output color to be used for I(runner_on_start_msg).
- Output color to be used for O(runner_on_start_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -565,7 +566,7 @@ DOCUMENTATION = r'''
runner_on_no_hosts_msg_color:
description:
- Output color to be used for I(runner_on_no_hosts_msg).
- Output color to be used for O(runner_on_no_hosts_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -589,7 +590,7 @@ DOCUMENTATION = r'''
playbook_on_setup_msg_color:
description:
- Output color to be used for I(playbook_on_setup_msg).
- Output color to be used for O(playbook_on_setup_msg).
- Template should render a L(valid color value,#notes).
ini:
- section: callback_diy
@@ -626,7 +627,7 @@ playbook.yml: >
---
- name: "Default plugin output: play example"
hosts: localhost
gather_facts: no
gather_facts: false
tasks:
- name: Default plugin output
ansible.builtin.debug:
@@ -634,7 +635,7 @@ playbook.yml: >
- name: Override from play vars
hosts: localhost
gather_facts: no
gather_facts: false
vars:
ansible_connection: local
green: "\e[0m\e[38;5;82m"
@@ -712,7 +713,7 @@ playbook.yml: >
- name: Using alias vars (see ansible.cfg)
ansible.builtin.debug:
msg:
when: False
when: false
vars:
ansible_callback_diy_playbook_on_task_start_msg: ""
on_skipped_msg: "DIY output(via task vars): skipped example:\n\e[0m\e[38;5;4m\u25b6\u25b6 {{ ansible_callback_diy.result.task.name }}\n"
@@ -785,10 +786,6 @@ playbook.yml: >
import sys
from contextlib import contextmanager
from ansible import constants as C
from ansible.playbook.task_include import TaskInclude
from ansible.plugins.callback import CallbackBase
from ansible.utils.color import colorize, hostcolor
from ansible.template import Templar
from ansible.vars.manager import VariableManager
from ansible.plugins.callback.default import CallbackModule as Default

View File

@@ -1,5 +1,6 @@
# (C) 2021, Victor Martinez <VictorMartinezRubio@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2021, Victor Martinez <VictorMartinezRubio@gmail.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
@@ -83,6 +84,7 @@ import time
import uuid
from collections import OrderedDict
from contextlib import closing
from os.path import basename
from ansible.errors import AnsibleError, AnsibleRuntimeError
@@ -200,24 +202,25 @@ class ElasticSource(object):
apm_cli = self.init_apm_client(apm_server_url, apm_service_name, apm_verify_server_cert, apm_secret_token, apm_api_key)
if apm_cli:
instrument() # Only call this once, as early as possible.
if traceparent:
parent = trace_parent_from_string(traceparent)
apm_cli.begin_transaction("Session", trace_parent=parent, start=parent_start_time)
else:
apm_cli.begin_transaction("Session", start=parent_start_time)
# Populate trace metadata attributes
if self.ansible_version is not None:
label(ansible_version=self.ansible_version)
label(ansible_session=self.session, ansible_host_name=self.host, ansible_host_user=self.user)
if self.ip_address is not None:
label(ansible_host_ip=self.ip_address)
with closing(apm_cli):
instrument() # Only call this once, as early as possible.
if traceparent:
parent = trace_parent_from_string(traceparent)
apm_cli.begin_transaction("Session", trace_parent=parent, start=parent_start_time)
else:
apm_cli.begin_transaction("Session", start=parent_start_time)
# Populate trace metadata attributes
if self.ansible_version is not None:
label(ansible_version=self.ansible_version)
label(ansible_session=self.session, ansible_host_name=self.host, ansible_host_user=self.user)
if self.ip_address is not None:
label(ansible_host_ip=self.ip_address)
for task_data in tasks:
for host_uuid, host_data in task_data.host_data.items():
self.create_span_data(apm_cli, task_data, host_data)
for task_data in tasks:
for host_uuid, host_data in task_data.host_data.items():
self.create_span_data(apm_cli, task_data, host_data)
apm_cli.end_transaction(name=__name__, result=status, duration=end_time - parent_start_time)
apm_cli.end_transaction(name=__name__, result=status, duration=end_time - parent_start_time)
def create_span_data(self, apm_cli, task_data, host_data):
""" create the span with the given TaskData and HostData """

View File

@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# (C) 2014, Matt Martz <matt@sivel.net>
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2014, Matt Martz <matt@sivel.net>
# Copyright (c) 2017 Ansible Project
# 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
@@ -20,7 +21,7 @@ DOCUMENTATION = '''
options:
token:
description: HipChat API token for v1 or v2 API.
required: True
required: true
env:
- name: HIPCHAT_TOKEN
ini:
@@ -28,7 +29,7 @@ DOCUMENTATION = '''
key: token
api_version:
description: HipChat API version, v1 or v2.
required: False
required: false
default: v1
env:
- name: HIPCHAT_API_VERSION
@@ -54,7 +55,7 @@ DOCUMENTATION = '''
notify:
description: Add notify flag to important messages
type: bool
default: True
default: true
env:
- name: HIPCHAT_NOTIFY
ini:

View File

@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2016 maxn nikolaev.makc@gmail.com
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# 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
@@ -12,29 +13,29 @@ DOCUMENTATION = '''
type: notification
short_description: post task events to a jabber server
description:
- The chatty part of ChatOps with a Hipchat server as a target
- The chatty part of ChatOps with a Hipchat server as a target.
- This callback plugin sends status updates to a HipChat channel during playbook execution.
requirements:
- xmpp (python lib https://github.com/ArchipelProject/xmpppy)
- xmpp (Python library U(https://github.com/ArchipelProject/xmpppy))
options:
server:
description: connection info to jabber server
required: True
required: true
env:
- name: JABBER_SERV
user:
description: Jabber user to authenticate as
required: True
required: true
env:
- name: JABBER_USER
password:
description: Password for the user to the jabber server
required: True
required: true
env:
- name: JABBER_PASS
to:
description: chat identifier that will receive the message
required: True
required: true
env:
- name: JABBER_TO
'''

View File

@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# (C) 2012, Michael DeHaan, <michael.dehaan@gmail.com>
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2012, Michael DeHaan, <michael.dehaan@gmail.com>
# Copyright (c) 2017 Ansible Project
# 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
@@ -12,10 +13,10 @@ DOCUMENTATION = '''
type: notification
short_description: write playbook output to log file
description:
- This callback writes playbook output to a file per host in the `/var/log/ansible/hosts` directory
- This callback writes playbook output to a file per host in the C(/var/log/ansible/hosts) directory.
requirements:
- Whitelist in configuration
- A writeable /var/log/ansible/hosts directory by the user executing Ansible on the controller
- A writeable C(/var/log/ansible/hosts) directory by the user executing Ansible on the controller
options:
log_folder:
default: /var/log/ansible/hosts

View File

@@ -1,12 +1,14 @@
# -*- coding: utf-8 -*-
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) Ansible project
# 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
DOCUMENTATION = '''
name: loganalytics
type: aggregate
type: notification
short_description: Posts task results to Azure Log Analytics
author: "Cyrus Li (@zhcli) <cyrus1006@gmail.com>"
description:
@@ -52,7 +54,6 @@ examples: |
import hashlib
import hmac
import base64
import logging
import json
import uuid
import socket
@@ -153,7 +154,7 @@ class AzureLogAnalyticsSource(object):
class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'aggregate'
CALLBACK_TYPE = 'notification'
CALLBACK_NAME = 'loganalytics'
CALLBACK_NEEDS_WHITELIST = True

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# (c) 2018, Samir Musali <samir.musali@logdna.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2018, Samir Musali <samir.musali@logdna.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
@@ -8,17 +9,17 @@ __metaclass__ = type
DOCUMENTATION = '''
author: Unknown (!UNKNOWN)
name: logdna
type: aggregate
type: notification
short_description: Sends playbook logs to LogDNA
description:
- This callback will report logs from playbook actions, tasks, and events to LogDNA (https://app.logdna.com)
- This callback will report logs from playbook actions, tasks, and events to LogDNA (U(https://app.logdna.com)).
requirements:
- LogDNA Python Library (https://github.com/logdna/python)
- LogDNA Python Library (U(https://github.com/logdna/python))
- whitelisting in configuration
options:
conf_key:
required: True
description: LogDNA Ingestion Key
required: true
description: LogDNA Ingestion Key.
type: string
env:
- name: LOGDNA_INGESTION_KEY
@@ -26,18 +27,18 @@ DOCUMENTATION = '''
- section: callback_logdna
key: conf_key
plugin_ignore_errors:
required: False
description: Whether to ignore errors on failing or not
required: false
description: Whether to ignore errors on failing or not.
type: boolean
env:
- name: ANSIBLE_IGNORE_ERRORS
ini:
- section: callback_logdna
key: plugin_ignore_errors
default: False
default: false
conf_hostname:
required: False
description: Alternative Host Name; the current host name by default
required: false
description: Alternative Host Name; the current host name by default.
type: string
env:
- name: LOGDNA_HOSTNAME
@@ -45,8 +46,8 @@ DOCUMENTATION = '''
- section: callback_logdna
key: conf_hostname
conf_tags:
required: False
description: Tags
required: false
description: Tags.
type: string
env:
- name: LOGDNA_TAGS
@@ -110,7 +111,7 @@ def isJSONable(obj):
class CallbackModule(CallbackBase):
CALLBACK_VERSION = 0.1
CALLBACK_TYPE = 'aggregate'
CALLBACK_TYPE = 'notification'
CALLBACK_NAME = 'community.general.logdna'
CALLBACK_NEEDS_WHITELIST = True

View File

@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# (c) 2015, Logentries.com, Jimmy Tang <jimmy.tang@logentries.com>
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2015, Logentries.com, Jimmy Tang <jimmy.tang@logentries.com>
# Copyright (c) 2017 Ansible Project
# 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
@@ -12,15 +13,15 @@ DOCUMENTATION = '''
short_description: Sends events to Logentries
description:
- This callback plugin will generate JSON objects and send them to Logentries via TCP for auditing/debugging purposes.
- Before 2.4, if you wanted to use an ini configuration, the file must be placed in the same directory as this plugin and named logentries.ini
- Before 2.4, if you wanted to use an ini configuration, the file must be placed in the same directory as this plugin and named C(logentries.ini).
- In 2.4 and above you can just put it in the main Ansible configuration file.
requirements:
- whitelisting in configuration
- certifi (python library)
- flatdict (python library), if you want to use the 'flatten' option
- certifi (Python library)
- flatdict (Python library), if you want to use the O(flatten) option
options:
api:
description: URI to the Logentries API
description: URI to the Logentries API.
env:
- name: LOGENTRIES_API
default: data.logentries.com
@@ -28,7 +29,7 @@ DOCUMENTATION = '''
- section: callback_logentries
key: api
port:
description: HTTP port to use when connecting to the API
description: HTTP port to use when connecting to the API.
env:
- name: LOGENTRIES_PORT
default: 80
@@ -36,7 +37,7 @@ DOCUMENTATION = '''
- section: callback_logentries
key: port
tls_port:
description: Port to use when connecting to the API when TLS is enabled
description: Port to use when connecting to the API when TLS is enabled.
env:
- name: LOGENTRIES_TLS_PORT
default: 443
@@ -44,27 +45,27 @@ DOCUMENTATION = '''
- section: callback_logentries
key: tls_port
token:
description: The logentries "TCP token"
description: The logentries C(TCP token).
env:
- name: LOGENTRIES_ANSIBLE_TOKEN
required: True
required: true
ini:
- section: callback_logentries
key: token
use_tls:
description:
- Toggle to decide whether to use TLS to encrypt the communications with the API server
- Toggle to decide whether to use TLS to encrypt the communications with the API server.
env:
- name: LOGENTRIES_USE_TLS
default: False
default: false
type: boolean
ini:
- section: callback_logentries
key: use_tls
flatten:
description: flatten complex data structures into a single dictionary with complex keys
description: Flatten complex data structures into a single dictionary with complex keys.
type: boolean
default: False
default: false
env:
- name: LOGENTRIES_FLATTEN
ini:
@@ -89,9 +90,9 @@ examples: >
api = data.logentries.com
port = 10000
tls_port = 20000
use_tls = no
use_tls = true
token = dd21fc88-f00a-43ff-b977-e3a4233c53af
flatten = False
flatten = false
'''
import os
@@ -195,15 +196,11 @@ else:
class TLSSocketAppender(PlainTextSocketAppender):
def open_connection(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock = ssl.wrap_socket(
context = ssl.create_default_context(
purpose=ssl.Purpose.SERVER_AUTH,
cafile=certifi.where(), )
sock = context.wrap_socket(
sock=sock,
keyfile=None,
certfile=None,
server_side=False,
cert_reqs=ssl.CERT_REQUIRED,
ssl_version=getattr(
ssl, 'PROTOCOL_TLSv1_2', ssl.PROTOCOL_TLSv1),
ca_certs=certifi.where(),
do_handshake_on_connect=True,
suppress_ragged_eofs=True, )
sock.connect((self.LE_API, self.LE_TLS_PORT))

View File

@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# (C) 2020, Yevhen Khmelenko <ujenmr@gmail.com>
# (C) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2020, Yevhen Khmelenko <ujenmr@gmail.com>
# Copyright (c) 2017 Ansible Project
# 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
@@ -12,13 +13,13 @@ DOCUMENTATION = r'''
type: notification
short_description: Sends events to Logstash
description:
- This callback will report facts and task events to Logstash https://www.elastic.co/products/logstash
- This callback will report facts and task events to Logstash U(https://www.elastic.co/products/logstash).
requirements:
- whitelisting in configuration
- logstash (python library)
- logstash (Python library)
options:
server:
description: Address of the Logstash server
description: Address of the Logstash server.
env:
- name: LOGSTASH_SERVER
ini:
@@ -27,7 +28,7 @@ DOCUMENTATION = r'''
version_added: 1.0.0
default: localhost
port:
description: Port on which logstash is listening
description: Port on which logstash is listening.
env:
- name: LOGSTASH_PORT
ini:
@@ -36,7 +37,7 @@ DOCUMENTATION = r'''
version_added: 1.0.0
default: 5000
type:
description: Message type
description: Message type.
env:
- name: LOGSTASH_TYPE
ini:
@@ -45,7 +46,7 @@ DOCUMENTATION = r'''
version_added: 1.0.0
default: ansible
pre_command:
description: Executes command before run and result put to ansible_pre_command_output field.
description: Executes command before run and its result is added to the C(ansible_pre_command_output) logstash field.
version_added: 2.0.0
ini:
- section: callback_logstash
@@ -53,7 +54,7 @@ DOCUMENTATION = r'''
env:
- name: LOGSTASH_PRE_COMMAND
format_version:
description: Logging format
description: Logging format.
type: str
version_added: 2.0.0
ini:
@@ -112,7 +113,7 @@ from ansible.plugins.callback import CallbackBase
class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'aggregate'
CALLBACK_TYPE = 'notification'
CALLBACK_NAME = 'community.general.logstash'
CALLBACK_NEEDS_WHITELIST = True

View File

@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright: (c) 2012, Dag Wieers <dag@wieers.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2012, Dag Wieers <dag@wieers.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
@@ -48,8 +49,9 @@ options:
sender:
description:
- Mail sender.
- Note that this will be required from community.general 6.0.0 on.
- This is required since community.general 6.0.0.
type: str
required: true
ini:
- section: callback_mail
key: sender
@@ -69,6 +71,16 @@ options:
ini:
- section: callback_mail
key: bcc
message_id_domain:
description:
- The domain name to use for the L(Message-ID header, https://en.wikipedia.org/wiki/Message-ID).
- The default is the hostname of the control node.
type: str
ini:
- section: callback_mail
key: message_id_domain
version_added: 8.2.0
'''
import json
@@ -77,7 +89,6 @@ import re
import email.utils
import smtplib
from ansible.module_utils.six import string_types
from ansible.module_utils.common.text.converters import to_bytes
from ansible.parsing.ajson import AnsibleJSONEncoder
from ansible.plugins.callback import CallbackBase
@@ -104,10 +115,6 @@ class CallbackModule(CallbackBase):
super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
self.sender = self.get_option('sender')
if self.sender is None:
self._display.deprecated(
'The sender for the mail callback has not been specified. This will be an error in the future',
version='6.0.0', collection_name='community.general')
self.to = self.get_option('to')
self.smtphost = self.get_option('mta')
self.smtpport = self.get_option('mtaport')
@@ -134,7 +141,7 @@ class CallbackModule(CallbackBase):
content += 'To: %s\n' % ', '.join([email.utils.formataddr(pair) for pair in to_addresses])
if self.cc:
content += 'Cc: %s\n' % ', '.join([email.utils.formataddr(pair) for pair in cc_addresses])
content += 'Message-ID: %s\n' % email.utils.make_msgid()
content += 'Message-ID: %s\n' % email.utils.make_msgid(domain=self.get_option('message_id_domain'))
content += 'Subject: %s\n\n' % subject.strip()
content += body

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# (c) 2018 Remi Verchere <remi@verchere.fr>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2018 Remi Verchere <remi@verchere.fr>
# 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
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
@@ -13,7 +14,7 @@ DOCUMENTATION = '''
short_description: Post task results to a Nagios server through nrdp
description:
- This callback send playbook result to Nagios.
- Nagios shall use NRDP to recive passive events.
- Nagios shall use NRDP to receive passive events.
- The passive check is sent to a dedicated host/service for Ansible.
options:
url:
@@ -66,9 +67,6 @@ DOCUMENTATION = '''
type: string
'''
import os
import json
from ansible.module_utils.six.moves.urllib.parse import urlencode
from ansible.module_utils.common.text.converters import to_bytes
from ansible.module_utils.urls import open_url

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2017 Ansible Project
# 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
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
@@ -14,7 +15,7 @@ DOCUMENTATION = '''
- set as main display callback
short_description: Don't display stuff to screen
description:
- This callback prevents outputing events to screen
- This callback prevents outputting events to screen.
'''
from ansible.plugins.callback import CallbackBase
@@ -23,7 +24,7 @@ from ansible.plugins.callback import CallbackBase
class CallbackModule(CallbackBase):
'''
This callback wont print messages to stdout when new callback events are received.
This callback won't print messages to stdout when new callback events are received.
'''
CALLBACK_VERSION = 2.0

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# (C) 2021, Victor Martinez <VictorMartinezRubio@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2021, Victor Martinez <VictorMartinezRubio@gmail.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
@@ -24,16 +25,24 @@ DOCUMENTATION = '''
- Hide the arguments for a task.
env:
- name: ANSIBLE_OPENTELEMETRY_HIDE_TASK_ARGUMENTS
ini:
- section: callback_opentelemetry
key: hide_task_arguments
version_added: 5.3.0
enable_from_environment:
type: str
description:
- Whether to enable this callback only if the given environment variable exists and it is set to C(true).
- Whether to enable this callback only if the given environment variable exists and it is set to V(true).
- This is handy when you use Configuration as Code and want to send distributed traces
if running in the CI rather when running Ansible locally.
- For such, it evaluates the given I(enable_from_environment) value as environment variable
- For such, it evaluates the given O(enable_from_environment) value as environment variable
and if set to true this plugin will be enabled.
env:
- name: ANSIBLE_OPENTELEMETRY_ENABLE_FROM_ENVIRONMENT
ini:
- section: callback_opentelemetry
key: enable_from_environment
version_added: 5.3.0
version_added: 3.8.0
otel_service_name:
default: ansible
@@ -42,6 +51,10 @@ DOCUMENTATION = '''
- The service name resource attribute.
env:
- name: OTEL_SERVICE_NAME
ini:
- section: callback_opentelemetry
key: otel_service_name
version_added: 5.3.0
traceparent:
default: None
type: str
@@ -49,6 +62,28 @@ DOCUMENTATION = '''
- The L(W3C Trace Context header traceparent,https://www.w3.org/TR/trace-context-1/#traceparent-header).
env:
- name: TRACEPARENT
disable_logs:
default: false
type: bool
description:
- Disable sending logs.
env:
- name: ANSIBLE_OPENTELEMETRY_DISABLE_LOGS
ini:
- section: callback_opentelemetry
key: disable_logs
version_added: 5.8.0
disable_attributes_in_logs:
default: false
type: bool
description:
- Disable populating span attributes to the logs.
env:
- name: ANSIBLE_OPENTELEMETRY_DISABLE_ATTRIBUTES_IN_LOGS
ini:
- section: callback_opentelemetry
key: disable_attributes_in_logs
version_added: 7.1.0
requirements:
- opentelemetry-api (Python library)
- opentelemetry-exporter-otlp (Python library)
@@ -61,11 +96,14 @@ examples: |
Enable the plugin in ansible.cfg:
[defaults]
callbacks_enabled = community.general.opentelemetry
[callback_opentelemetry]
enable_from_environment = ANSIBLE_OPENTELEMETRY_ENABLED
Set the environment variable:
export OTEL_EXPORTER_OTLP_ENDPOINT=<your endpoint (OTLP/HTTP)>
export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer your_otel_token"
export OTEL_SERVICE_NAME=your_service_name
export ANSIBLE_OPENTELEMETRY_ENABLED=true
'''
import getpass
@@ -94,13 +132,32 @@ try:
from opentelemetry.sdk.trace.export import (
BatchSpanProcessor
)
from opentelemetry.util._time import _time_ns
# Support for opentelemetry-api <= 1.12
try:
from opentelemetry.util._time import _time_ns
except ImportError as imp_exc:
OTEL_LIBRARY_TIME_NS_ERROR = imp_exc
else:
OTEL_LIBRARY_TIME_NS_ERROR = None
except ImportError as imp_exc:
OTEL_LIBRARY_IMPORT_ERROR = imp_exc
OTEL_LIBRARY_TIME_NS_ERROR = imp_exc
else:
OTEL_LIBRARY_IMPORT_ERROR = None
if sys.version_info >= (3, 7):
time_ns = time.time_ns
elif not OTEL_LIBRARY_TIME_NS_ERROR:
time_ns = _time_ns
else:
def time_ns():
# Support versions older than 3.7 with opentelemetry-api > 1.12
return int(time.time() * 1e9)
class TaskData:
"""
Data about an individual task.
@@ -112,12 +169,10 @@ class TaskData:
self.path = path
self.play = play
self.host_data = OrderedDict()
if sys.version_info >= (3, 7):
self.start = time.time_ns()
else:
self.start = _time_ns()
self.start = time_ns()
self.action = action
self.args = args
self.dump = None
def add_host(self, host):
if host.uuid in self.host_data:
@@ -140,10 +195,7 @@ class HostData:
self.name = name
self.status = status
self.result = result
if sys.version_info >= (3, 7):
self.finish = time.time_ns()
else:
self.finish = _time_ns()
self.finish = time_ns()
class OpenTelemetrySource(object):
@@ -183,7 +235,7 @@ class OpenTelemetrySource(object):
tasks_data[uuid] = TaskData(uuid, name, path, play_name, action, args)
def finish_task(self, tasks_data, status, result):
def finish_task(self, tasks_data, status, result, dump):
""" record the results of a task for a single host """
task_uuid = result._task._uuid
@@ -197,12 +249,13 @@ class OpenTelemetrySource(object):
task = tasks_data[task_uuid]
if self.ansible_version is None and result._task_fields['args'].get('_ansible_version'):
if self.ansible_version is None and hasattr(result, '_task_fields') and result._task_fields['args'].get('_ansible_version'):
self.ansible_version = result._task_fields['args'].get('_ansible_version')
task.dump = dump
task.add_host(HostData(host_uuid, host_name, status, result))
def generate_distributed_traces(self, otel_service_name, ansible_playbook, tasks_data, status, traceparent):
def generate_distributed_traces(self, otel_service_name, ansible_playbook, tasks_data, status, traceparent, disable_logs, disable_attributes_in_logs):
""" generate distributed traces from the collected TaskData and HostData """
tasks = []
@@ -238,9 +291,9 @@ class OpenTelemetrySource(object):
for task in tasks:
for host_uuid, host_data in task.host_data.items():
with tracer.start_as_current_span(task.name, start_time=task.start, end_on_exit=False) as span:
self.update_span_data(task, host_data, span)
self.update_span_data(task, host_data, span, disable_logs, disable_attributes_in_logs)
def update_span_data(self, task_data, host_data, span):
def update_span_data(self, task_data, host_data, span, disable_logs, disable_attributes_in_logs):
""" update the span with the given TaskData and HostData """
name = '[%s] %s: %s' % (host_data.name, task_data.play, task_data.name)
@@ -258,8 +311,9 @@ class OpenTelemetrySource(object):
else:
res = host_data.result._result
rc = res.get('rc', 0)
message = self.get_error_message(res)
enriched_error_message = self.enrich_error_message(res)
if host_data.status == 'failed':
message = self.get_error_message(res)
enriched_error_message = self.enrich_error_message(res)
if host_data.status == 'failed':
status = Status(status_code=StatusCode.ERROR, description=message)
@@ -272,36 +326,47 @@ class OpenTelemetrySource(object):
status = Status(status_code=StatusCode.UNSET)
span.set_status(status)
# Create the span and log attributes
attributes = {
"ansible.task.module": task_data.action,
"ansible.task.message": message,
"ansible.task.name": name,
"ansible.task.result": rc,
"ansible.task.host.name": host_data.name,
"ansible.task.host.status": host_data.status
}
if isinstance(task_data.args, dict) and "gather_facts" not in task_data.action:
names = tuple(self.transform_ansible_unicode_to_str(k) for k in task_data.args.keys())
values = tuple(self.transform_ansible_unicode_to_str(k) for k in task_data.args.values())
self.set_span_attribute(span, ("ansible.task.args.name"), names)
self.set_span_attribute(span, ("ansible.task.args.value"), values)
self.set_span_attribute(span, "ansible.task.module", task_data.action)
self.set_span_attribute(span, "ansible.task.message", message)
self.set_span_attribute(span, "ansible.task.name", name)
self.set_span_attribute(span, "ansible.task.result", rc)
self.set_span_attribute(span, "ansible.task.host.name", host_data.name)
self.set_span_attribute(span, "ansible.task.host.status", host_data.status)
attributes[("ansible.task.args.name")] = names
attributes[("ansible.task.args.value")] = values
self.set_span_attributes(span, attributes)
# This will allow to enrich the service map
self.add_attributes_for_service_map_if_possible(span, task_data)
span.end(end_time=host_data.finish)
# Send logs
if not disable_logs:
# This will avoid populating span attributes to the logs
span.add_event(task_data.dump, attributes={} if disable_attributes_in_logs else attributes)
span.end(end_time=host_data.finish)
def set_span_attribute(self, span, attributeName, attributeValue):
""" update the span attribute with the given attribute and value if not None """
def set_span_attributes(self, span, attributes):
""" update the span attributes with the given attributes if not None """
if span is None and self._display is not None:
self._display.warning('span object is None. Please double check if that is expected.')
else:
if attributeValue is not None:
span.set_attribute(attributeName, attributeValue)
if attributes is not None:
span.set_attributes(attributes)
def add_attributes_for_service_map_if_possible(self, span, task_data):
"""Update the span attributes with the service that the task interacted with, if possible."""
redacted_url = self.parse_and_redact_url_if_possible(task_data.args)
if redacted_url:
self.set_span_attribute(span, "http.url", redacted_url.geturl())
span.set_attribute("http.url", redacted_url.geturl())
@staticmethod
def parse_and_redact_url_if_possible(args):
@@ -388,6 +453,8 @@ class CallbackModule(CallbackBase):
def __init__(self, display=None):
super(CallbackModule, self).__init__(display=display)
self.hide_task_arguments = None
self.disable_attributes_in_logs = None
self.disable_logs = None
self.otel_service_name = None
self.ansible_playbook = None
self.play_name = None
@@ -418,6 +485,10 @@ class CallbackModule(CallbackBase):
self.hide_task_arguments = self.get_option('hide_task_arguments')
self.disable_attributes_in_logs = self.get_option('disable_attributes_in_logs')
self.disable_logs = self.get_option('disable_logs')
self.otel_service_name = self.get_option('otel_service_name')
if not self.otel_service_name:
@@ -474,28 +545,32 @@ class CallbackModule(CallbackBase):
self.opentelemetry.finish_task(
self.tasks_data,
status,
result
result,
self._dump_results(result._result)
)
def v2_runner_on_ok(self, result):
self.opentelemetry.finish_task(
self.tasks_data,
'ok',
result
result,
self._dump_results(result._result)
)
def v2_runner_on_skipped(self, result):
self.opentelemetry.finish_task(
self.tasks_data,
'skipped',
result
result,
self._dump_results(result._result)
)
def v2_playbook_on_include(self, included_file):
self.opentelemetry.finish_task(
self.tasks_data,
'included',
included_file
included_file,
""
)
def v2_playbook_on_stats(self, stats):
@@ -508,7 +583,9 @@ class CallbackModule(CallbackBase):
self.ansible_playbook,
self.tasks_data,
status,
self.traceparent
self.traceparent,
self.disable_logs,
self.disable_attributes_in_logs
)
def v2_runner_on_async_failed(self, result, **kwargs):

View File

@@ -1,118 +0,0 @@
# -*- coding: utf-8 -*-
# (c) 2012, Michael DeHaan, <michael.dehaan@gmail.com>
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = '''
author: Unknown (!UNKNOWN)
name: say
type: notification
requirements:
- whitelisting in configuration
- the '/usr/bin/say' command line program (standard on macOS) or 'espeak' command line program
short_description: notify using software speech synthesizer
description:
- This plugin will use the 'say' or 'espeak' program to "speak" about play events.
notes:
- In 2.8, this callback has been renamed from C(osx_say) into M(community.general.say).
'''
import platform
import subprocess
import os
from ansible.module_utils.common.process import get_bin_path
from ansible.plugins.callback import CallbackBase
class CallbackModule(CallbackBase):
"""
makes Ansible much more exciting.
"""
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'notification'
CALLBACK_NAME = 'community.general.say'
CALLBACK_NEEDS_WHITELIST = True
def __init__(self):
super(CallbackModule, self).__init__()
self.FAILED_VOICE = None
self.REGULAR_VOICE = None
self.HAPPY_VOICE = None
self.LASER_VOICE = None
try:
self.synthesizer = get_bin_path('say')
if platform.system() != 'Darwin':
# 'say' binary available, it might be GNUstep tool which doesn't support 'voice' parameter
self._display.warning("'say' executable found but system is '%s': ignoring voice parameter" % platform.system())
else:
self.FAILED_VOICE = 'Zarvox'
self.REGULAR_VOICE = 'Trinoids'
self.HAPPY_VOICE = 'Cellos'
self.LASER_VOICE = 'Princess'
except ValueError:
try:
self.synthesizer = get_bin_path('espeak')
self.FAILED_VOICE = 'klatt'
self.HAPPY_VOICE = 'f5'
self.LASER_VOICE = 'whisper'
except ValueError:
self.synthesizer = None
# plugin disable itself if say is not present
# ansible will not call any callback if disabled is set to True
if not self.synthesizer:
self.disabled = True
self._display.warning("Unable to find either 'say' or 'espeak' executable, plugin %s disabled" % os.path.basename(__file__))
def say(self, msg, voice):
cmd = [self.synthesizer, msg]
if voice:
cmd.extend(('-v', voice))
subprocess.call(cmd)
def runner_on_failed(self, host, res, ignore_errors=False):
self.say("Failure on host %s" % host, self.FAILED_VOICE)
def runner_on_ok(self, host, res):
self.say("pew", self.LASER_VOICE)
def runner_on_skipped(self, host, item=None):
self.say("pew", self.LASER_VOICE)
def runner_on_unreachable(self, host, res):
self.say("Failure on host %s" % host, self.FAILED_VOICE)
def runner_on_async_ok(self, host, res, jid):
self.say("pew", self.LASER_VOICE)
def runner_on_async_failed(self, host, res, jid):
self.say("Failure on host %s" % host, self.FAILED_VOICE)
def playbook_on_start(self):
self.say("Running Playbook", self.REGULAR_VOICE)
def playbook_on_notify(self, host, handler):
self.say("pew", self.LASER_VOICE)
def playbook_on_task_start(self, name, is_conditional):
if not is_conditional:
self.say("Starting task: %s" % name, self.REGULAR_VOICE)
else:
self.say("Notifying task: %s" % name, self.REGULAR_VOICE)
def playbook_on_setup(self):
self.say("Gathering facts", self.REGULAR_VOICE)
def playbook_on_play_start(self, name):
self.say("Starting play: %s" % name, self.HAPPY_VOICE)
def playbook_on_stats(self, stats):
self.say("Play complete", self.HAPPY_VOICE)

View File

@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# (c) 2012, Michael DeHaan, <michael.dehaan@gmail.com>
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2012, Michael DeHaan, <michael.dehaan@gmail.com>
# Copyright (c) 2017 Ansible Project
# 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
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
@@ -13,12 +14,10 @@ DOCUMENTATION = '''
type: notification
requirements:
- whitelisting in configuration
- the '/usr/bin/say' command line program (standard on macOS) or 'espeak' command line program
- the C(/usr/bin/say) command line program (standard on macOS) or C(espeak) command line program
short_description: notify using software speech synthesizer
description:
- This plugin will use the 'say' or 'espeak' program to "speak" about play events.
notes:
- In 2.8, this callback has been renamed from C(osx_say) into M(community.general.say).
- This plugin will use the C(say) or C(espeak) program to "speak" about play events.
'''
import platform

View File

@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# (c) Fastly, inc 2016
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) Fastly, inc 2016
# Copyright (c) 2017 Ansible Project
# 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
@@ -14,14 +15,14 @@ DOCUMENTATION = '''
- set as main display callback
short_description: only print certain tasks
description:
- This callback only prints tasks that have been tagged with `print_action` or that have failed.
- This callback only prints tasks that have been tagged with C(print_action) or that have failed.
This allows operators to focus on the tasks that provide value only.
- Tasks that are not printed are placed with a '.'.
- Tasks that are not printed are placed with a C(.).
- If you increase verbosity all tasks are printed.
options:
nocolor:
default: False
description: This setting allows suppressing colorizing output
default: false
description: This setting allows suppressing colorizing output.
env:
- name: ANSIBLE_NOCOLOR
- name: ANSIBLE_SELECTIVE_DONT_COLORIZE
@@ -43,26 +44,17 @@ from ansible import constants as C
from ansible.plugins.callback import CallbackBase
from ansible.module_utils.common.text.converters import to_text
try:
codeCodes = C.COLOR_CODES
except AttributeError:
# This constant was moved to ansible.constants in
# https://github.com/ansible/ansible/commit/1202dd000f10b0e8959019484f1c3b3f9628fc67
# (will be included in ansible-core 2.11.0). For older Ansible/ansible-base versions,
# we include from the original location.
from ansible.utils.color import codeCodes
DONT_COLORIZE = False
COLORS = {
'normal': '\033[0m',
'ok': '\033[{0}m'.format(codeCodes[C.COLOR_OK]),
'ok': '\033[{0}m'.format(C.COLOR_CODES[C.COLOR_OK]),
'bold': '\033[1m',
'not_so_bold': '\033[1m\033[34m',
'changed': '\033[{0}m'.format(codeCodes[C.COLOR_CHANGED]),
'failed': '\033[{0}m'.format(codeCodes[C.COLOR_ERROR]),
'changed': '\033[{0}m'.format(C.COLOR_CODES[C.COLOR_CHANGED]),
'failed': '\033[{0}m'.format(C.COLOR_CODES[C.COLOR_ERROR]),
'endc': '\033[0m',
'skipped': '\033[{0}m'.format(codeCodes[C.COLOR_SKIP]),
'skipped': '\033[{0}m'.format(C.COLOR_CODES[C.COLOR_SKIP]),
}
@@ -114,8 +106,8 @@ class CallbackModule(CallbackBase):
line_length = 120
if self.last_skipped:
print()
msg = colorize("# {0} {1}".format(task_name,
'*' * (line_length - len(task_name))), 'bold')
line = "# {0} ".format(task_name)
msg = colorize("{0}{1}".format(line, '*' * (line_length - len(line))), 'bold')
print(msg)
def _indent_text(self, text, indent_level):

View File

@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# (C) 2014-2015, Matt Martz <matt@sivel.net>
# (C) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2014-2015, Matt Martz <matt@sivel.net>
# Copyright (c) 2017 Ansible Project
# 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
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
@@ -17,11 +18,10 @@ DOCUMENTATION = '''
short_description: Sends play events to a Slack channel
description:
- This is an ansible callback plugin that sends status updates to a Slack channel during playbook execution.
- Before 2.4 only environment variables were available for configuring this plugin
options:
webhook_url:
required: True
description: Slack Webhook URL
required: true
description: Slack Webhook URL.
env:
- name: SLACK_WEBHOOK_URL
ini:
@@ -44,13 +44,13 @@ DOCUMENTATION = '''
- section: callback_slack
key: username
validate_certs:
description: validate the SSL certificate of the Slack server. (For HTTPS URLs)
description: Validate the SSL certificate of the Slack server for HTTPS URLs.
env:
- name: SLACK_VALIDATE_CERTS
ini:
- section: callback_slack
key: validate_certs
default: True
default: true
type: bool
'''

View File

@@ -1,45 +1,34 @@
# -*- coding: utf-8 -*-
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Copyright (c) Ansible Project
# 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
DOCUMENTATION = '''
name: splunk
type: aggregate
type: notification
short_description: Sends task result events to Splunk HTTP Event Collector
author: "Stuart Hirst (!UNKNOWN) <support@convergingdata.com>"
description:
- This callback plugin will send task results as JSON formatted events to a Splunk HTTP collector.
- The companion Splunk Monitoring & Diagnostics App is available here "https://splunkbase.splunk.com/app/4023/"
- The companion Splunk Monitoring & Diagnostics App is available here U(https://splunkbase.splunk.com/app/4023/).
- Credit to "Ryan Currah (@ryancurrah)" for original source upon which this is based.
requirements:
- Whitelisting this callback plugin
- 'Create a HTTP Event Collector in Splunk'
- 'Define the url and token in ansible.cfg'
- 'Define the URL and token in C(ansible.cfg)'
options:
url:
description: URL to the Splunk HTTP collector source
description: URL to the Splunk HTTP collector source.
env:
- name: SPLUNK_URL
ini:
- section: callback_splunk
key: url
authtoken:
description: Token to authenticate the connection to the Splunk HTTP collector
description: Token to authenticate the connection to the Splunk HTTP collector.
env:
- name: SPLUNK_AUTHTOKEN
ini:
@@ -47,8 +36,8 @@ DOCUMENTATION = '''
key: authtoken
validate_certs:
description: Whether to validate certificates for connections to HEC. It is not recommended to set to
C(false) except when you are sure that nobody can intercept the connection
between this plugin and HEC, as setting it to C(false) allows man-in-the-middle attacks!
V(false) except when you are sure that nobody can intercept the connection
between this plugin and HEC, as setting it to V(false) allows man-in-the-middle attacks!
env:
- name: SPLUNK_VALIDATE_CERTS
ini:
@@ -59,7 +48,7 @@ DOCUMENTATION = '''
version_added: '1.0.0'
include_milliseconds:
description: Whether to include milliseconds as part of the generated timestamp field in the event
sent to the Splunk HTTP collector
sent to the Splunk HTTP collector.
env:
- name: SPLUNK_INCLUDE_MILLISECONDS
ini:
@@ -176,7 +165,7 @@ class SplunkHTTPCollectorSource(object):
class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'aggregate'
CALLBACK_TYPE = 'notification'
CALLBACK_NAME = 'community.general.splunk'
CALLBACK_NEEDS_WHITELIST = True

View File

@@ -1,36 +1,25 @@
# -*- coding: utf-8 -*-
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Copyright (c) Ansible Project
# 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
DOCUMENTATION = '''
DOCUMENTATION = r'''
name: sumologic
type: aggregate
type: notification
short_description: Sends task result events to Sumologic
author: "Ryan Currah (@ryancurrah)"
description:
- This callback plugin will send task results as JSON formatted events to a Sumologic HTTP collector source
- This callback plugin will send task results as JSON formatted events to a Sumologic HTTP collector source.
requirements:
- Whitelisting this callback plugin
- 'Create a HTTP collector source in Sumologic and specify a custom timestamp format of C(yyyy-MM-dd HH:mm:ss ZZZZ) and a custom timestamp locator
of C("timestamp": "(.*)")'
- 'Create a HTTP collector source in Sumologic and specify a custom timestamp format of V(yyyy-MM-dd HH:mm:ss ZZZZ) and a custom timestamp locator
of V("timestamp": "(.*\)")'
options:
url:
description: URL to the Sumologic HTTP collector source
description: URL to the Sumologic HTTP collector source.
env:
- name: SUMOLOGIC_URL
ini:
@@ -39,7 +28,7 @@ options:
'''
EXAMPLES = '''
examples: >
examples: |
To enable, add this to your ansible.cfg file in the defaults block
[defaults]
callback_whitelist = community.general.sumologic
@@ -122,7 +111,7 @@ class SumologicHTTPCollectorSource(object):
class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'aggregate'
CALLBACK_TYPE = 'notification'
CALLBACK_NAME = 'community.general.sumologic'
CALLBACK_NEEDS_WHITELIST = True

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2017 Ansible Project
# 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
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
@@ -14,11 +15,10 @@ DOCUMENTATION = '''
- whitelist in configuration
short_description: sends JSON events to syslog
description:
- This plugin logs ansible-playbook and ansible runs to a syslog server in JSON format
- Before 2.9 only environment variables were available for configuration
- This plugin logs ansible-playbook and ansible runs to a syslog server in JSON format.
options:
server:
description: syslog server that will receive the event
description: Syslog server that will receive the event.
env:
- name: SYSLOG_SERVER
default: localhost
@@ -26,7 +26,7 @@ DOCUMENTATION = '''
- section: callback_syslog_json
key: syslog_server
port:
description: port on which the syslog server is listening
description: Port on which the syslog server is listening.
env:
- name: SYSLOG_PORT
default: 514
@@ -34,7 +34,7 @@ DOCUMENTATION = '''
- section: callback_syslog_json
key: syslog_port
facility:
description: syslog facility to log as
description: Syslog facility to log as.
env:
- name: SYSLOG_FACILITY
default: user
@@ -53,9 +53,6 @@ DOCUMENTATION = '''
version_added: 4.5.0
'''
import os
import json
import logging
import logging.handlers
@@ -70,7 +67,7 @@ class CallbackModule(CallbackBase):
"""
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'aggregate'
CALLBACK_TYPE = 'notification'
CALLBACK_NAME = 'community.general.syslog_json'
CALLBACK_NEEDS_WHITELIST = True

View File

@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright: (c) 2017, Allyson Bowles <@akatch>
# Copyright: (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2023, Al Bowles <@akatch>
# Copyright (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.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
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
@@ -10,7 +11,7 @@ __metaclass__ = type
DOCUMENTATION = '''
name: unixy
type: stdout
author: Allyson Bowles (@akatch)
author: Al Bowles (@akatch)
short_description: condensed Ansible output
description:
- Consolidated Ansible output in the style of LINUX/UNIX startup logs.
@@ -39,7 +40,6 @@ class CallbackModule(CallbackModule_default):
- Only display task names if the task runs on at least one host
- Add option to display all hostnames on a single line in the appropriate result color (failures may have a separate line)
- Consolidate stats display
- Display whether run is in --check mode
- Don't show play name if no hosts found
'''
@@ -62,7 +62,7 @@ class CallbackModule(CallbackModule_default):
def _preprocess_result(self, result):
self.delegated_vars = result._result.get('_ansible_delegated_vars', None)
self._handle_exception(result._result, use_stderr=self.display_failed_stderr)
self._handle_exception(result._result, use_stderr=self.get_option('display_failed_stderr'))
self._handle_warnings(result._result)
def _process_result_output(self, result, msg):
@@ -91,24 +91,36 @@ class CallbackModule(CallbackModule_default):
def v2_playbook_on_task_start(self, task, is_conditional):
self._get_task_display_name(task)
if self.task_display_name is not None:
self._display.display("%s..." % self.task_display_name)
if task.check_mode and self.get_option('check_mode_markers'):
self._display.display("%s (check mode)..." % self.task_display_name)
else:
self._display.display("%s..." % self.task_display_name)
def v2_playbook_on_handler_task_start(self, task):
self._get_task_display_name(task)
if self.task_display_name is not None:
self._display.display("%s (via handler)... " % self.task_display_name)
if task.check_mode and self.get_option('check_mode_markers'):
self._display.display("%s (via handler in check mode)... " % self.task_display_name)
else:
self._display.display("%s (via handler)... " % self.task_display_name)
def v2_playbook_on_play_start(self, play):
name = play.get_name().strip()
if name and play.hosts:
msg = u"\n- %s on hosts: %s -" % (name, ",".join(play.hosts))
if play.check_mode and self.get_option('check_mode_markers'):
if name and play.hosts:
msg = u"\n- %s (in check mode) on hosts: %s -" % (name, ",".join(play.hosts))
else:
msg = u"- check mode -"
else:
msg = u"---"
if name and play.hosts:
msg = u"\n- %s on hosts: %s -" % (name, ",".join(play.hosts))
else:
msg = u"---"
self._display.display(msg)
def v2_runner_on_skipped(self, result, ignore_errors=False):
if self.display_skipped_hosts:
if self.get_option('display_skipped_hosts'):
self._preprocess_result(result)
display_color = C.COLOR_SKIP
msg = "skipped"
@@ -127,7 +139,7 @@ class CallbackModule(CallbackModule_default):
msg += " | item: %s" % (item_value,)
task_result = self._process_result_output(result, msg)
self._display.display(" " + task_result, display_color, stderr=self.display_failed_stderr)
self._display.display(" " + task_result, display_color, stderr=self.get_option('display_failed_stderr'))
def v2_runner_on_ok(self, result, msg="ok", display_color=C.COLOR_OK):
self._preprocess_result(result)
@@ -141,7 +153,7 @@ class CallbackModule(CallbackModule_default):
display_color = C.COLOR_CHANGED
task_result = self._process_result_output(result, msg)
self._display.display(" " + task_result, display_color)
elif self.display_ok_hosts:
elif self.get_option('display_ok_hosts'):
task_result = self._process_result_output(result, msg)
self._display.display(" " + task_result, display_color)
@@ -161,7 +173,7 @@ class CallbackModule(CallbackModule_default):
display_color = C.COLOR_UNREACHABLE
task_result = self._process_result_output(result, msg)
self._display.display(" " + task_result, display_color, stderr=self.display_failed_stderr)
self._display.display(" " + task_result, display_color, stderr=self.get_option('display_failed_stderr'))
def v2_on_file_diff(self, result):
if result._task.loop and 'results' in result._result:
@@ -204,7 +216,7 @@ class CallbackModule(CallbackModule_default):
colorize(u'ignored', t['ignored'], None)),
log_only=True
)
if stats.custom and self.show_custom_stats:
if stats.custom and self.get_option('show_custom_stats'):
self._display.banner("CUSTOM STATS: ")
# per host
# TODO: come up with 'pretty format'
@@ -226,8 +238,10 @@ class CallbackModule(CallbackModule_default):
self._display.display(" Ran out of hosts!", color=C.COLOR_ERROR)
def v2_playbook_on_start(self, playbook):
# TODO display whether this run is happening in check mode
self._display.display("Executing playbook %s" % basename(playbook._file_name))
if context.CLIARGS['check'] and self.get_option('check_mode_markers'):
self._display.display("Executing playbook %s in check mode" % basename(playbook._file_name))
else:
self._display.display("Executing playbook %s" % basename(playbook._file_name))
# show CLI arguments
if self._display.verbosity > 3:

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright (c) 2017 Ansible Project
# 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
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
@@ -10,7 +11,7 @@ DOCUMENTATION = '''
author: Unknown (!UNKNOWN)
name: yaml
type: stdout
short_description: yaml-ized Ansible screen output
short_description: YAML-ized Ansible screen output
description:
- Ansible output that can be quite a bit easier to read than the
default JSON formatting.
@@ -24,12 +25,10 @@ import yaml
import json
import re
import string
import sys
from ansible.module_utils.common.text.converters import to_bytes, to_text
from ansible.module_utils.six import string_types
from ansible.module_utils.common.text.converters import to_text
from ansible.parsing.yaml.dumper import AnsibleDumper
from ansible.plugins.callback import CallbackBase, strip_internal_keys, module_response_deepcopy
from ansible.plugins.callback import strip_internal_keys, module_response_deepcopy
from ansible.plugins.callback.default import CallbackModule as Default