Ansible剧本,可将文件从git repo复制到远程服务器

问题描述

我正在尝试将一些文件从git存储库复制到远程服务器。由于将经常对这些文件进行更改,因此将这些文件放置在git中,并从git中尝试将其复制到远程服务器。

我正在尝试类似的操作,但是我正在访问的git repo是受保护的,我有信誉。我想知道如何在此处传递用户名和密码。我该如何实现?

    - name: Clone git to a local server
        git:
          repo: https://github.com/blah/blah.git
          dest: /my/laptop/var/tmp/

一旦我在控制器服务器中拥有这些文件,就可以使用复制模块从那里将文件复制到所有远程主机。

解决方法

一种简单(但不安全)的可能性是:

git:
      repo: https://username:password@github.com/blah/blah.git
      dest: /my/laptop/var/tmp/

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...