I want to download data from git only on first run of playbook.
For example, I have this
- 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
Because of some another commands I would run again the same playbook, but without few commands like git.
I tried with register index.php, but afterwards if there is a difference between local and remote repository, I’m getting “msg”: “Local modifications exist in repository (force=no).”
Just to mention, I’m very new with Ansible.
2
Answers
Concept of run_once is to only run a task one time for a batch of hosts. This is not what you want, I think.
An option would be to use a lock file. For example:
(not tested)
Maybe the “update” option in the git ansible module be worth for you:
Check the doc page.
This is the explanation there:
The default is “yes”.
Also, check the example in the same doc page:
I hope it can help you!