对 Azure 存储库 Ansible 克隆的交互式密码支持 [英] Interactive password support for Ansible clone of Azure Repository

查看:28
本文介绍了对 Azure 存储库 Ansible 克隆的交互式密码支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要使用什么特定语法才能让 Ansible 从 Azure 存储库克隆 git 存储库?

存储库 URL 是 https://OrganizationName@dev.azure.com/OrganizationName/ProjectName/_git/RepositoryName,我们可以通过提供请求的密码在交互式 shell 中手动克隆它我们拥有如下:

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':

但是,我们从官方 Ansible 文档中获得的 Ansible 示例任务并未提及任何密码,如下所示:

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

推荐答案

您的密码必须在您的 repo 链接中,如下所示

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

这篇关于对 Azure 存储库 Ansible 克隆的交互式密码支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆