我只想在第一次运行 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/