Пример #1
0
def sync_key(key_name, client=None):
    if not client:
        cloud = env.cloud()
        client = ssh.master_client(cloud)

    ssh.sudo(
            client,
            'salt \'*\' ssh.set_auth_key_from_file ubuntu salt://keys/%s' % \
            key_name)
Пример #2
0
def sync_key(key_name, client=None):
    if not client:
        cloud = env.cloud()
        client = ssh.master_client(cloud)

    ssh.sudo(
            client,
            'salt \'*\' ssh.set_auth_key_from_file ubuntu salt://keys/%s' % \
            key_name)
Пример #3
0
def highstate(minion_id=None, grain=None):

    cloud = env.cloud()
    client = ssh.master_client(cloud)

    if minion_id:
        ssh.sudo(client, 'salt \'%s\' state.highstate' % minion_id)
    elif grain:
        ssh.sudo(client, 'salt -G \'%s\' state.highstate' % grain)
Пример #4
0
def highstate(minion_id=None, grain=None):

    cloud = env.cloud()
    client = ssh.master_client(cloud)

    if minion_id:
        ssh.sudo(client, 'salt \'%s\' state.highstate' % minion_id)
    elif grain:
        ssh.sudo(client, 'salt -G \'%s\' state.highstate' % grain)
Пример #5
0
def _add_key():
    user_path = os.path.expanduser('~/.ssh')
    files = glob.glob(os.path.join(user_path, 'id_rsa.pub'))

    if len(files) < 1:
        # TODO ERROR MESSAGES
        return

    target = files[0]
    log.debug('Transferring public key \'%s\' to master', target)
    cloud = env.cloud()

    with open(target, 'rb') as f:
        key_name = hashlib.md5(f.read()).hexdigest()

    sync_file(target, '/tmp/%s' % key_name, cloud)

    client = ssh.master_client(cloud)
    ssh.sudo(
        client,
        'mv /tmp/%s /srv/cloudseed/keys && chmod 600 /srv/cloudseed/keys/%s' % \
        (key_name, key_name))

    salt.sync_key(key_name, client=client)