
    Vh8                    f    d dl mZ dZd dlZdZ	 d dlZd dlmZ  G d de      Z	y# e$ r dZY w xY w)	    )annotationsa  
author: Unknown (!UNKNOWN)
name: jabber
type: notification
short_description: post task events to a Jabber server
description:
  - 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 library U(https://github.com/ArchipelProject/xmpppy))
options:
  server:
    description: Connection info to Jabber server.
    type: str
    required: true
    env:
      - name: JABBER_SERV
  user:
    description: Jabber user to authenticate as.
    type: str
    required: true
    env:
      - name: JABBER_USER
  password:
    description: Password for the user to the Jabber server.
    type: str
    required: true
    env:
      - name: JABBER_PASS
  to:
    description: Chat identifier that will receive the message.
    type: str
    required: true
    env:
      - name: JABBER_TO
NTF)CallbackBasec                  N     e Zd ZdZdZdZdZd fd	Zd Zd Z	d Z
d	 Zd
 Z xZS )CallbackModuleg       @notificationzcommunity.general.jabberTc                    t         t        |   |       t        s"| j                  j                  d       d| _        t        j                  d      | _	        t        j                  d      | _
        t        j                  d      | _        t        j                  d      | _        | j                  xs( | j                  xs | j                  xs | j                  #d| _        | j                  j                  d       y y )	N)displayzuThe required python xmpp library (xmpppy) is not installed. pip install git+https://github.com/ArchipelProject/xmpppyTJABBER_SERVJABBER_USERJABBER_PASS	JABBER_TOzcJabber CallBack wants the JABBER_SERV, JABBER_USER, JABBER_PASS and JABBER_TO environment variables)superr   __init__HAS_XMPP_displaywarningdisabledosgetenvservj_userj_passj_to)selfr	   	__class__s     m/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/callback/jabber.pyr   zCallbackModule.__init__@   s    nd,W,=MM!! #^ _ DMIIm,	ii.ii.IIk*	KK@4;;@$))@tyyI DMMM!!  #H  I J    c                   t        j                  | j                        }t        j                  | j                  g       }|j                  | j                  df       |j                  |j                         | j                  |j                                t        j                  | j                  |      }|j                  dd       |j                  |       |j                          y)zSend message)debugif  )server)resourcetypechatN)xmppJIDr   Clientr   connectauthgetNoder   getResourceMessager   setAttrsend
disconnect)r   msgjidclientmessages        r   send_msgzCallbackModule.send_msgR   s    hht{{#TYYb1tyy$/0CKKM4;;9JK,,tyy#.'Gr   c                    | j                  |j                  |j                  j                         | j	                  |j                        | _        y N)_clean_results_result_taskaction_dump_resultsr   )r   results     r   v2_runner_on_okzCallbackModule.v2_runner_on_ok]   s6    FNNFLL,?,?@''7
r   c                    || _         y r5   )task)r   r>   is_conditionals      r   v2_playbook_on_task_startz(CallbackModule.v2_playbook_on_task_starta   s	    	r   c                R    || _         |j                  }| j                  d|        y)z(Display Playbook and play start messageszAnsible starting play: N)playnamer3   )r   rB   rC   s      r   v2_playbook_on_play_startz(CallbackModule.v2_playbook_on_play_startd   s&    	yy/v67r   c           	     ~   | j                   }t        |j                  j                               }d}d}|D ](  }|j	                  |      }|d   dkD  rd}|d   dkD  s'd}* |s|r3| j
                  }| j                  | d| j                   d d|        y | j
                  }| j                  d	| d
 d|        y )NFfailuresr   Tunreachablez: Failures detected 
z 
Host: z
 Failed at:
zGreat! 
 Playbook z completed:
z 
 Last task debug:
 )rB   sorted	processedkeys	summarizer   r3   r>   )	r   statsrC   hostsrF   rG   hsouts	            r   playbook_on_statsz CallbackModule.playbook_on_statsj   s    yyu++-. 	#A"A}q !#"	# {**CMMTF"89QC_b^cde**CMM/v]1#E\]`\abcr   r5   )__name__
__module____qualname__CALLBACK_VERSIONCALLBACK_TYPECALLBACK_NAMECALLBACK_NEEDS_WHITELISTr   r3   r<   r@   rD   rQ   __classcell__)r   s   @r   r   r   9   s9    "M.M#I$	88dr   r   )

__future__r   DOCUMENTATIONr   r   r$   ImportErroransible.plugins.callbackr   r    r   r   <module>r_      sO    ##J 
 2Bd\ Bd  Hs   & 00