hello ok

i did some more debugging.
looks like an bug.

the combination uri,  with_items and when is the problem

using only two of them work fine

server -> is a straight forward dict.


On Wednesday, December 20, 2017 at 5:01:01 PM UTC+1, Matt Martz wrote:

> Seeing the output of the debug task could probably be helpful for 
> answering your question.
>
> On Wed, Dec 20, 2017 at 9:02 AM, Mark Eisenblätter <mark.eise...@gmail.com 
> <javascript:>> wrote:
>
>> Ok forget: 
>> ansible-playbook 2.4.1.0
>>
>>
>> On Wednesday, December 20, 2017 at 4:01:04 PM UTC+1, Mark Eisenblätter 
>> wrote:
>>>
>>> hello list,
>>>
>>> i have a strage problem. 
>>>    # do we need to readd server to cluster in case of rebuild
>>>     - name: get etcd server
>>>       set_fact:
>>>         etcd_server: "{{ lookup('get_serverip_by_group', zone, 
>>> 'kubernetes_etcd', wantlist=True)}}"
>>>
>>>     # Get ETCD Members
>>>     - name: get all members from ETCD Cluster
>>>       uri:
>>>         url: http://{{ item }}:2379/v2/members
>>>       register: etcd_members
>>>       with_items: "{{ etcd_server }}"
>>>       when: etcd_members is not defined or etcd_members.failed
>>>       ignore_errors: true
>>>
>>>     - debug: var=etcd_members
>>>
>>>     - name: did i get members?
>>>       fail: msg="NO Members found"
>>>       when: '"failed" in etcd_members.results[-1] and 
>>> etcd_members.results[-1].failed == true'
>>>
>>>     - name: body template
>>>       template:
>>>         src: "{{ playbook_dir }}/templates/add_etcd_member.json.j2"
>>>         dest: "{{ playbook_dir }}/tmp/add_etcd_member-{{ server['name'] 
>>> }}.json"
>>>       when: lookup('get_id_from_etcd_api', etcd_members.results, 
>>> server['name']) == None
>>>
>>>     - debug: var=server
>>>
>>>     # add ETCD member
>>>     - name: add member
>>>       uri:
>>>         url: http://{{ item }}:2379/v2/members
>>>         method: POST
>>>         body_fromat: json
>>>         body: "{{ lookup('file', playbook_dir + '/tmp/add_etcd_member-' 
>>> + server['name'] * '.json') }}"
>>>       register: etcd_add
>>>       with_items: "{{ etcd_server }}"
>>>       when: lookup('get_id_from_etcd_api', etcd_members.results, 
>>> server['name']) == None
>>>        #- (etcd_add is not defined or etcd_add.failed)
>>>       ignore_errors: true
>>>
>>>     - debug: var=etcd_add
>>>
>>>     - name: "did i delete member: {{ server['name'] }}?"
>>>       fail: msg="did not delete {{ server['name'] }}"
>>>       when: '"failed" in etcd_add.results[-1] and 
>>> etcd_add.results[-1].failed == true'
>>>
>>>
>>> in module template the when clause works fine, but in the URI it casues 
>>> an errer
>>>
>>> fatal: [localhost]: FAILED! => {"failed": true, "msg": "The conditional 
>>> check 'lookup('get_id_from_etcd_api', etcd_members.results, server['name']) 
>>> == None' failed. The error was: error while evaluating conditional 
>>> (lookup('get_id_from_etcd_api', etcd_members.results, server['name']) == 
>>> None): 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no 
>>> attribute 'name'\n\nThe error appears to have been in 
>>> '/build/tasks/add_etcd_to_cluster.yaml': line 35, column 7, but may\nbe 
>>> elsewhere in the file depending on the exact syntax problem.\n\nThe 
>>> offending line appears to be:\n\n    # add ETCD member\n    - name: add 
>>> member\n      ^ here\n"}
>>>
>>>
>>> but i have no idea why it works the first time and not the second?
>>>
>>> server['name'] is there i use it on many parts and it is working fine 
>>> everywhere else.
>>>
>>>
>>> thanks in advanced,
>>> mark
>>>
>> -- 
>> 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/3d6aad3e-6daa-4fca-a441-74898e70aa4d%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/3d6aad3e-6daa-4fca-a441-74898e70aa4d%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Matt Martz
> @sivel
> sivel.net
>

-- 
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/4a17dd39-3a63-4056-8b3b-f1ad50c53ce1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to