Skip to content

A simple role to generate github deploy keys using a github token.

Notifications You must be signed in to change notification settings

hpc-unibe-ch/ansible-role-github-deploy-keys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

github-deploy-keys

This role configures github deploy keys on a ansible host and manages a users ssh-config to use the generated keys for authentication with github.

This role can be useful when automatic access to private or internal repositories needs to be configured. A possible use case is Ansible Semaphore.

Role Variables

gdk_deploy_keys:
  - name: "repo_name"
    key: "/root/.ssh/id_rsa_name"
    deploy_keyname: "deploy-token-name"
    repo: "repo"
    owner: "repo_owner"
    token: "github_securetoken"
    state: "present"

gdk_manage_ssh_config: false
gdk_ssh_config_path: '/root/.ssh/config'

A list of dictionaries controls the repositories that this role should grant access to. If you need multiple repositories, simply copy the -name block and adapt the repository settings.

  • name sets the repository name (currently only used as unique identifier)
  • key is the name of the ssh-key to be installed
  • deploy_keyname is the name of the deploy key as shown on Github
  • repo sets the github repository to access
  • owner sets the github account / organization the key should access
  • token is the github access token used with the API to register the keys
  • state (default is present). Can be set to absent to remove deploy keys

For details of the dict keys please see the the ansible github_deploy_key module documentation.

gdk_user: "root"

Set the user account on the ansible host that should own the key.

gdk_manage_ssh_config: false

boolean to control whether the user ssh-config. Note: This is currently a template. Any other contents of an existing ssh-config will be overwritten.

gdk_ssh_config_path: '/root/.ssh/config'

Set the path of the ssh config file to modify.

Example Playbook

- name: Generate deploy keys and ssh config for semaphore
  hosts: semaphore
  vars:
    gdk_deploy_keys:
      - name: "repo_name"
        key: "/root/.ssh/id_rsa_name"
        deploy_keyname: "deploy-token-name"
        repo: "repo"
        owner: "repo_owner"
        token: "github_securetoken"
        state: "present"
    gdk_user: "root"
    gdk_ssh_config_path: "/var/lib/semaphore/.ssh/config"
    gdk_manage_ssh_config: true
  roles:
    - role: ubelix.github_deploy_keys

License

MIT

About

A simple role to generate github deploy keys using a github token.

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages