def create_rule(module, container_image=None):
    '''
    Create a new crush replicated/erasure rule
    '''

    cluster = module.params.get('cluster')
    name = module.params.get('name')
    rule_type = module.params.get('rule_type')
    bucket_root = module.params.get('bucket_root')
    bucket_type = module.params.get('bucket_type')
    device_class = module.params.get('device_class')
    profile = module.params.get('profile')

    if rule_type == 'replicated':
        args = ['create-replicated', name, bucket_root, bucket_type]
        if device_class:
            args.append(device_class)
    else:
        args = ['create-erasure', name]
        if profile:
            args.append(profile)

    cmd = generate_cmd(sub_cmd=['osd', 'crush', 'rule'],
                       args=args,
                       cluster=cluster,
                       container_image=container_image)

    return cmd

    Create a new crush replicated/erasure rule
    
library/ceph_crush_rule.py