Fix rds "promote" command never promoting

Previously, the `promote` command in the `rds` module would always return OK and never actually promote an instance. This was because `promote_db_instance()` had its conditions backwards: if the instance had the `replication_source` attribute indicating that it **was** a replica, it would set `changed = False` and do nothing. If the instance **wasn't** a replica, it would attempt to run `boto.rds.promote_read_replica()`, which would always fail.
pull/18777/head
Max Rothman 9 years ago committed by Matt Clay
parent 88f221fd9f
commit 086038cb4f

@ -829,13 +829,17 @@ def promote_db_instance(module, conn):
instance_name = module.params.get('instance_name') instance_name = module.params.get('instance_name')
result = conn.get_db_instance(instance_name) result = conn.get_db_instance(instance_name)
if not result:
module.fail_json(msg="DB Instance %s does not exist" % instance_name)
if result.get_data().get('replication_source'): if result.get_data().get('replication_source'):
changed = False
else:
try: try:
result = conn.promote_read_replica(instance_name, **params) result = conn.promote_read_replica(instance_name, **params)
changed = True
except RDSException, e: except RDSException, e:
module.fail_json(msg=e.message) module.fail_json(msg=e.message)
else:
changed = False
if module.params.get('wait'): if module.params.get('wait'):
resource = await_resource(conn, result, 'available', module) resource = await_resource(conn, result, 'available', module)

Loading…
Cancel
Save