#!/usr/bin/env python

#coding:utf8

from fabric.api import *

fd=open("iplist.txt",'r')

fd_ssh_pub=open("/root/.ssh/id_rsa.pub",'r')


iplist_new=[]

for i in fd:

        iplist_new.append(i.strip('\n').split(':'))


env.passwords=dict(iplist_new)

env.hosts=env.passwords.keys()


def host_type():

        from fabric.state import env

        env.password=env.passwords[env.host_string]

        run('uname -a')

def ssh_trust():

        from fabric.state import env

        env.password=env.passwords[env.host_string]

        run('mkdir -p /root/.ssh;echo "%s" >>/root/.ssh/authorized_keys' % fd_ssh_pub.read() )