I keep running into this a lot but I am not sure how to handle it. Lets
assume I have the following yaml:
project_paths:
- path: /srv/www/web/app1
name: app1
- path: /srv/www/web/app2
name: app2
Then I want to check if a file exists before running the following action:
- name: application | check for installer
stat: path={{ item.path }}/install.php
register: check_install
with_items: project_paths
- name: application | run install
command: php install.php chdir={{ item.path }}
with_items: project_paths
when: check_install.stat.exists == false
The issue is registering check_install since we are doing it in a loop. It
looks to be resetting the variable for every item. I tried something like
this and I get 'check_install' is undefined.
- name: application | check for installer
stat: path={{ item.path }}/install.php
register: check_install[item.name]
with_items: project_paths
- name: application | run install
command: php install.php chdir={{ item.path }}
with_items: project_paths
when: check_install[item.name].stat.exists == false
- name: done
fail: msg="{{ item.name } installer does not exist"
with_items: project_paths
when: check_install[item.name].stat.exists == false
Basically I am wondering the best way to run stat or other register
commands with_items so that I can later check that on other with_item tasks
for the same variables.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.