<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_key(service, key):
 """ Add a key to a keyring. Creates the keyring if it doesn't already exist. Logs and returns if the key is already in the keyring. """

    keyring = _keyring_path(service)
    if os.path.exists(keyring):
        with open(keyring, 'r') as ring:
            if key in ring.read():
                log('Ceph keyring exists at %s and has not changed.' % keyring,
                    level=DEBUG)
                return
            log('Updating existing keyring %s.' % keyring, level=DEBUG)

    cmd = ['ceph-authtool', keyring, '--create-keyring',
           '--name=client.{}'.format(service), '--add-key={}'.format(key)]
    check_call(cmd)
    log('Created new ceph keyring at %s.' % keyring, level=DEBUG)