问题
What specific syntax needs to be used to get Ansible to clone a git repository from Azure Repositories?
The repository URL is https://OrganizationName@dev.azure.com/OrganizationName/ProjectName/_git/RepositoryName
and we are able to clone it manually in an interactive shell by providing a requested password which we possess as follows:
$ git clone https://OrganizationName@dev.azure.com/OrganizationName/ProjectName/_git/RepositoryName
Password for 'https://OrganizationName@dev.azure.com':
However, the Ansible example task that we have from the official Ansible documentation does not include any mention of a password, as follows:
- name: Clone a repo
git:
repo: https://OrganizationName@dev.azure.com/OrganizationName/ProjectName/_git/RepositoryName
dest: /src/RepositoryName
回答1:
Your password must be in your repo link as below
---
- name: Clone repo playbook
hosts: dev
vars_prompt:
- name: "git_user"
prompt: "Enter your git username"
private: no
- name: "git_password"
prompt: "Password for 'https://OrganizationName@dev.azure.com'"
private: yes
tasks:
- name: Clone a repo
git:
repo: https://{{ git_user | urlencode }}:{{ git_password | urlencode }}@dev.azure.com/OrganizationName/ProjectName/_git/RepositoryName
dest: /src/RepositoryName
来源:https://stackoverflow.com/questions/64672204/interactive-password-support-for-ansible-clone-of-azure-repository