ansible / ansible.builtin / v2.5.6 / module / github_deploy_key Manages deploy keys for GitHub repositories. | "added in version" 2.4 of ansible.builtin" Authors: Ali (@bincyber) preview | supported by communityansible.builtin.github_deploy_key (v2.5.6) — module
pip
Install with pip install ansible==2.5.6
Adds or removes deploy keys for GitHub repositories. Supports authentication using username and password, username and password and 2-factor authentication code (OTP), OAuth2 token, or personal access token.
# add a new read-only deploy key to a GitHub repository using basic authentication - github_deploy_key: owner: "johndoe" repo: "example" name: "new-deploy-key" key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAwXxn7kIMNWzcDfou..." read_only: yes username: "johndoe" password: "supersecretpassword"
# remove an existing deploy key from a GitHub repository - github_deploy_key: owner: "johndoe" repository: "example" name: "new-deploy-key" key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAwXxn7kIMNWzcDfou..." force: yes username: "johndoe" password: "supersecretpassword" state: absent
# add a new deploy key to a GitHub repository, replace an existing key, use an OAuth2 token to authenticate - github_deploy_key: owner: "johndoe" repository: "example" name: "new-deploy-key" key: "{{ lookup('file', '~/.ssh/github.pub') }}" force: yes token: "ABAQDAwXxn7kIMNWzcDfo..."
# re-add a deploy key to a GitHub repository but with a different name - github_deploy_key: owner: "johndoe" repository: "example" name: "replace-deploy-key" key: "{{ lookup('file', '~/.ssh/github.pub') }}" username: "johndoe" password: "supersecretpassword"
# add a new deploy key to a GitHub repository using 2FA - github_deploy_key: owner: "johndoe" repo: "example" name: "new-deploy-key-2" key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAwXxn7kIMNWzcDfou..." username: "johndoe" password: "supersecretpassword" otp: 123456
key: default: null description: - The SSH public key to add to the repository as a deploy key. required: true otp: aliases: - 2fa_token default: null description: - The 6 digit One Time Password for 2-Factor Authentication. Required together with I(username) and I(password). required: false name: aliases: - title - label default: null description: - The name for the deploy key. required: true repo: aliases: - repository default: null description: - The name of the GitHub repository. required: true force: default: false description: - If C(true), forcefully adds the deploy key by deleting any existing deploy key with the same public key or title. required: false type: bool owner: aliases: - account - organization default: null description: - The name of the individual account or organization that owns the GitHub repository. required: true state: choices: - present - absent default: present description: - The state of the deploy key. required: false token: default: null description: - The OAuth2 token or personal access token to authenticate with. Mutually exclusive with I(password). required: false password: default: null description: - The password to authenticate with. A personal access token can be used here in place of a password. required: false username: default: null description: - The username to authenticate with. required: false read_only: default: true description: - If C(true), the deploy key will only be able to read repository contents. Otherwise, the deploy key will be able to read and write. required: false type: bool
error: description: the error message returned by the GitHub API returned: failed sample: key is already in use type: string http_status_code: description: the HTTP status code returned by the GitHub API returned: failed sample: 400 type: int id: description: the key identifier assigned by GitHub for the deploy key returned: changed sample: 24381901 type: int msg: description: the status message describing what occurred returned: always sample: Deploy key added successfully type: string