Ansible 相当于 git remote set-url origin

use*_*265 6 ansible

我正在尝试使用 Ansible 更新 git 存储库源。我试图模仿的命令是git remote set-url origin new.git.url/here. 有谁知道我怎样才能做到这一点?我试图在不重新克隆存储库的情况下完成此操作。

Vla*_*tka 6

请参阅git_config。例如,给定 Git 存储库test.git

shell> git init --bare  test.git
Run Code Online (Sandbox Code Playgroud)

下面的剧本可以完成这项工作

- hosts: localhost
  tasks:
    - git_config:
        repo: 'test.git'
        scope: 'local'
        name: 'remote.origin.url'
        value: 'new.git.url/here'
Run Code Online (Sandbox Code Playgroud)
shell> cd test.git && git config remote.origin.url
new.git.url/here
Run Code Online (Sandbox Code Playgroud)