def define_task(name,
                tick_script,
                task_type='stream',
                database=None,
                retention_policy='default',
                dbrps=None):
    '''
    Define a task. Serves as both create/update.

    name
        Name of the task.

    tick_script
        Path to the TICK script for the task. Can be a salt:// source.

    task_type
        Task type. Defaults to 'stream'

    dbrps
        A list of databases and retention policies in "dbname"."rpname" format
        to fetch data from. For backward compatibility, the value of
        'database' and 'retention_policy' will be merged as part of dbrps.

        .. versionadded:: 2019.2.0

    database
        Which database to fetch data from.

    retention_policy
        Which retention policy to fetch data from. Defaults to 'default'.

    CLI Example:

    .. code-block:: bash

        salt '*' kapacitor.define_task cpu salt://kapacitor/cpu.tick database=telegraf
    '''
    if not database and not dbrps:
        log.error("Providing database name or dbrps is mandatory.")
        return False

    if version() < '0.13':
        cmd = 'kapacitor define -name {0}'.format(name)
    else:
        cmd = 'kapacitor define {0}'.format(name)

    if tick_script.startswith('salt://'):
        tick_script = __salt__['cp.cache_file'](tick_script, __env__)

    cmd += ' -tick {0}'.format(tick_script)

    if task_type:
        cmd += ' -type {0}'.format(task_type)

    if not dbrps:
        dbrps = []

    if database and retention_policy:
        dbrp = '{0}.{1}'.format(database, retention_policy)
        dbrps.append(dbrp)

    if dbrps:
        for dbrp in dbrps:
            cmd += ' -dbrp {0}'.format(dbrp)

    return _run_cmd(cmd)
Define a task. Serves as both create/update.

    name
        Name of the task.

    tick_script
        Path to the TICK script for the task. Can be a salt:// source.

    task_type
        Task type. Defaults to 'stream'

    dbrps
        A list of databases and retention policies in "dbname"."rpname" format
        to fetch data from. For backward compatibility, the value of
        'database' and 'retention_policy' will be merged as part of dbrps.

        .. versionadded:: 2019.2.0

    database
        Which database to fetch data from.

    retention_policy
        Which retention policy to fetch data from. Defaults to 'default'.

    CLI Example:

    .. code-block:: bash

        salt '*' kapacitor.define_task cpu salt://kapacitor/cpu.tick database=telegraf