Anons79 Mini Shell

Directory : /proc/self/root/lib/python2.7/site-packages/ansible/modules/source_control/
Upload File :
Current File : //proc/self/root/lib/python2.7/site-packages/ansible/modules/source_control/gitlab_deploy_key.pyo

�
�Udac@`s@ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlZdZyddlZeZWn#ek
r�ej�ZeZnXddlmZdd
lmZmZddlmZddlmZdefd��YZd�Z d�Z!e"dkr<e!�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
module: gitlab_deploy_key
short_description: Manages GitLab project deploy keys.
description:
     - Adds, updates and removes project deploy keys
version_added: "2.6"
author:
  - Marcus Watkins (@marwatk)
  - Guillaume Martinez (@Lunik)
requirements:
  - python >= 2.7
  - python-gitlab python module <= 1.12.1
extends_documentation_fragment:
    - auth_basic
options:
  api_token:
    description:
      - GitLab token for logging in.
    version_added: "2.8"
    type: str
    aliases:
      - private_token
      - access_token
  project:
    description:
      - Id or Full path of project in the form of group/name
    required: true
    type: str
  title:
    description:
      - Deploy key's title
    required: true
    type: str
  key:
    description:
      - Deploy key
    required: true
    type: str
  can_push:
    description:
      - Whether this key can push to the project
    type: bool
    default: no
  state:
    description:
      - When C(present) the deploy key added to the project if it doesn't exist.
      - When C(absent) it will be removed from the project if it exists
    required: true
    default: present
    type: str
    choices: [ "present", "absent" ]
s�
- name: "Adding a project deploy key"
  gitlab_deploy_key:
    api_url: https://gitlab.example.com/
    api_token: "{{ access_token }}"
    project: "my_group/my_project"
    title: "Jenkins CI"
    state: present
    key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9w..."

- name: "Update the above deploy key to add push access"
  gitlab_deploy_key:
    api_url: https://gitlab.example.com/
    api_token: "{{ access_token }}"
    project: "my_group/my_project"
    title: "Jenkins CI"
    state: present
    can_push: yes

- name: "Remove the previous deploy key from the project"
  gitlab_deploy_key:
    api_url: https://gitlab.example.com/
    api_token: "{{ access_token }}"
    project: "my_group/my_project"
    state: absent
    key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9w..."

s�
msg:
  description: Success or failure message
  returned: always
  type: str
  sample: "Success"

result:
  description: json parsed response from the server
  returned: always
  type: dict

error:
  description: the error message returned by the GitLab API
  returned: failed
  type: str
  sample: "400: key is already in use"

deploy_key:
  description: API object
  returned: always
  type: dict
N(tbasic_auth_argument_spec(t
AnsibleModuletmissing_required_lib(t	to_native(tfindProjecttGitLabDeployKeycB`sGeZd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(cC`s||_||_d|_dS(N(t_modulet_gitlabtNonetdeployKeyObject(tselftmoduletgitlab_instance((sT/usr/lib/python2.7/site-packages/ansible/modules/source_control/gitlab_deploy_key.pyt__init__�s		cC`s�t}|jdkrI|j|i|d6|d6|dd6�}t}n&|j|ji|dd6�\}}||_|r�|jjr�|jjdtdd|�ny|j	�Wn*t
k
r�}|jjdd|�nXtStSdS(Nttitletkeytcan_pushtchangedtmsgs1Successfully created or updated the deploy key %ss Failed to update deploy key: %s (tFalseRRtcreateDeployKeytTruetupdateDeployKeyRt
check_modet	exit_jsontsavet	Exceptiont	fail_json(Rtprojectt	key_titletkey_keytoptionsRt	deployKeyte((sT/usr/lib/python2.7/site-packages/ansible/modules/source_control/gitlab_deploy_key.pytcreateOrUpdateDeployKey�s&		 cC`sc|jjrtSy|jj|�}Wn6tjjk
r^}|jjddt	|��nX|S(NRs Failed to create deploy key: %s (
RRRtkeystcreatetgitlabt
exceptionstGitlabCreateErrorR#R(RR$t	argumentsR(R)((sT/usr/lib/python2.7/site-packages/ansible/modules/source_control/gitlab_deploy_key.pyR�s!cC`svt}xc|j�D]U\}}||dk	rt||�||krht||||�t}qhqqW||fS(N(RtitemsRtgetattrtsetattrR(RR(R0Rtarg_keyt	arg_value((sT/usr/lib/python2.7/site-packages/ansible/modules/source_control/gitlab_deploy_key.pyR�scC`s7|jj�}x!|D]}|j|kr|SqWdS(N(R+tlistR(RR$R%t
deployKeysR(((sT/usr/lib/python2.7/site-packages/ansible/modules/source_control/gitlab_deploy_key.pyt
findDeployKey�s
cC`s)|j||�}|r%||_tStS(N(R8RRR(RR$R%R(((sT/usr/lib/python2.7/site-packages/ansible/modules/source_control/gitlab_deploy_key.pytexistsDeployKey�s
	cC`s|jjrtS|jj�S(N(RRRRtdelete(R((sT/usr/lib/python2.7/site-packages/ansible/modules/source_control/gitlab_deploy_key.pytdeleteDeployKey�s(	t__name__t
__module__RR*RRR8R9R;(((sT/usr/lib/python2.7/site-packages/ansible/modules/source_control/gitlab_deploy_key.pyR
�s					
	cC`sOddg}x<|D]4}||jkr|jdjd|�d�qqWdS(Nt
private_tokentaccess_tokensAlias '{aliase}' is deprecatedtaliases2.10(tparamst	deprecatetformat(Rtdeprecated_aliasesR@((sT/usr/lib/python2.7/site-packages/ansible/modules/source_control/gitlab_deploy_key.pytdeprecation_warning�s
cC`s�t�}|jtdtdddtdddg�dtddd	d
ddd
g�d
tdddt�dtdddt�dtddd	t�dtdddt���td|dddgddggdddggdddggdt�}t|�tjdd|j	d�}|j	d}|j	d}|j	d}|j	d}|j	d}|j	d
}|j	d}	|j	d}
|j	d}t
s�|jdtd�d t
�ny>tjd!|d"|d#|d$|d|d%d&�}|j�Wnqtjjtjjfk
r9}
|jdd't|
��n3tjjk
rk}
|jdd(t|
��nXt||�}t||�}|dkr�|jdd)|�n|j||	�}|dkr|r�|j�|jd*tdd+|	�q|jd*tdd,�n|d
kr�|j||	|
i|d6�re|jd*tdd-|	d.|jj�q�|jd*tdd/|	d.|jj�ndS(0Nt	api_tokenttypetstrtno_logtaliasesR>R?tstatetdefaulttpresenttchoicestabsentR$trequiredRRtboolRt
argument_spectmutually_exclusivetapi_usernametapi_passwordtrequired_togethertrequired_one_oftsupports_check_modes/api.*ttapi_urltvalidate_certsRs
python-gitlabt	exceptionturlt
ssl_verifytemailtpasswordtapi_versionis&Failed to connect to GitLab server: %ss�Failed to connect to GitLab server: %s.             GitLab remove Session API now that private tokens are removed from user API endpoints since version 10.2.s6Failed to create deploy key: project %s doesn't existsRs"Successfully deleted deploy key %ss%Deploy key deleted or does not existss1Successfully created or updated the deploy key %st
deploy_keys#No need to update the deploy key %s(RtupdatetdictRRR	REtretsubRAtHAS_GITLAB_PACKAGER#R
tGITLAB_IMP_ERRR-tGitlabtauthR.tGitlabAuthenticationErrortGitlabGetErrorRtGitlabHttpErrorR
RRR9R;R R*Rt_attrs(RRRt
gitlab_urlR[tgitlab_usertgitlab_passwordtgitlab_tokenRKtproject_identifierR%tkey_keyfiletkey_can_pushRR)tgitlab_deploy_keyR$tdeployKey_exists((sT/usr/lib/python2.7/site-packages/ansible/modules/source_control/gitlab_deploy_key.pytmain�sj	!!		









!!	
t__main__(#t
__future__RRRRGt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNtosRet	tracebackRRhR-RRgR"t
format_excRtansible.module_utils.apiRtansible.module_utils.basicR	R
tansible.module_utils._textRtansible.module_utils.gitlabRtobjectR
RERxR<(((sT/usr/lib/python2.7/site-packages/ansible/modules/source_control/gitlab_deploy_key.pyt<module>
s4


5


c		O

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