Hello all,
is there a specific reason why dynamic groups with group_by always signal “changed” instead of “ok”? This way a playbook containing dynamic groups always signals that items changed, although nothing is changed on any target system. If you want to monitor if things really changed since the last run IMHO it would be more convenient to have the dynamic group return status ok.
TIA,
Oliver
forgot to mention: that is with current ansible 1.2
group by created some groups.
I think its’ fair to argue it should probably never report changed in any case, just because it would keep the “# of changed tasks” lower for people who tend to get obsessive about those counts.
But I can’t see any value to hanging a handler off of a group_by task.
I’m not sure if i get the logic correctly
if inv_group not in inv_host.get_groups():
result[‘changed’] = True
inv_group.add_host(inv_host)
It is a dynamic group so no host should have this group in it’s inventory groups unless this i the second run of the same group_by argument.
→ gives “changed” on the first run, “ok” on any subsequent run that creates the same dynamic groups
From the inventory perspective the returned status is correct - it is just a bit inconvenient, when trying to track changes on hosts
But is there any useful use for this “correct” behaviour? I think the incorrect “always return changed=false” is really what we need to monitor “real” changes - thus changes to ansible inner logic/states as inventory changes should not qualify as a result[‘changed’] = True .
I’d be fine with changed=False.
It’s not /affecting/ the host, which is what changed is supposed to track.
Any chance on having this fixed in trunk or has a reason shown up for not changing it?
We simply remove the result[‘changed’] = True line and so far I’ve not seen any adverse affects but it’s a little annoying to patch each time on upgrade.
group_by should definitely report changed when it adds new things to new groups.
Also: this thread is 10 months old
Thought it would be better to follow up here for the history.
Following the docs and using group_by for distributions to assign group_vars [1], we always get a changed event even if nothing changes on the host.
[1] http://docs.ansible.com/playbooks_best_practices.html#operating-system-and-distribution-variance
You can always add “changed_when: False” to hide the output, but it’s not really hurting anything.