14:59:14 #startmeeting ansible core public irc meeting 14:59:14 Meeting started Thu Oct 8 14:59:14 2020 UTC. 14:59:14 This meeting is logged and archived in a public location. 14:59:14 The chair is bcoca. Information about MeetBot at http://wiki.debian.org/MeetBot. 14:59:14 Useful Commands: #action #agreed #halp #info #idea #link #topic. 14:59:14 The meeting name has been set to 'ansible_core_public_irc_meeting' 14:59:40 o/ 15:00:11 o/ 15:00:56 #topic ansible/ansible#71118 15:01:29 yoctozepto: i would say 'no' to this, handler notification is based on 'task result' not 'item result' 15:01:38 https://github.com/ansible/ansible/pull/71118 15:01:39 an item can add to the list of notified handlers 15:02:16 if you dont want to add to the list, you can add that to the notify expression to avoid that specific item, based on any condition, including per item change 15:02:52 how so? 15:03:13 we loop over several services to check if they need a restart 15:03:27 presumably need to notify only the changed service 15:03:32 but they all get notified instead 15:03:39 because all iterations get the trigger 15:03:43 if any one does 15:03:50 what if you mark the general task failed? 15:04:13 why would I want to fail the task? 15:04:51 you might not want to, but it fails, host gets taken out of active list, then now notifications for 'non hosts' are in queue for handlers 15:05:17 there is a reason the 'handler notification' happens at task level, since most of the things that it requires to function are at that level 15:05:32 yoiu have a specific use case that this would work for, but it breaks many others 15:05:52 I see 15:06:23 any recommendation how to work around the issue we have? looped handlers are pretty limited now... 15:06:25 as for populating the 'notify list' that is fine if it happens per item, since we only require it at the end of taks when we decide to notify or not 15:06:39 looped handlers or notifying from looped task? 15:06:43 those are diff things 15:07:07 looped notifies* 15:07:21 (I shortcircuited) 15:07:25 not really seeing the limit, just dont add the handler to list on a condition 15:08:31 https://opendev.org/openstack/kolla-ansible/src/branch/master/ansible/roles/nova/tasks/check-containers.yml 15:09:13 I couldn't figure out how to amend that except by involving include_task indirection which induces a performance penalty 15:10:10 notify: [ "{{ results is changed|ternary('Restart ' ~ item.key ~ ' container', None) }}" ] 15:10:16 ^ or similar 15:11:41 oh, I'll give it a try then! 15:11:49 I've never seen it used like this before tbh 15:12:52 you can even skip the [] i just added in case you wanted to do several items per loop 15:13:12 notify: "{{ results is changed|ternary('Restart ' ~ item.key ~ ' container', None) }}" should work just as well 15:13:30 since any 'list' will take a string as a 'list of one' 15:13:51 just careful with , cause then it will be 'comma separated string' and split on that 15:14:13 thank you, makes sense 15:14:25 15:14:29 anything else? 15:14:33 lol 15:14:48 not from me, I'll try your hint and let you know in the PR 15:19:10 #topic open floor 15:24:16 bcoca: it doesn't seem to like it though 15:24:21 I get "The 'changed' test expects a dictionary" 15:26:13 you might need to use results list and item index 15:26:36 registered vars get 'tricky' when used inside loop, there should be some examples of use in 'when' clauses 15:27:24 oh, right, indexing right away 15:37:45 bcoca: nope, it does not see the registered results at all in this scope :-( 15:37:59 the same message is if I try to check total gibberish 15:39:18 can you share a gist of what you're doing? 15:39:23 i'll need to look into that, but it is possible to get inline results and/or tailor the list 15:39:35 shertel: https://opendev.org/openstack/kolla-ansible/src/branch/master/ansible/roles/nova/tasks/check-containers.yml 15:41:04 http://paste.openstack.org/show/798873/ 15:41:12 I'll tried the above without indexing yet ^ 15:41:26 but this would normally be a dictionary 15:41:36 containing the global 'changed' value 15:41:50 but it seems the 'register' has not happened yet 15:41:58 i'll need to look into that, but it is possible to get inline results and/or tailor the list http://paste.debian.net/1166362/ 15:42:21 register does happen, but you have to keep in mind how its evaluated, so default is always needed at one point to avoikd initial errors 15:43:16 though might be better to just use map and construct the list at the end when you ahve .results 15:43:57 ah, ok, let's see 15:44:22 '{{ "results" in r|ternary(r.results|map(...) , omit)}}' 15:44:41 might still need default there, cause of how ternary works 15:44:51 if/else syntax might be better in this case 15:49:12 |default({}) resulted in no handlers getting triggered, possibly because it had to always default to {} 15:50:52 i'll try the var indirection 15:57:08 ^ hmm, my test does get them triggered 15:57:21 in any case, we can continue this elsewhere, goint to close meeting for now 15:57:24 #endmeeting