git - 如何仅在第一次运行剧本时运行命令,在下次重新运行时跳过?

标签 git ansible

我只想在第一次运行 playbook 时从 git 下载数据。 比如我有这个

- name: Check if Magento is already installed
  stat: path=/var/www/html/index.php
  register: index_php
- name: Deploy the latest version from OpenMage github, only if it is not already installed
  git:
    repo: 'https://github.com/OpenMage/magento-mirror'
    dest: /var/www/html
    run_once: true 
  when: not index_php.stat.exists

由于一些其他命令,我会再次运行相同的剧本,但没有像 git 这样的命令。

我尝试注册 index.php,但之后如果本地和远程存储库之间存在差异,我会收到“消息”:“存储库中存在本地修改(force=no)。”

顺便提一下,我是 Ansible 的新手。

最佳答案

也许 git ansible 模块中的“更新”选项对你来说是值得的:

检查 doc page .

update: no

这里是解释:

If no, do not retrieve new revisions from the origin repository Operations like archive will work on the existing (old) repository and might not respond to changes to the options version or remote.

默认为"is"。

此外,检查同一文档页面中的示例:

# Example just ensuring the repo checkout exists
- git:
    repo: 'https://foosball.example.org/path/to/repo.git'
    dest: /srv/checkout
    update: no

希望对您有所帮助!

关于git - 如何仅在第一次运行剧本时运行命令,在下次重新运行时跳过?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54524919/

相关文章:

带有子分支的 git rebase master

GIT:致命:内存不足,malloc 失败(试图分配 889192448 字节)

ansible - 在ansible中将ssl证书从服务器复制到主机

linux - Ansible - 如何设置目录权限

ansible - 相对于剧本的文件lookup()

git - 将默认的 Git merge 放入 TFS

git - 如何在具有多个项目的 Xcode Workspace 中配置 GIT 存储库

linux - 如何从 list 文件调用/包含 IP 地址到 ansible playbook

git - git gui 的深色主题

ansible - 如何从 ansible_env 获取 sudoed 用户的主目录?