- name: Check if sitemap is present stat: path={{ ansible_www_home }}/{{ item.dest }}/sitemap.xml with_items: repositories when: item.type == "prestashop" register: sitemap
- debug: var=sitemap
- name: Create sitemap.xml if necessary file: > path={{ ansible_www_home }}/{{ item.dest }}/sitemap.xml owner=www-data group=www-data mode=0644 with_items: repositories when: item.type == "prestashop" and sitemap.results.item is defined and sitemap.results.stat.exists == False
"sitemap": { "changed": false, "msg": "All items completed", "results": [ { "changed": false, "skipped": true }, { "changed": false, "skipped": true }, { "changed": false, "invocation": { "module_args": "path=/home/yprox/ansible-www/project/sitemap.xml", "module_name": "stat" }, "item": { "dest": "top-kids", "repo": "g...@github.com:Organisation/project.git", "type": "prestashop", "version": "master" }, "stat": { "exists": false, }
},
..........- name: Create sitemap.xml if necessary
file: >
path={{ ansible_www_home }}/{{ item.dest }}/sitemap.xml
owner=www-data
group=www-data
mode=0644
with_items: sitemap.results
when: item.item.type is defined and item.item.type == "prestashop" and item.stat.exists == False
- name: Create sitemap.xml if necessary file: > path={{ ansible_www_home }}/{{ item.item.dest }}/sitemap.xml owner=www-data group=www-data mode=0644 file=touch