Interactive password support for Ansible clone of Azure Repository

房东的猫 提交于 2021-01-29 07:58:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!