Browse Source

mirror-workspace-git: use port when pushing git repo through ssh

In the case of using a custom SSH port to connect to the ansible host,
the task of pushing the repository failed, as it assumed the SSH port to
be the default 22.

Now the command is aware of the custom SSH port, as it is specified in
the host facts.

Note that we have to escape the hostname if it is an ipv6 address
(because : is a special character in ipv6 addresses). Thankfully ansible
provides a filter to do that for us:
https://docs.ansible.com/ansible/2.5/user_guide/playbooks_filters_ipaddr.html#wrapping-ipv6-addresses-in-brackets

Change-Id: I76969850fc3a57078370fe38efdebac146720797
Tudor Tabacel 5 months ago
parent
commit
719f214db7
1 changed files with 1 additions and 1 deletions
  1. 1
    1
      roles/mirror-workspace-git-repos/tasks/main.yaml

+ 1
- 1
roles/mirror-workspace-git-repos/tasks/main.yaml View File

@@ -7,7 +7,7 @@
7 7
   with_dict: "{{ zuul.projects }}"
8 8
 
9 9
 - name: Synchronize src repos to workspace directory
10
-  command: "git push --mirror git+ssh://{{ ansible_user }}@{{ ansible_host }}/{{ ansible_user_dir }}/{{ item.value.src_dir}}"
10
+  command: "git push --mirror git+ssh://{{ ansible_user }}@{{ ansible_host | ipwrap }}:{{ ansible_port }}/{{ ansible_user_dir }}/{{ item.value.src_dir}}"
11 11
   args:
12 12
     chdir: "{{ zuul.executor.work_root }}/{{ item.value.src_dir }}"
13 13
   with_dict: "{{ zuul.projects }}"

Loading…
Cancel
Save