我想使用一个简单的任务克隆git repo http://gitlab.mydomain.com/projects/myproject.git
,我正在尝试使用regex_replace
将http://
替换为http://username:password@
,但以下操作失败任务:
- name: Deploy Web Application
git:
repo: "{{ projectGitURL | regex_replace('http://','http://{{ gitUsername }}:{{ gitPassword }}@') }}"
dest: "/deployment/path"
输出为:
http://{{ gitUsername }}:{{ gitPassword }}@gitlab.mydomain.com/projects/myproject.git
所需的输出是:
http://username:password@gitlab.mydomain.com/projects/myproject.git
请帮忙吗?
编辑:
使用以下方法解决:
repo: "{{ projectGitURL | urlsplit('scheme') }}://{{ gitUsername }}:{{ gitPassword }}@{{ projectGitURL | regex_replace('http://') }}"