ansible.builtin.github_key (v2.9.27) — module

Manage GitHub access keys.

| "added in version" 2.2 of ansible.builtin"

Authors: Robert Estelle (@erydo)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.27

Description

Creates, removes, or updates GitHub access keys.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Read SSH public key to authorize
  shell: cat /home/foo/.ssh/id_rsa.pub
  register: ssh_pub_key
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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 }}'

Inputs

    
name:
    description:
    - SSH key name
    required: true

force:
    default: 'yes'
    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

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Whether to remove a key, ensure that it exists, or update its value.

token:
    description:
    - GitHub Access Token with permission to list and create public keys.
    required: true

pubkey:
    description:
    - SSH public key value. Required when C(state=present).

Outputs

deleted_keys:
  description: An array of key objects that were deleted. Only present on state=absent
  returned: When state=absent
  sample:
  - created_at: YYYY-MM-DDTHH:MM:SZ
    id: 0
    key: BASE64 encoded key
    read_only: false
    url: http://example.com/github key
  type: list
key:
  description: Metadata about the key just created. Only present on state=present
  returned: success
  sample:
    created_at: YYYY-MM-DDTHH:MM:SZ
    id: 0
    key: BASE64 encoded key
    read_only: false
    url: http://example.com/github key
  type: dict
matching_keys:
  description: An array of keys matching the specified name. Only present on state=present
  returned: When state=present
  sample:
  - created_at: YYYY-MM-DDTHH:MM:SZ
    id: 0
    key: BASE64 encoded key
    read_only: false
    url: http://example.com/github key
  type: list