'Make the necessary changes'

def run(self):

    changed = False
    try:
        if (self.state == 'absent'):
            if self.exists():
                self.delete()
                changed = True
        elif (self.state == 'present'):
            if (not self.exists()):
                self.add()
                changed = True
            current_fail_mode = self.get_fail_mode()
            if (self.fail_mode and (self.fail_mode != current_fail_mode)):
                self.module.log(('changing    fail    mode    %s    to    %s' % (current_fail_mode, self.fail_mode)))
                self.set_fail_mode()
                changed = True
            current_external_ids = self.get_external_ids()
            exp_external_ids = self.module.params['external_ids']
            if (exp_external_ids is not None):
                for (key, value) in exp_external_ids.items():
                    if ((value != current_external_ids.get(key, None)) and self.set_external_id(key, value)):
                        changed = True
                for (key, value) in current_external_ids.items():
                    if ((key not in exp_external_ids) and self.set_external_id(key, None)):
                        changed = True
    except Exception:
        earg = get_exception()
        self.module.fail_json(msg=str(earg))
    self.module.exit_json(changed=changed)
