Yeah, fair enough ;)

It would be interesting to know though if this isn't working because:

1. It should/could work but I'm not doing it right
2. It doesnt/will not work and I should just stop trying

Either way, the stacktrace is kinda ugly?

On Thursday, 2 October 2014 22:46:43 UTC+2, Michael DeHaan wrote:
>
> Probably that nobody is trying it :)
>
>
>
> On Wed, Oct 1, 2014 at 1:32 PM, Mikael Sandström <ora...@gmail.com 
> <javascript:>> wrote:
>
>> So I havent made any progress with this, and given the lack of response I 
>> take it this will not work?
>>
>> The workaround hack it is then
>>
>> /Micke
>>
>>
>> On Friday, September 26, 2014 3:00:59 PM UTC+2, Mikael Sandström wrote:
>>>
>>> Hi,
>>>
>>> I've got the following structures (or at least I'm hoping to be able to 
>>> use them)
>>>
>>> list_of_files:
>>>        - { filename: file1, version: 1 }
>>>        - { filename: file2, version: 1 }
>>>        - { filename: file3, version: 1 }
>>>        - { filename: file1, version: 2 }
>>>        - { filename: file2, version: 2 }
>>>        - { filename: file1, version: 3 }
>>>        - { filename: file1, version: 4 }
>>>        - { filename: file1, version: 5 }
>>>        - { filename: file2, version: 5 }
>>>
>>> dict_name:                                    
>>>         key1:                                
>>>              type: x        
>>>              dictversion: 1          
>>>         key2:                                
>>>              type: y        
>>>              dictversion: 2
>>>         key3:                                
>>>              type: z        
>>>              dictversion: 1        
>>>
>>>  
>>>
>>> I'd like to use *dict_name.key.dictversion* to download all files from 
>>> *list_of_files* where *dict_name.keyX.dictversion==**list_of_files*
>>> *.version. *
>>> Meaning, for each key, I'd like to get the (variable) number of files 
>>> with the versionnumber that specific key has.
>>>
>>>
>>> I tried with this:
>>>
>>>   - name: Get files
>>>     get_url: url={{ source }}/{{ item.0.filename }} dest={{ somewhere }}
>>>     with_together:
>>>         - dict_name
>>>         - list_of_files
>>>     when: "{{ dict_name[item.1].dictversion }}" == "{{ item.0.version }}
>>>
>>> But it doesnt work. It errors out with a stacktrace:
>>>   File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", 
>>> line 561, in _executor
>>>     exec_rc = self._executor_internal(host, new_stdin)
>>>   File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", 
>>> line 696, in _executor_internal
>>>     complex_args=complex_args
>>>   File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", 
>>> line 756, in _executor_internal_inner
>>>     if not utils.check_conditional(cond, self.basedir, inject, 
>>> fail_on_undefined=self.error_on_undefined_vars):
>>>   File "/usr/lib/python2.7/site-packages/ansible/utils/__init__.py", 
>>> line 254, in check_conditional
>>>     conditional = template.template(basedir, conditional, inject, 
>>> fail_on_undefined=fail_on_undefined)
>>>   File "/usr/lib/python2.7/site-packages/ansible/utils/template.py", 
>>> line 115, in template
>>>     varname = template_from_string(basedir, varname, vars, 
>>> fail_on_undefined)
>>>   File "/usr/lib/python2.7/site-packages/ansible/utils/template.py", 
>>> line 357, in template_from_string
>>>     res = jinja2.utils.concat(rf)
>>>   File "<template>", line 10, in root
>>>   File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 
>>> 372, in getattr
>>>     return getattr(obj, attribute)
>>>   File "/usr/lib/python2.7/site-packages/jinja2/runtime.py", line 463, 
>>> in __getattr__
>>>     return self._fail_with_undefined_error()
>>>   File "/usr/lib/python2.7/site-packages/jinja2/runtime.py", line 457, 
>>> in _fail_with_undefined_error
>>>     raise self._undefined_exception(hint)
>>> UndefinedError: dict object has no element None
>>>
>>>
>>> Is this even possible? 
>>>
>>> I could work around this by adding something like a 'download: 
>>> true/false' to the list and use that in the when:, but I really like the to 
>>> be able to control which files to get by using the dictversion variable in 
>>> *dict_name*
>>>
>>> regards
>>> /Micke
>>>
>>>
>>>
>>>  -- 
>> 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 ansible-proje...@googlegroups.com <javascript:>.
>> To post to this group, send email to ansible...@googlegroups.com 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/b50b8424-9bd5-4bca-b1ee-725ca2520533%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/b50b8424-9bd5-4bca-b1ee-725ca2520533%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/85794506-e1f9-4573-a24d-527e34ab7ba9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to