fix regression introduced by f38186ce8b, and propose a fix for docker facts

This commit is contained in:
Philippe Jandot 2015-09-16 16:49:09 +02:00 committed by Matt Clay
parent abca0327b9
commit 5b7d72e4ef

View file

@ -1554,7 +1554,8 @@ def present(manager, containers, count, name):
delta = count - len(containers.deployed) delta = count - len(containers.deployed)
if delta > 0: if delta > 0:
containers.notice_changed(manager.create_containers(delta)) created = manager.create_containers(delta)
containers.notice_changed(manager.get_inspect_containers(created))
if delta < 0: if delta < 0:
# If both running and stopped containers exist, remove # If both running and stopped containers exist, remove
@ -1569,8 +1570,8 @@ def present(manager, containers, count, name):
to_remove.append(c) to_remove.append(c)
manager.stop_containers(to_stop) manager.stop_containers(to_stop)
containers.notice_changed(manager.get_inspect_containers(to_remove))
manager.remove_containers(to_remove) manager.remove_containers(to_remove)
containers.notice_changed(to_remove)
def started(manager, containers, count, name): def started(manager, containers, count, name):
'''Ensure that exactly `count` matching containers exist and are running.''' '''Ensure that exactly `count` matching containers exist and are running.'''
@ -1586,13 +1587,13 @@ def started(manager, containers, count, name):
created = manager.create_containers(delta) created = manager.create_containers(delta)
manager.start_containers(created) manager.start_containers(created)
containers.notice_changed(created) containers.notice_changed(manager.get_inspect_containers(created))
if delta < 0: if delta < 0:
excess = containers.running[0:-delta] excess = containers.running[0:-delta]
containers.notice_changed(manager.get_inspect_containers(excess))
manager.stop_containers(excess) manager.stop_containers(excess)
manager.remove_containers(excess) manager.remove_containers(excess)
containers.notice_changed(excess)
def reloaded(manager, containers, count, name): def reloaded(manager, containers, count, name):
''' '''
@ -1626,7 +1627,7 @@ def stopped(manager, containers, count, name):
containers.refresh() containers.refresh()
manager.stop_containers(containers.running) manager.stop_containers(containers.running)
containers.notice_changed(containers.running) containers.notice_changed(manager.get_inspect_containers(containers.running))
def killed(manager, containers, count, name): def killed(manager, containers, count, name):
'''Kill any matching containers that are running.''' '''Kill any matching containers that are running.'''
@ -1634,7 +1635,7 @@ def killed(manager, containers, count, name):
containers.refresh() containers.refresh()
manager.kill_containers(containers.running) manager.kill_containers(containers.running)
containers.notice_changed(containers.running) containers.notice_changed(manager.get_inspect_containers(containers.running))
def absent(manager, containers, count, name): def absent(manager, containers, count, name):
'''Stop and remove any matching containers.''' '''Stop and remove any matching containers.'''
@ -1642,8 +1643,8 @@ def absent(manager, containers, count, name):
containers.refresh() containers.refresh()
manager.stop_containers(containers.running) manager.stop_containers(containers.running)
containers.notice_changed(manager.get_inspect_containers(containers.deployed))
manager.remove_containers(containers.deployed) manager.remove_containers(containers.deployed)
containers.notice_changed(containers.deployed)
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
@ -1756,9 +1757,8 @@ def main():
module.exit_json(changed=manager.has_changed(), module.exit_json(changed=manager.has_changed(),
msg=manager.get_summary_message(), msg=manager.get_summary_message(),
summary=manager.counters, summary=manager.counters,
containers=containers.changed,
reload_reasons=manager.get_reload_reason_message(), reload_reasons=manager.get_reload_reason_message(),
ansible_facts=_ansible_facts(manager.get_inspect_containers(containers.changed))) ansible_facts=_ansible_facts(containers.changed))
except DockerAPIError as e: except DockerAPIError as e:
module.fail_json(changed=manager.has_changed(), msg="Docker API Error: %s" % e.explanation) module.fail_json(changed=manager.has_changed(), msg="Docker API Error: %s" % e.explanation)