
    Vhb                     |    d dl mZmZmZ eZdZdZd dlZd dl	m
Z
 d dlmZ d dlmZ d dlmZ d	 Zed
k(  r e        yy)    )absolute_importdivisionprint_functiona  
module: rollbar_deployment
author: "Max Riveiro (@kavu)"
short_description: Notify Rollbar about app deployments
description:
  - Notify Rollbar about app deployments (see U(https://rollbar.com/docs/deploys_other/)).
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  token:
    type: str
    description:
      - Your project access token.
    required: true
  environment:
    type: str
    description:
      - Name of the environment being deployed, for example V(production).
    required: true
  revision:
    type: str
    description:
      - Revision number/sha being deployed.
    required: true
  user:
    type: str
    description:
      - User who deployed.
    required: false
  rollbar_user:
    type: str
    description:
      - Rollbar username of the user who deployed.
    required: false
  comment:
    type: str
    description:
      - Deploy comment (for example what is being deployed).
    required: false
  url:
    type: str
    description:
      - Optional URL to submit the notification to.
    required: false
    default: 'https://api.rollbar.com/api/1/deploy/'
  validate_certs:
    description:
      - If V(false), SSL certificates for the target URL will not be validated. This should only be used on personally controlled
        sites using self-signed certificates.
    required: false
    default: true
    type: bool
a  
- name: Rollbar deployment notification
  community.general.rollbar_deployment:
  token: AAAAAA
  environment: staging
  user: ansible
  revision: '4.2'
  rollbar_user: admin
  comment: Test Deploy

- name: Notify rollbar about current git revision deployment by current user
  community.general.rollbar_deployment:
  token: "{{ rollbar_access_token }}"
  environment: production
  revision: "{{ lookup('pipe', 'git rev-parse HEAD') }}"
  user: "{{ lookup('env', 'USER') }}"
N)AnsibleModule)	urlencode)	to_native)	fetch_urlc                     t        t        t        dd      t        d      t        d      t        d      t        d      t        d      t        dd      t        dd      	      d
      } | j                  r| j                  d       t        | j                  d   | j                  d   | j                  d         }| j                  d   r| j                  d   |d<   | j                  d   r| j                  d   |d<   | j                  d   r| j                  d   |d<   | j                  j                  d      }	 t        |      }t        | ||d      \  }}|d   dk(  r| j                  d       y | j                  d|d   |fz         y # t        $ r;}| j                  dt        |      z  t        j                                Y d }~y d }~ww xY w)NT)requiredno_log)r   Fz%https://api.rollbar.com/api/1/deploy/)r   defaultbool)r   type)tokenenvironmentrevisionuserrollbar_usercommenturlvalidate_certs)argument_specsupports_check_mode)changedr   r   r   )access_tokenr   r   r   local_usernamer   rollbar_usernamer   r   POST)datamethodstatus   z%HTTP result code: %d connecting to %s)msgzUnable to notify Rollbar: %s)r#   	exception)r   dict
check_mode	exit_jsonparamsgetr   r	   	fail_json	Exceptionr   	traceback
format_exc)moduler(   r   r   responseinfoes          x/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/rollbar_deployment.pymainr3   `   s   T2d+4(u%u-%(?  6:
 !F" &]]7+MM-0z*F }}V#)==#8 }}^$%+]]>%B!"}}Y"MM)4y
--

E
"C	b "63T&I$ >S T*!HDQYN\_K`!`a  n;ilJV_VjVjVlmmns   F 	G 1GG__main__)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESr,   ansible.module_utils.basicr   +ansible.module_utils.six.moves.urllib.parser   +ansible.module_utils.common.text.convertersr   ansible.module_utils.urlsr	   r3   __name__     r2   <module>r@      sN    A @9v"  4 A A /0bf zF r?   