def set_hostname(hostname=None, commit_change=True):
    conn = __proxy__['junos.conn']()
    ret = dict()
    if hostname is None:
        ret['out'] = False
        return ret

    # Added to recent versions of JunOs
    # Use text format instead
    set_string = 'set system host-name {0}'.format(hostname)
    conn.cu.load(set_string, format='set')
    if commit_change:
        return commit()
    else:
        ret['out'] = True
        ret['msg'] = 'set system host-name {0} is queued'.format(hostname)

    return ret
To set the name of the device.
dataset/ETHPy150Open saltstack/salt/salt/modules/junos.py/set_hostname