You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
792 B
Python
37 lines
792 B
Python
#!/usr/bin/python
|
|
|
|
DOCUMENTATION = '''
|
|
---
|
|
module: smardigo_user_token
|
|
short_description: create smardigo user token
|
|
'''
|
|
EXAMPLES = '''
|
|
- hosts: localhost
|
|
tasks:
|
|
- name: create smardigo user token
|
|
smardigo_user_token:
|
|
secret: ""
|
|
user_id: ""
|
|
register: result
|
|
- debug: var=result
|
|
'''
|
|
|
|
from jose import jwe
|
|
from ansible.module_utils.basic import *
|
|
|
|
def main():
|
|
|
|
fields = {
|
|
"secret": {"default": False, "type": "str"},
|
|
"user_id": {"default": False, "type": "str"}
|
|
}
|
|
|
|
module = AnsibleModule(argument_spec=fields)
|
|
|
|
token = jwe.encrypt('{"sub":"' + module.params["user_id"] + '"}', module.params["secret"], algorithm='dir', encryption='A128CBC-HS256')
|
|
|
|
module.exit_json(changed=True, token=token)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|