Exemplo n.º 1
0
	def testUserCheck( self ):
		user_data = cuisine.user_check(USER)
		assert user_data
		assert user_data["name"] == USER
		assert user_data == cuisine.user_check(name=USER)
		# We ensure that user_check works with uid and name
		assert cuisine.user_check(uid=user_data["uid"])
		assert cuisine.user_check(uid=user_data["uid"])["name"] == user_data["name"]
Exemplo n.º 2
0
 def testUserCheck(self):
     user_data = cuisine.user_check(USER)
     assert user_data
     assert user_data["name"] == USER
     assert user_data == cuisine.user_check(name=USER)
     # We ensure that user_check works with uid and name
     assert cuisine.user_check(uid=user_data["uid"])
     assert cuisine.user_check(
         uid=user_data["uid"])["name"] == user_data["name"]
Exemplo n.º 3
0
	def testUserCheckNeedPasswd( self ):
		user_data = cuisine.user_check(USER, need_passwd=False)
		user_data_with_passwd = cuisine.user_check(name=USER)
		assert user_data
		assert user_data["name"] == USER
		assert 'passwd' in user_data_with_passwd
		assert 'passwd' not in user_data
		# We ensure that user_check works with uid and name
		assert cuisine.user_check(uid=user_data["uid"], need_passwd=False)
		assert cuisine.user_check(uid=user_data["uid"], need_passwd=False)["name"] == user_data["name"]
Exemplo n.º 4
0
 def testUserCheckNeedPasswd(self):
     user_data = cuisine.user_check(USER, need_passwd=False)
     user_data_with_passwd = cuisine.user_check(name=USER)
     assert user_data
     assert user_data["name"] == USER
     assert 'passwd' in user_data_with_passwd
     assert 'passwd' not in user_data
     # We ensure that user_check works with uid and name
     assert cuisine.user_check(uid=user_data["uid"], need_passwd=False)
     assert cuisine.user_check(
         uid=user_data["uid"],
         need_passwd=False)["name"] == user_data["name"]
Exemplo n.º 5
0
def create_deployment_user():
    '''
    Create the deployment user
    '''
    if user_check('deployment') == None:
        print(green("Creating deployment user"))
        user_create('deployment', DEPLOYMENT_PASSWORD, uid=502, \
                        shell='/bin/bash', home='/opt/apps')
    else:
        print(red("Deployment user already exists"))
Exemplo n.º 6
0
def uninstall():
    if fabric.contrib.console.confirm(
        "!!! ACHTUNG !!!\nthis will delete all data!\nContinue?",
        default=False):
        run('service apache2 stop')
        if user_check(project_name):
            user_remove(project_name)
            run('rm -rf /home/%s' % project_name)
        file_unlink('/etc/apache2/sites-enabled/' + project_name)
        run('rm -rf /etc/apache2/sites-available/' + project_name)
        run('service apache2 start')
Exemplo n.º 7
0
def create_default_user():
    '''
    Create a default user so we can still login after puppet runs 
    and disables root login
    '''
    if user_check(DEFAULT_USER) == None:
        print(green("Creating default user %s" % DEFAULT_USER))
        user_create(DEFAULT_USER, DEFAULT_PASSWORD, uid=503, shell='/bin/bash')
        print(green("Adding %s to sudo group" % DEFAULT_USER))
        sudo_group(DEFAULT_USER)
    else:
        print(green("Default user %s already exists" % DEFAULT_USER))
Exemplo n.º 8
0
def add_user(username, password):
    '''
    Add user.
    '''
    mode_sudo()
    if not user_check(username):
        print(green("Creating user %s" % username))
        user_create(username, shell='/bin/bash')
        passwd(username, password)
        sudo_group(username)
        print(green("Added user %s to %s" % (username, env.host_string)))
    else:
        print(red("User already exists"))
Exemplo n.º 9
0
    def testAuthorize(self):
        cuisine.ssh_authorize(USER, self.key)
        d = cuisine.user_check(USER, need_passwd=False)
        keyf = d["home"] + "/.ssh/authorized_keys"
        keys = [line.strip() for line in open(keyf)]

        print(self.key)

        print(keyf)

        print(keys)

        assert keys.count(self.key) == 1
Exemplo n.º 10
0
def setup():
    """ Main setup"""

    puts(green('-> Configuring SSHD')) 
    cuisine.sudo('sed -i "s/LoginGraceTime 120/LoginGraceTime 30/g" /etc/ssh/sshd_config') 
    cuisine.sudo('sed -i "s/#PasswordAuthentication yes/PasswordAuthentication no/g" /etc/ssh/sshd_config') 
    puts(green('-> Restart SSHD')) 
    cuisine.sudo('/etc/init.d/ssh restart')

    if cuisine.user_check('vagrant') and not cuisine.file_exists('/home/vagrant/.tmux.conf'):
        puts(green('-> Creating tmux config'))        
        cuisine.file_upload('/home/vagrant/.tmux.conf', 
                './provision/config/tmux.conf',
                sudo='vagrant')
Exemplo n.º 11
0
    def apply(self, computer):
        username = "******"
        if not cuisine.user_check(username):
            cuisine.user_create(username)
            cuisine.sudo('usermod -p `openssl rand -base64 32` %s' % username)

        key = self.environment["users"][username]["ssh_public_key"]
        cuisine.ssh_authorize(username, key)

        cuisine.dir_ensure('/home/example_com/www',
                           mode='755',
                           owner=username,
                           group=username)
        cuisine.file_link('/home/example_com/www', '/srv/www/example_com')

        self.push_package_file_set('example_com', computer)

        cuisine.file_link('/etc/nginx/sites-available/example_com',
                          '/etc/nginx/sites-enabled/example_com')

        cuisine.sudo("service nginx restart")
Exemplo n.º 12
0
	def testUserCheck( self ):
		user_data = cuisine.user_check(USER)
		assert user_data
		assert user_data["name"] == USER
Exemplo n.º 13
0
	def testUnauthorize( self ):
		cuisine.ssh_unauthorize(USER, self.key)
		d = cuisine.user_check(USER, need_passwd=False)
		keyf = d["home"] + "/.ssh/authorized_keys"
		keys = [line.strip() for line in open(keyf)]
		assert keys.count(self.key) == 0
Exemplo n.º 14
0
 def testUserCheck(self):
     user_data = cuisine.user_check(USER)
     print "USER_DATA", user_data
Exemplo n.º 15
0
	def testUserCheck( self ):
		user_data = cuisine.user_check(USER)
		print "USER_DATA", user_data