Fix alarm action comparison (#23523)

This fixes issue when list from module contains more than one element.
Ansible and/or boto may put same elements in list in different order,
thus resulting task as changed.

Fixes #3310
This commit is contained in:
Łukasz Kostka 2017-04-13 20:27:48 +02:00 committed by Matt Davis
parent b6c00f722b
commit 94bd647bc0

View file

@ -225,7 +225,9 @@ def create_metric_alarm(connection, module):
for attr in ('alarm_actions','insufficient_data_actions','ok_actions'):
action = module.params.get(attr) or []
if getattr(alarm, attr) != action:
# Boto and/or ansible may provide same elements in lists but in different order.
# Compare on sets since they do not need any order.
if set(getattr(alarm, attr)) != set(action):
changed = True
setattr(alarm, attr, module.params.get(attr))