Exemplo n.º 1
0
def get_absent_user_list():
    c = Cmd('ssh %s@%s "cd %s/afuser/manifests/users && grep del -l *.pp"|\
            sed "s/\.pp//g"' % (PUPPET_USER, PUPPET_SERVER, PUPPET_MODULE_DIR))
    if c.is_success():
        users = c.output().split()
    else:
        users = []

    return users
Exemplo n.º 2
0
def add_user(user_name, pub_key, is_admin=False, app='all'):
    import os

    while True:
        f = open('user', 'w')
        if is_admin:
            from puppet.resource import add_sa_template
            f.write(add_sa_template(name=user_name))
        else:
            from puppet.resource import add_user_template
            f.write(add_user_template(name=user_name))
        f.close()
        f = open('key', 'w')
        f.write(pub_key)
        f.close()

        c = Cmd('scp user %s@%s:%s/afuser/manifests/users/%s.pp'\
                % (PUPPET_USER, PUPPET_SERVER, PUPPET_MODULE_DIR, user_name))
        print(c.output())
        if not c.is_success():
            break

        c = Cmd('scp key %s@%s:%s/afuser/files/keys/%s'\
                % (PUPPET_USER, PUPPET_SERVER, PUPPET_MODULE_DIR, user_name))
        print(c.output())
        if not c.is_success():
            break

        c = Cmd('ssh -t %s@%s sudo touch %s/puppet.conf' % (PUPPET_USER,
                                                            PUPPET_SERVER,
                                                            PUPPET_BASE_DIR))
        print(c.output())
        c = Cmd('ssh -t %s@%s sudo puppetrun app10-0{%s}.i.ajkdns.com' \
                % (PUPPET_USER, PUPPET_SERVER, PUPPET_APPS))
        print(c.output())
        if not c.is_success():
            break

        break
Exemplo n.º 3
0
def del_user(user_name, app='all'):
    from puppet.resource import del_user_template
    while True:
        f = open('user', 'w')
        f.write(del_user_template(name=user_name))
        f.close()

        c = Cmd('scp user %s@%s:%s/afuser/manifests/users/%s.pp'\
                % (PUPPET_USER, PUPPET_SERVER, PUPPET_MODULE_DIR, user_name))
        print(c.output())
        if not c.is_success():
            break

        c = Cmd('ssh -t %s@%s sudo touch %s/puppet.conf' % (PUPPET_USER,
                                                            PUPPET_SERVER,
                                                            PUPPET_BASE_DIR))
        print(c.output())
        c = Cmd('ssh -t %s@%s sudo puppetrun app10-0{%s}.i.ajkdns.com' \
                % (PUPPET_USER, PUPPET_SERVER, PUPPET_APPS))
        print(c.output())
        if not c.is_success():
            break

        break