def policy_present(name, policy_document, path=None, description=None,
                 region=None, key=None, keyid=None, profile=None):
    ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
    policy = __salt__['boto_iam.get_policy'](name, region, key, keyid, profile)
    if not policy:
        if __opts__['test']:
            ret['comment'] = 'IAM policy {0} is set to be created.'.format(name)
            ret['result'] = None
            return ret
        created = __salt__['boto_iam.create_policy'](name, policy_document, path, description, region, key, keyid, profile)
        if created:
            ret['changes']['policy'] = created
            ret['comment'] = os.linesep.join([ret['comment'], 'Policy {0} has been created.'.format(name)])
        else:
            ret['result'] = False
            ret['comment'] = 'Failed to update policy.'
            ret['changes'] = {}
            return ret
    else:
        policy = policy.get('policy', {})
        ret['comment'] = os.linesep.join([ret['comment'], 'Policy {0} is present.'.format(name)])
        _describe = __salt__['boto_iam.get_policy_version'](name, policy.get('default_version_id'),
                                                       region, key, keyid, profile).get('policy_version', {})
        if isinstance(_describe['document'], string_types):
            describeDict = json.loads(_describe['document'])
        else:
            describeDict = _describe['document']

        if isinstance(policy_document, string_types):
            policy_document = json.loads(policy_document)

        r = salt.utils.compare_dicts(describeDict, policy_document)

        if bool(r):
            if __opts__['test']:
                msg = 'Policy {0} set to be modified.'.format(name)
                ret['comment'] = msg
                ret['result'] = None
                return ret

            ret['comment'] = os.linesep.join([ret['comment'], 'Policy to be modified'])
            policy_document = json.dumps(policy_document)

            r = __salt__['boto_iam.create_policy_version'](policy_name=name,
                                               policy_document=policy_document,
                                               set_as_default=True,
                                               region=region, key=key,
                                               keyid=keyid, profile=profile)
            if not r.get('created'):
                ret['result'] = False
                ret['comment'] = 'Failed to update policy: {0}.'.format(r['error']['message'])
                ret['changes'] = {}
                return ret

            __salt__['boto_iam.delete_policy_version'](policy_name=name,
                                               version_id=policy['default_version_id'],
                                               region=region, key=key,
                                               keyid=keyid, profile=profile)

            ret['changes'].setdefault('new', {})['document'] = policy_document
            ret['changes'].setdefault('old', {})['document'] = _describe['document']
    return ret
.. versionadded:: 2015.8.0
dataset/ETHPy150Open saltstack/salt/salt/states/boto_iam.py/policy_present