Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/notification/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/notification/slack.pyo

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zdd
l	Z	ddl
mZddlm
Z
d
ZdZidd6dd6Zd�Zd�Zd�Zd�Zd�Zedkr�e�nd
S(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontstableinterfacetstatust	communitytsupported_bys�
module: slack
short_description: Send Slack notifications
description:
    - The C(slack) module sends notifications to U(http://slack.com) via the Incoming WebHook integration
version_added: "1.6"
author: "Ramon de la Fuente (@ramondelafuente)"
options:
  domain:
    description:
      - Slack (sub)domain for your environment without protocol. (i.e.
        C(example.slack.com)) In 1.8 and beyond, this is deprecated and may
        be ignored.  See token documentation for information.
  token:
    description:
      - Slack integration token.  This authenticates you to the slack service.
        Prior to 1.8, a token looked like C(3Ffe373sfhRE6y42Fg3rvf4GlK).  In
        1.8 and above, ansible adapts to the new slack API where tokens look
        like C(G922VJP24/D921DW937/3Ffe373sfhRE6y42Fg3rvf4GlK).  If tokens
        are in the new format then slack will ignore any value of domain.  If
        the token is in the old format the domain is required.  Ansible has no
        control of when slack will get rid of the old API.  When slack does
        that the old format will stop working.  ** Please keep in mind the tokens
        are not the API tokens but are the webhook tokens.  In slack these are
        found in the webhook URL which are obtained under the apps and integrations.
        The incoming webhooks can be added in that area.  In some cases this may
        be locked by your Slack admin and you must request access.  It is there
        that the incoming webhooks can be added.  The key is on the end of the
        URL given to you in that section.
    required: true
  msg:
    description:
      - Message to send. Note that the module does not handle escaping characters.
        Plain-text angle brackets and ampersands should be converted to HTML entities (e.g. & to &) before sending.
        See Slack's documentation (U(https://api.slack.com/docs/message-formatting)) for more.
  channel:
    description:
      - Channel to send the message to. If absent, the message goes to the channel selected for the I(token).
  thread_id:
    version_added: 2.8
    description:
      - Optional. Timestamp of message to thread this message to as a float. https://api.slack.com/docs/message-threading
  username:
    description:
      - This is the sender of the message.
    default: "Ansible"
  icon_url:
    description:
      - Url for the message sender's icon (default C(https://www.ansible.com/favicon.ico))
  icon_emoji:
    description:
      - Emoji for the message sender. See Slack documentation for options.
        (if I(icon_emoji) is set, I(icon_url) will not be used)
  link_names:
    description:
      - Automatically create links for channels and usernames in I(msg).
    default: 1
    choices:
      - 1
      - 0
  parse:
    description:
      - Setting for the message parser at Slack
    choices:
      - 'full'
      - 'none'
  validate_certs:
    description:
      - If C(no), SSL certificates will not be validated. This should only be used
        on personally controlled sites using self-signed certificates.
    type: bool
    default: 'yes'
  color:
    version_added: "2.0"
    description:
      - Allow text to use default colors - use the default of 'normal' to not send a custom color bar at the start of the message.
      - Allowed values for color can be one of 'normal', 'good', 'warning', 'danger', any valid 3 digit or 6 digit hex color value.
      - Specifying value in hex is supported from version 2.8.
    default: 'normal'
  attachments:
    description:
      - Define a list of attachments. This list mirrors the Slack JSON API.
      - For more information, see also in the (U(https://api.slack.com/docs/attachments)).
s&
- name: Send notification message via Slack
  slack:
    token: thetoken/generatedby/slack
    msg: '{{ inventory_hostname }} completed'
  delegate_to: localhost

- name: Send notification message via Slack all options
  slack:
    token: thetoken/generatedby/slack
    msg: '{{ inventory_hostname }} completed'
    channel: '#ansible'
    thread_id: 1539917263.000100
    username: 'Ansible on {{ inventory_hostname }}'
    icon_url: http://www.example.com/some-image-file.png
    link_names: 0
    parse: 'none'
  delegate_to: localhost

- name: insert a color bar in front of the message for visibility purposes and use the default webhook icon and name configured in Slack
  slack:
    token: thetoken/generatedby/slack
    msg: '{{ inventory_hostname }} is alive!'
    color: good
    username: ''
    icon_url: ''

- name: insert a color bar in front of the message with valid hex color value
  slack:
    token: thetoken/generatedby/slack
    msg: 'This message uses color in hex value'
    color: '#00aacc'
    username: ''
    icon_url: ''

- name: Use the attachments API
  slack:
    token: thetoken/generatedby/slack
    attachments:
      - text: Display my system load on host A and B
        color: '#ff00dd'
        title: System load
        fields:
          - title: System A
            value: "load average: 0,74, 0,66, 0,63"
            short: True
          - title: System B
            value: 'load average: 5,16, 4,64, 2,43'
            short: True

- name: Send a message with a link using Slack markup
  slack:
    token: thetoken/generatedby/slack
    msg: We sent this message using <https://www.ansible.com|Ansible>!

- name: Send a message with angle brackets and ampersands
  slack:
    token: thetoken/generatedby/slack
    msg: This message has &lt;brackets&gt; &amp; ampersands in plain text.
N(t
AnsibleModule(t	fetch_urls3https://%s/services/hooks/incoming-webhook?token=%ss#https://hooks.slack.com/services/%ss"s'cC`stjd|�rtStS(Ns"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$(tretmatchtTruetFalse(tcolor_choice((sF/usr/lib/python2.7/site-packages/ansible/modules/notification/slack.pytis_valid_hex_color�scC`sdjd�|D��S(s!Backslash any quotes within text.tcs`s!|]}tj||�VqdS(N(tescape_tabletget(t.0tc((sF/usr/lib/python2.7/site-packages/ansible/modules/notification/slack.pys	<genexpr>�s(tjoin(ttext((sF/usr/lib/python2.7/site-packages/ansible/modules/notification/slack.pyt
escape_quotes�sc
C`si}|	dkr6|dk	r6tdt|��}n?|dk	rutdtdt|�d|	ddg�g�}n|dk	r�|ddks�|ddkr�||d	<q�d||d	<n|dk	r�||d
<n|dk	r�||d<n|dk	r
||d<n
||d
<|dk	r-||d<n|dk	rF||d<n|
dk	rnd|krng|d<qnn|
dk	rdddddg}xs|
D]h}
x1|D])}||
kr�t|
|�|
|<q�q�Wd|
kr�|
d|
d<n|dj|
�q�Wn|j|�}|S(NtnormalRtattachmentstcolort	mrkdwn_init#t@tchannelt	thread_tstusernamet
icon_emojiticon_urlt
link_namestparsettitletauthor_nametpretexttfallback(tNonetdictRtappendtjsonify(tmoduleRRt	thread_idR R"R!R#R$RRtpayloadtkeys_to_escapet
attachmenttkey((sF/usr/lib/python2.7/site-packages/ansible/modules/notification/slack.pytbuild_payload_for_slack�sL3 






	

c	C`s�|jd�dkr"t|}n)|s;|jdd�nt||f}idd6dd6}td|d	|d
|ddd
|�\}}|ddkr�td}|jdd|||df�ndS(Nt/itmsgskSlack has updated its webhook API.  You need to specify a token of the form XXXX/YYYY/ZZZZ in your playbooksapplication/jsonsContent-TypetAcceptR-turltheaderstmethodtPOSTtdataRi�s
[obscured]s failed to send %s to %s: %s(tcounttSLACK_INCOMING_WEBHOOKt	fail_jsontOLD_SLACK_INCOMING_WEBHOOKR	(	R-tdomainttokenR/tslack_incoming_webhookR8tresponsetinfotobscured_incoming_webhook((sF/usr/lib/python2.7/site-packages/ansible/modules/notification/slack.pytdo_notify_slack�s

-
c#C`s�tdtdtdddtdd�dtdddtdt�d	tdddtdd�d
tdddd�dtdddd�d
tdddd�dtdddd�dtdddd�dtdddddddg�dtdddddddg�dtdddd�dtdddd�dtdd dtdd��
�}|jd}|jd}|jd	}|jd
}|jd}|jd
}|jd}|jd}|jd}	|jd}
|jd}|jd}dd!d"d#g}
||
kr1t|�r1|jd	d$|
�nt||||||||	|
||�}t	||||�|j
d	d%�dS(&Nt
argument_specR@ttypetstrtrequiredtdefaultRAtno_logR5RR.tfloatR tAnsibleR"s#https://www.ansible.com/favicon.icoR!R#tintitchoicesiR$tnonetfulltvalidate_certstyestboolRRRtlisttgoodtwarningtdangers[Color value specified should be either one of %r or any valid hex value with length 3 or 6.tOK(RR*R
R)RtparamsRR>R3RFt	exit_json(R-R@RARRR.R R"R!R#R$RRt
color_choicesR/((sF/usr/lib/python2.7/site-packages/ansible/modules/notification/slack.pytmain
sF!!!











t__main__(t
__future__RRRRHt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLESR
tansible.module_utils.basicRtansible.module_utils.urlsR	R?R=RRRR3RFR^t__name__(((sF/usr/lib/python2.7/site-packages/ansible/modules/notification/slack.pyt<module>s*


V=
			4		,

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]