#!/usr/bin/python # Copyright: (c) 2023, John Fulton # Apache License Version 2.0 (see LICENSE) from __future__ import absolute_import, division, print_function __metaclass__ = type DOCUMENTATION = r""" --- module: cephx_key short_description: Generate a random CephX authentication key description: - Generate a random CephX authentication key and return it author: - John Fulton (@fultonj) """ EXAMPLES = r""" - name: Generate a cephx key cephx_key: register: cephx - name: Show cephx key debug: msg: "{{ cephx.key }}" """ RETURN = r""" key: description: A random cephx authentication key type: dict returned: success sample: - KEY: AQC+vYNXgDAgAhAAc8UoYt+OTz5uhV7ItLdwUw== """ from ansible.module_utils.basic import AnsibleModule import base64 import os import struct import time def __create_cephx_key(): # NOTE(fultonj): Taken from # https://github.com/ceph/ceph-deploy/blob/master/ceph_deploy/new.py#L21 key = os.urandom(16) header = struct.pack("