Oh great, but *sitemap.results* doesn't know the *item.dest *which was 
contained in the first array (*repositories).*

Is there a way to cross arrays in order to avoid loosing the reference to 
item.dest (because I want to know where to create the sitemap, and right 
now with your solution, it doesn't know)


Le lundi 19 janvier 2015 13:52:30 UTC+1, [email protected] a écrit :
>
>
> Remember *s**itemap* is a list. So you need to loop over that 
> <http://docs.ansible.com/playbooks_loops.html#using-register-with-a-loop>.
>
> You should be able to do something like:
>
> - 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
>
>
>
> On Monday, January 19, 2015 at 5:51:04 AM UTC-5, Tristan Bessoussa wrote:
>>
>> Hi, 
>>
>> I'm trying to achieve something basic (v1.8.2):  create a sitemap.xml if 
>> not exist for prestahsop projects.
>>
>>
>> - 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
>>
>>
>> The debug statement gives me 
>>
>>     "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": "[email protected]:Organisation/project.git", 
>>                     "type": "prestashop", 
>>                     "version": "master"
>>                 }, 
>>                 "stat": {
>>                     "exists": false, 
>>                 }
>>             },
>>             ..........
>>
>>
>> I have at least one node which has "exists" false. But it does not create 
>> the file. It just goes "Skipped".
>>
>> Why ? Thanks :-)
>>
>

-- 
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].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c62d5b5c-b3a0-47fe-826a-6cf320992988%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to