Merge "Add parameter to upload-git-mirror to specify ssh host key"

This commit is contained in:
Zuul 2019-04-02 21:22:24 +00:00 committed by Gerrit Code Review
commit a76af3f4f1
4 changed files with 28 additions and 4 deletions

View File

@ -20,11 +20,16 @@ superuser privileges to run.
SSH host for the remote git repository
.. zuul:rolevar:: key
.. zuul:rolevar:: ssh_key
Literal private key contents.
Should start with something like ``-----BEGIN RSA PRIVATE KEY-----``.
.. zuul:rolevar:: host_key
SSH host key of the remote git server.
Can be obtained with ``ssh-keyscan -H <host>``.
.. zuul:rolevar:: git_mirror_repository
Path of the remote git repository

View File

@ -3,7 +3,8 @@
# git_mirror_credentials:
# user:
# host:
# key:
# ssh_key:
# host_key:
# Repository to replicate to
# git_mirror_repository:

View File

@ -6,7 +6,7 @@
- name: Set up private key
copy:
content: "{{ git_mirror_credentials.key }}"
content: "{{ git_mirror_credentials.ssh_key }}"
dest: "{{ ssh_private_key_tmp.path }}"
mode: 0600
@ -26,6 +26,12 @@
mode: 0600
block: "{{ ssh_config }}"
- name: Add host key to known hosts
known_hosts:
state: present
name: "{{ git_mirror_credentials.host }}"
key: "{{ git_mirror_credentials.host_key }}"
- name: Mirror the git repository
command: git push --mirror {{ git_mirror_credentials.user }}@{{ git_mirror_credentials.host }}:{{ git_mirror_repository }}
args:
@ -45,3 +51,10 @@
mode: 0600
block: "{{ ssh_config }}"
register: git_mirror_ssh_config_removed
- name: Remove host key from known hosts
known_hosts:
state: absent
name: "{{ git_mirror_credentials.host }}"
key: "{{ git_mirror_credentials.host_key }}"
register: git_mirror_host_key_removed

View File

@ -68,11 +68,16 @@
SSH host for the remote git repository
.. zuul:jobvar:: key
.. zuul:jobvar:: ssh_key
Literal private key contents.
Should start with something like ``-----BEGIN RSA PRIVATE KEY-----``.
.. zuul:jobvar:: host_key
SSH host key of the remote git server.
Can be obtained with ``ssh-keyscan -H <host>``.
.. zuul:jobvar:: git_mirror_repository
Path of the remote git repository