Inchdev.github_deploy_key
Role Name
=========
This role lets you add or remove an SSH key from your GitHub repository using the GitHub API: GitHub API Documentation
Requirements
None
Role Variables
Here are the variables you can use with this role and a brief description:
github_deploy_key_readonly: true # Set to true if the deploy key should be read-only
github_api_url: https://api.github.com/repos/{{github_repository}}/keys # This URL should not be changed; it's necessary for the GitHub API calls
deploy_key_operation: present # Use 'present' to add a key, or 'absent' to remove a key
github_deploy_key_name: ansible-generated # The name of your key
github_deploy_key: ssh-rsa foobar # The content of your SSH key (this is required)
# You can authenticate with your username and password (if two-factor authentication is not enabled):
github_username: myUsername
github_password: myPassword
# Alternatively, use a personal access token, which you can create here: https://github.com/settings/tokens
github_access_token: myAccessTokenThatIsSuperLongAndUsuallyInTheVault
Dependencies
None
Example Playbook
Here's how to use this role in an Ansible playbook:
- hosts: servers
roles:
- role: github_deploy_key
vars:
github_repository: owner/repo_name
github_access_token: myAccessTokenThatIsSuperLongAndUsuallyInTheVault
github_deploy_key: ssh-rsa tototata
github_deploy_key_readonly: false
- hosts: servers
roles:
- role: github_deploy_key
vars:
github_repository: owner/repo_name
github_username: myUsername
github_password: myPassword
github_deploy_key: ssh-rsa tototata
- hosts: servers
roles:
- role: github_deploy_key
vars:
deploy_key_operation: absent
github_repository: owner/repo_name
github_deploy_key_id: 4242
github_access_token: myAccessTokenThatIsSuperLongAndUsuallyInTheVault
License
BSD