�
�Udac @` s d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d
Z d d l
Z
d d l Z d d l m
Z
d d
l m Z d Z d e f d � � YZ d e f d � � YZ d � Z d � Z d � Z d � Z d � Z d � Z e d k re � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bys}
module: github_key
short_description: Manage GitHub access keys.
description:
- Creates, removes, or updates GitHub access keys.
version_added: "2.2"
options:
token:
description:
- GitHub Access Token with permission to list and create public keys.
required: true
name:
description:
- SSH key name
required: true
pubkey:
description:
- SSH public key value. Required when C(state=present).
state:
description:
- Whether to remove a key, ensure that it exists, or update its value.
choices: ['present', 'absent']
default: 'present'
force:
description:
- The default is C(yes), which will replace the existing remote key
if it's different than C(pubkey). If C(no), the key will only be
set if no key with the given C(name) exists.
type: bool
default: 'yes'
author: Robert Estelle (@erydo)
sq
deleted_keys:
description: An array of key objects that were deleted. Only present on state=absent
type: list
returned: When state=absent
sample: [{'id': 0, 'key': 'BASE64 encoded key', 'url': 'http://example.com/github key', 'created_at': 'YYYY-MM-DDTHH:MM:SZ', 'read_only': False}]
matching_keys:
description: An array of keys matching the specified name. Only present on state=present
type: list
returned: When state=present
sample: [{'id': 0, 'key': 'BASE64 encoded key', 'url': 'http://example.com/github key', 'created_at': 'YYYY-MM-DDTHH:MM:SZ', 'read_only': False}]
key:
description: Metadata about the key just created. Only present on state=present
type: dict
returned: success
sample: {'id': 0, 'key': 'BASE64 encoded key', 'url': 'http://example.com/github key', 'created_at': 'YYYY-MM-DDTHH:MM:SZ', 'read_only': False}
s'
- name: Read SSH public key to authorize
shell: cat /home/foo/.ssh/id_rsa.pub
register: ssh_pub_key
- name: Authorize key with GitHub
local_action:
module: github_key
name: Access Key for Some Machine
token: '{{ github_access_token }}'
pubkey: '{{ ssh_pub_key.stdout }}'
N( t
AnsibleModule( t fetch_urls https://api.github.comt GitHubResponsec B` s# e Z d � Z d � Z d � Z RS( c C` s | j � | _ | | _ d S( N( t readt contentt info( t selft responseR
( ( sM /usr/lib/python2.7/site-packages/ansible/modules/source_control/github_key.pyt __init__\ s c C` s t j | j � S( N( t jsont loadsR ( R ( ( sM /usr/lib/python2.7/site-packages/ansible/modules/source_control/github_key.pyR ` s c C` s\ i } d | j k rX | j d } t j d | � } x! | D] \ } } | | | <q; Wn | S( Nt links <([^>]+)>; rel="([^"]+)"( R
t ret findall( R t linkst link_headert matchest urlt rel( ( sM /usr/lib/python2.7/site-packages/ansible/modules/source_control/github_key.pyR c s
( t __name__t
__module__R R R ( ( ( sM /usr/lib/python2.7/site-packages/ansible/modules/source_control/github_key.pyR
[ s t
GitHubSessionc B` s e Z d � Z d d � Z RS( c C` s | | _ | | _ d S( N( t modulet token( R R R ( ( sM /usr/lib/python2.7/site-packages/ansible/modules/source_control/github_key.pyR n s c C` s� i d | j d 6d d 6d d 6} t | j | d | d | d | �\ } } d
| d k og d k n s� | j j d
d | | | d
f � n t | | � S( Ns token %st
Authorizations application/jsons Content-Types application/vnd.github.v3+jsont Acceptt methodt datat headersi� R i� t msgs$ failed to send request %s to %s: %s( R R R t fail_jsonR
( R R"