Skip to content

Commit

Permalink
Add github_key support
Browse files Browse the repository at this point in the history
  • Loading branch information
henriklynggaard committed Apr 22, 2017
1 parent 83b8380 commit 31fa957
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Role Variables
git_username: ""
git_email: ""

git_github_token: (not defined by default, if you set it your ssh key will be registered in github)
git_github_key_name: (not defined by default)
git_packages:
- git
- gitg
Expand Down Expand Up @@ -45,6 +47,9 @@ __Example inventory__
git_username: John Doe
git_email: [email protected]

git_github_token: 758375934abdc6735345378
git_github_key_name: "My linux machine"

git_alias:
- alias: st
vlaue: status -sb
Expand All @@ -70,4 +75,5 @@ MIT
Change log
----------

* 1.1: Add support for registering keys in github. You must use Ansible 2.3 or backport the github_key module
* 1.0: Initial version
3 changes: 2 additions & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ galaxy_info:

license: MIT

min_ansible_version: 2.1
min_ansible_version: 2.3

platforms:
- name: Ubuntu
versions:
- trusty
- xenial

galaxy_tags:
- git
Expand Down
8 changes: 8 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
scope: global
with_items: "{{ git_alias }}"

- name: Authorize key with GitHub
github_key:
name: '{{ git_github_key_name }}'
token: '{{ git_github_token }}'
force: no
pubkey: "{{ lookup('file', '/home/{{ workstation_bootstrap_username }}/.ssh/id_rsa.pub') }}"
when: git_github_token is defined

- name: Checkout Git repositories
git:
repo: "{{ item.repo }}"
Expand Down

0 comments on commit 31fa957

Please sign in to comment.